dotfiles/.config/qtile/scripts/Default.sh

309 lines
12 KiB
Bash
Executable File

#!/usr/bin/env bash
## Copyright (C) 2020-2021 Aditya Shakya <adi1090x@gmail.com>
## Everyone is permitted to copy and distribute copies of this file under GNU-GPL3
## Dirs #############################################
qtile_path="$HOME/.config/qtile"
polybar_path="$HOME/.config/qtile/polybar"
rofi_path="$HOME/.config/qtile/rofi"
terminal_path="$HOME/.config/alacritty"
xfce_term_path="$HOME/.config/xfce4/terminal"
geany_path="$HOME/.config/geany"
dunst_path="$HOME/.config/dunst"
# wallpaper ---------------------------------
set_wallpaper() {
nitrogen --save --set-zoom-fill /usr/share/backgrounds/"$1"
}
# polybar -----------------------------------
change_polybar() {
sed -i -e "s/STYLE=.*/STYLE=\"$1\"/g" ${polybar_path}/launch.sh
sed -i -e "s/font-0 = .*/font-0 = \"$2\"/g" ${polybar_path}/"$1"/config.ini
}
# rofi --------------------------------------
change_rofi() {
sed -i -e "s/STYLE=.*/STYLE=\"$1\"/g" ${rofi_path}/bin/music ${rofi_path}/bin/network ${rofi_path}/bin/screenshot ${rofi_path}/bin/runner
sed -i -e "s/DIR=.*/DIR=\"$1\"/g" ${rofi_path}/bin/launcher ${rofi_path}/bin/powermenu
sed -i -e 's/STYLE=.*/STYLE="launcher"/g' ${rofi_path}/bin/launcher
sed -i -e 's/STYLE=.*/STYLE="powermenu"/g' ${rofi_path}/bin/powermenu
sed -i -e "s/font:.*/font: \"$2\";/g" ${rofi_path}/"$1"/font.rasi
sed -i -e "s/font:.*/font: \"$2\";/g" ${rofi_path}/dialogs/askpass.rasi ${rofi_path}/dialogs/confirm.rasi
sed -i -e "s/border:.*/border: $3;/g" ${rofi_path}/dialogs/askpass.rasi ${rofi_path}/dialogs/confirm.rasi
sed -i -e "s/border-radius:.*/border-radius: $4;/g" ${rofi_path}/dialogs/askpass.rasi ${rofi_path}/dialogs/confirm.rasi
if [[ -f "$HOME"/.config/rofi/config.rasi ]]; then
sed -i -e "s/icon-theme:.*/icon-theme: \"$5\";/g" "$HOME"/.config/rofi/config.rasi
fi
cat > ${rofi_path}/dialogs/colors.rasi <<- _EOF_
/* Color-Scheme */
* {
BG: #282C33ff;
FG: #D8D8D8ff;
BDR: #62AEEFff;
}
_EOF_
}
# network manager ---------------------------
change_nm() {
sed -i -e "s#dmenu_command = .*#dmenu_command = rofi -dmenu -theme ~/.config/qtile/rofi/$1/networkmenu.rasi#g" "$HOME"/.config/networkmanager-dmenu/config.ini
}
# terminal ----------------------------------
change_terminal() {
sed -i -e "s/family: .*/family: \"$1\"/g" ${terminal_path}/fonts.yml
sed -i -e "s/size: .*/size: $2/g" ${terminal_path}/fonts.yml
cat > ${terminal_path}/colors.yml <<- _EOF_
## Colors configuration
colors:
# Default colors
primary:
background: '#1E2128'
foreground: '#ABB2BF'
# Normal colors
normal:
black: '#32363D'
red: '#E06B74'
green: '#98C379'
yellow: '#E5C07A'
blue: '#62AEEF'
magenta: '#C778DD'
cyan: '#55B6C2'
white: '#ABB2BF'
# Bright colors
bright:
black: '#50545B'
red: '#EA757E'
green: '#A2CD83'
yellow: '#EFCA84'
blue: '#6CB8F9'
magenta: '#D282E7'
cyan: '#5FC0CC'
white: '#B5BCC9'
_EOF_
}
# xfce terminal -----------------------------
change_xfce_terminal() {
sed -i -e "s/FontName=.*/FontName=$1/g" ${xfce_term_path}/terminalrc
sed -i -e 's/ColorForeground=.*/ColorForeground=#ababb2b2bfbf/g' ${xfce_term_path}/terminalrc
sed -i -e 's/ColorBackground=.*/ColorBackground=#1e1e21212828/g' ${xfce_term_path}/terminalrc
sed -i -e 's/ColorCursor=.*/ColorCursor=#ababb2b2bfbf/g' ${xfce_term_path}/terminalrc
sed -i -e 's/ColorPalette=.*/ColorPalette=#323236363d3d;#e0e06b6b7474;#9898c3c37979;#e5e5c0c07a7a;#6262aeaeefef;#c7c77878dddd;#5555b6b6c2c2;#ababb2b2bfbf;#505054545b5b;#eaea75757e7e;#a2a2cdcd8383;#efefcaca8484;#6c6cb8b8f9f9;#d2d28282e7e7;#5f5fc0c0cccc;#b5b5bcbcc9c9/g' ${xfce_term_path}/terminalrc
}
# geany -------------------------------------
change_geany() {
sed -i -e "s/color_scheme=.*/color_scheme=$1.conf/g" ${geany_path}/geany.conf
sed -i -e "s/editor_font=.*/editor_font=$2/g" ${geany_path}/geany.conf
}
# gtk theme, icons and fonts ----------------
change_appearance() {
xfconf-query -c xsettings -p /Net/ThemeName -s "$1"
xfconf-query -c xsettings -p /Net/IconThemeName -s "$2"
xfconf-query -c xsettings -p /Gtk/CursorThemeName -s "$3"
xfconf-query -c xsettings -p /Gtk/FontName -s "$4"
if [[ -f "$HOME"/.icons/default/index.theme ]]; then
sed -i -e "s/Inherits=.*/Inherits=$3/g" "$HOME"/.icons/default/index.theme
fi
}
# qtile -----------------------------------
obconfig () {
namespace="http://qtile.org/3.4/rc"
config="$qtile_path/rc.xml"
theme="$1"
layout="$2"
font="$3"
fontsize="$4"
# Theme
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:name' -v "$theme" "$config"
# Title
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:titleLayout' -v "$layout" "$config"
# Fonts
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveWindow"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveWindow"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveWindow"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveWindow"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveWindow"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveWindow"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveWindow"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveWindow"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuHeader"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuHeader"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuHeader"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuHeader"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuItem"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuItem"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuItem"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="MenuItem"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:weight' -v Bold "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="ActiveOnScreenDisplay"]/a:slant' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:name' -v "$font" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:size' -v "$fontsize" "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:weight' -v Normal "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:theme/a:font[@place="InactiveOnScreenDisplay"]/a:slant' -v Normal "$config"
# qtile Menu Style
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:menu/a:file' -v "$5" "$config"
# Margins
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:margins/a:top' -v 0 "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:margins/a:bottom' -v 10 "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:margins/a:left' -v 10 "$config"
xmlstarlet ed -L -N a="$namespace" -u '/a:qtile_config/a:margins/a:right' -v 10 "$config"
}
# dunst -------------------------------------
change_dunst() {
sed -i -e "s/geometry = .*/geometry = \"$1\"/g" ${dunst_path}/dunstrc
sed -i -e "s/font = .*/font = $2/g" ${dunst_path}/dunstrc
sed -i -e "s/frame_width = .*/frame_width = $3/g" ${dunst_path}/dunstrc
sed -i '/urgency_low/Q' ${dunst_path}/dunstrc
cat >> ${dunst_path}/dunstrc <<- _EOF_
[urgency_low]
timeout = 2
background = "#282C33"
foreground = "#D8D8D8"
frame_color = "#30343B"
[urgency_normal]
timeout = 5
background = "#282C33"
foreground = "#D8D8D8"
frame_color = "#30343B"
[urgency_critical]
timeout = 0
background = "#282C33"
foreground = "#E06B74"
frame_color = "#30343B"
_EOF_
pkill dunst && dunst &
}
# Plank -------------------------------------
change_dock() {
cat > "$HOME"/.cache/plank.conf <<- _EOF_
[dock1]
alignment='center'
auto-pinning=true
current-workspace-only=false
dock-items=['xfce-settings-manager.dockitem', 'Alacritty.dockitem', 'thunar.dockitem', 'firefox.dockitem', 'geany.dockitem']
hide-delay=0
hide-mode='intelligent'
icon-size=32
items-alignment='center'
lock-items=false
monitor=''
offset=0
pinned-only=false
position='bottom'
pressure-reveal=false
show-dock-item=false
theme='Transparent'
tooltips-enabled=true
unhide-delay=0
zoom-enabled=true
zoom-percent=120
_EOF_
}
# compositor --------------------------------
compositor() {
comp_file="$HOME/.config/picom.conf"
backend="$1"
cradius="$2"
shadow_r="$(echo $3 | cut -d' ' -f1)"
shadow_o="$(echo $3 | cut -d' ' -f2)"
shadow_x="$(echo $3 | cut -d' ' -f3)"
shadow_y="$(echo $3 | cut -d' ' -f4)"
method="$(echo $4 | cut -d' ' -f1)"
strength="$(echo $4 | cut -d' ' -f2)"
# Rounded Corners
sed -i -e "s/backend = .*/backend = \"$backend\";/g" ${comp_file}
sed -i -e "s/corner-radius = .*/corner-radius = $cradius;/g" ${comp_file}
# Shadows
sed -i -e "s/shadow-radius = .*/shadow-radius = $shadow_r;/g" ${comp_file}
sed -i -e "s/shadow-opacity = .*/shadow-opacity = $shadow_o;/g" ${comp_file}
sed -i -e "s/shadow-offset-x = .*/shadow-offset-x = $shadow_x;/g" ${comp_file}
sed -i -e "s/shadow-offset-y = .*/shadow-offset-y = $shadow_y;/g" ${comp_file}
# Blur
sed -i -e "s/backend = .*/backend = \"$backend\";/g" ${comp_file}
sed -i -e "s/method = .*/method = \"$method\";/g" ${comp_file}
sed -i -e "s/strength = .*/strength = $strength;/g" ${comp_file}
}
# notify ------------------------------------
notify_user() {
local style=`basename $0`
dunstify -u normal --replace=699 -i /usr/share/archcraft/icons/dunst/themes.png "Applying Style : ${style%.*}"
}
## Execute Script ---------------------------
notify_user
# funct WALLPAPER
set_wallpaper 'default.jpg'
# funct STYLE FONT
change_polybar 'default' 'JetBrains Mono:size=10;3' && "$polybar_path"/launch.sh
"$polybar_path"/launch.sh
# funct STYLE FONT BORDER BORDER-RADIUS ICON (Change colors in funct)
change_rofi 'default' 'Iosevka 10' '0px 0px 2px 0px' '8px' 'Zafiro'
# funct STYLE (network manager applet)
change_nm 'default'
# funct FONT SIZE (Change colors in funct)
change_terminal 'JetBrainsMono Nerd Font' '10'
# funct FONT (Change colors in funct)
change_xfce_terminal 'JetBrainsMono Nerd Font 10'
# funct SCHEME FONT
change_geany 'arc' 'JetBrains Mono 10'
# funct THEME ICON CURSOR FONT
change_appearance 'Arc-Dark' 'Zafiro' 'Qogirr' 'Noto Sans 9'
# funct THEME LAYOUT FONT SIZE (Change margin in funct)
# obconfig 'Arc-Dark' 'DLIMC' 'JetBrains Mono' '9' 'menu-icons.xml' && qtile --reconfigure
# funct GEOMETRY FONT BORDER (Change colors in funct)
change_dunst '280x50-10+48' 'JetBrains Mono 10' '6'
# Paste settings in funct (PLANK)
change_dock && cat "$HOME"/.cache/plank.conf | dconf load /net/launchpad/plank/docks/
# Change compositor settings
#compositor 'glx' '6' '14 0.30 -12 -12' 'none 0'