From ad9b1ea45ae2bd60b2b12bfbb0bcdbca28fd1dfa Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Thu, 14 Nov 2019 16:09:40 +0100 Subject: [PATCH] Add polybar config file merging tool --- .config/i3/config_common | 2 +- .config/polybar/{config.desk => config} | 171 +++++++----------- .config/polybar/config.d/desk | 59 ++++++ .config/polybar/config.d/laptop | 65 +++++++ .../polybar/{config.laptop => config_common} | 112 +----------- .init_config.sh | 13 +- 6 files changed, 201 insertions(+), 221 deletions(-) rename .config/polybar/{config.desk => config} (83%) create mode 100644 .config/polybar/config.d/desk create mode 100644 .config/polybar/config.d/laptop rename .config/polybar/{config.laptop => config_common} (66%) diff --git a/.config/i3/config_common b/.config/i3/config_common index 4c5ee12..64ecd46 100644 --- a/.config/i3/config_common +++ b/.config/i3/config_common @@ -37,7 +37,7 @@ smart_gaps on exec --no-startup-id compton #start polybar -exec --no-startup-id $HOME/.config/polybar/scripts/launch_polybar.sh +exec_always --no-startup-id $HOME/.config/polybar/scripts/launch_polybar.sh # configure keyboard layout exec setxkbmap fr diff --git a/.config/polybar/config.desk b/.config/polybar/config similarity index 83% rename from .config/polybar/config.desk rename to .config/polybar/config index ae338b9..75c712d 100644 --- a/.config/polybar/config.desk +++ b/.config/polybar/config @@ -1,12 +1,3 @@ -;===================================================== -; -; To learn more about how to configure Polybar -; go to https://github.com/jaagr/polybar -; -; The README contains alot of information -; -;===================================================== - [colors] background = #bb2f343f foreground = #eee @@ -18,43 +9,6 @@ accent = #fba922 [global/wm] margin-top=50 -; Common to top and bottom bars -[bar/common] -width = 100% -enable-ipc = true -height = 27 -foreground = ${colors.foreground} -background = ${colors.background} -line-size = 3 -line-color = #f00 - -locale = fr_FR.UTF-8 -monitor = ${env:MONITOR:HDMI-0} - -[bar/chostytopbar] -inherit = bar/common -font-0 = NotoSans-Regular:size=10;2 -font-1 = MaterialIcons-Regular:size=11;4 -font-2 = Symbola:size=10;2 -font-3 = Weather Icons:size=10;3 - -overline-size = 10 -underline-size = 10 -overline-color = ${self.background} -underline-color = ${self.background} -border-bottom-size = 1 -border-bottom-color = #333 -padding-left = 2 -padding-right = 10 -module-margin-left = 4 -module-margin-right = 4 - -modules-left = powermenu system-uptime-pretty -modules-center = xwindow -modules-right = system-usb-udev volume date - -tray-position = right - [bar/chostybottombar] inherit = bar/common bottom = true @@ -77,31 +31,8 @@ font-3 = MaterialIcons-Regular:size=11;4 font-4 = Font Awesome 5 Free:style=solid:size=10;2 modules-left = i3 -;modules-center = -modules-right = wireless-network wired-network updates-arch-combined temperature cpu memory filesystem-custom - -[module/volume] -type = internal/volume - -master-soundcard = hw:PCH -speaker-soundcard = hw:PCH -headphone-soundcard = hw:PCH - -master-mixer = Master -speaker-mixer = Front - -mapped = true - -format-volume = -label-muted = ๐Ÿ”‡ muted -label-muted-foreground = #66 - -ramp-volume-0 = ๐Ÿ”ˆ -ramp-volume-1 = ๐Ÿ”‰ -ramp-volume-2 = ๐Ÿ”Š - -ramp-headphones-0 = ๏€ฅ -ramp-headphones-1 = ๏€ฅ +;modules-center = +modules-right = wireless-network updates-arch-combined temperature cpu memory filesystem-custom [module/xwindow] type = internal/xwindow @@ -154,36 +85,6 @@ label-visible-foreground = #55ffffff label-visible-font = 0 label-visible-padding = 4 -[module/xkeyboard] -type = internal/xkeyboard -blacklist-0 = num lock - -format-prefix = "๎‰ฏ " -format-prefix-foreground = ${colors.foreground-alt} -format-prefix-underline = ${colors.secondary} - -label-layout = %layout% -label-layout-underline = ${colors.secondary} - -label-indicator-padding = 2 -label-indicator-margin = 1 -label-indicator-background = ${colors.secondary} -label-indicator-underline = ${colors.secondary} - -[module/filesystem] -type = internal/fs -interval = 25 - -mount-0 = / -mount-1 = /mnt/data -mount-2 = /mnt/backup - -label-mounted = %{F#0a81f5}%mountpoint%%{F-} ยท %percentage_used%% ยท%{F#555} %free% free -label-unmounted = %mountpoint% not mounted -label-unmounted-foreground = ${colors.foreground-alt} - -spacing = 4 - [module/cpu] type = internal/cpu interval = 0.5 @@ -230,7 +131,7 @@ bar-used-foreground-0 = #55aa55 bar-used-foreground-1 = #557755 bar-used-foreground-2 = #f5a70a bar-used-foreground-3 = #ff5555 -bar-used-indicator = +bar-used-indicator = bar-used-indicator-font = 2 bar-used-indicator-foreground = #fff bar-used-fill =โ– @@ -262,9 +163,9 @@ label = %{F#77dd77}๎€€ %{F-} %temperature-c% label-warn = %{F#dd7777}๎€€ %{F-} %temperature-c% label-warn-foreground = #dd7777 -ramp-0 = -ramp-1 = -ramp-2 = +ramp-0 = +ramp-1 = +ramp-2 = ramp-foreground = ${colors.foreground-alt} [module/powermenu] @@ -300,7 +201,6 @@ menu-2-1 = Power off menu-2-1-foreground = ${colors.accent} menu-2-1-exec = systemctl poweroff - [module/system-usb-udev] type = custom/script exec = ~/.config/polybar/scripts/system-usb-udev.sh @@ -322,3 +222,62 @@ interval = 60 type = custom/script exec = ~/.config/polybar/scripts/system-uptime-pretty.sh interval = 30 +; Common to top and bottom bars +[bar/common] +width = 100% +enable-ipc = true +height = 27 +foreground = ${colors.foreground} +background = ${colors.background} +line-size = 3 +line-color = #f00 + +locale = fr_FR.UTF-8 +monitor = ${env:MONITOR:HDMI-0} + +[bar/chostytopbar] +inherit = bar/common +font-0 = NotoSans-Regular:size=10;2 +font-1 = MaterialIcons-Regular:size=11;4 +font-2 = Symbola:size=10;2 +font-3 = Weather Icons:size=10;3 + +overline-size = 10 +underline-size = 10 +overline-color = ${self.background} +underline-color = ${self.background} +border-bottom-size = 1 +border-bottom-color = #333 +padding-left = 2 +padding-right = 10 +module-margin-left = 4 +module-margin-right = 4 + +modules-left = powermenu system-uptime-pretty +modules-center = xwindow +modules-right = system-usb-udev volume date + +tray-position = right + +[module/volume] +type = internal/volume + +master-soundcard = hw:PCH +speaker-soundcard = hw:PCH +headphone-soundcard = hw:PCH + +master-mixer = Master +speaker-mixer = Front + +mapped = true + +format-volume = +label-muted = ๐Ÿ”‡ muted +label-muted-foreground = #66 + +ramp-volume-0 = ๐Ÿ”ˆ +ramp-volume-1 = ๐Ÿ”‰ +ramp-volume-2 = ๐Ÿ”Š + +ramp-headphones-0 = ๏€ฅ +ramp-headphones-1 = ๏€ฅ diff --git a/.config/polybar/config.d/desk b/.config/polybar/config.d/desk new file mode 100644 index 0000000..8823f20 --- /dev/null +++ b/.config/polybar/config.d/desk @@ -0,0 +1,59 @@ +; Common to top and bottom bars +[bar/common] +width = 100% +enable-ipc = true +height = 27 +foreground = ${colors.foreground} +background = ${colors.background} +line-size = 3 +line-color = #f00 + +locale = fr_FR.UTF-8 +monitor = ${env:MONITOR:HDMI-0} + +[bar/chostytopbar] +inherit = bar/common +font-0 = NotoSans-Regular:size=10;2 +font-1 = MaterialIcons-Regular:size=11;4 +font-2 = Symbola:size=10;2 +font-3 = Weather Icons:size=10;3 + +overline-size = 10 +underline-size = 10 +overline-color = ${self.background} +underline-color = ${self.background} +border-bottom-size = 1 +border-bottom-color = #333 +padding-left = 2 +padding-right = 10 +module-margin-left = 4 +module-margin-right = 4 + +modules-left = powermenu system-uptime-pretty +modules-center = xwindow +modules-right = system-usb-udev volume date + +tray-position = right + +[module/volume] +type = internal/volume + +master-soundcard = hw:PCH +speaker-soundcard = hw:PCH +headphone-soundcard = hw:PCH + +master-mixer = Master +speaker-mixer = Front + +mapped = true + +format-volume = +label-muted = ๐Ÿ”‡ muted +label-muted-foreground = #66 + +ramp-volume-0 = ๐Ÿ”ˆ +ramp-volume-1 = ๐Ÿ”‰ +ramp-volume-2 = ๐Ÿ”Š + +ramp-headphones-0 = ๏€ฅ +ramp-headphones-1 = ๏€ฅ diff --git a/.config/polybar/config.d/laptop b/.config/polybar/config.d/laptop new file mode 100644 index 0000000..84cb8e8 --- /dev/null +++ b/.config/polybar/config.d/laptop @@ -0,0 +1,65 @@ +; Common to top and bottom bars +[bar/common] +dpi = 150 +width = 100% +enable-ipc = true +height = 54 +foreground = ${colors.foreground} +background = ${colors.background} +line-size = 3 +line-color = #f00 + +locale = fr_FR.UTF-8 +monitor = ${env:MONITOR:HDMI-0} + +[bar/chostytopbar] +inherit = bar/common +font-0 = NotoSans-Regular:size=10;2 +font-1 = MaterialIcons-Regular:size=11;4 +font-2 = Symbola:size=11;2 +font-3 = Weather Icons:size=10;3 + +overline-size = 10 +underline-size = 10 +overline-color = ${self.background} +underline-color = ${self.background} +border-bottom-size = 1 +border-bottom-color = #333 +padding-left = 2 +padding-right = 10 +module-margin-left = 4 +module-margin-right = 4 + +modules-left = powermenu system-uptime-pretty battery +modules-center = xwindow +modules-right = system-usb-udev pulseaudio date + +tray-position = right + +[module/pulseaudio] +type = internal/pulseaudio +interval = 5 + +format-volume = +label-muted = ๐Ÿ”‡ muted +label-muted-foreground = #666 + +ramp-volume-0 = ๐Ÿ”ˆ +ramp-volume-1 = ๐Ÿ”‰ +ramp-volume-2 = ๐Ÿ”Š + +ramp-headphones-0 = ๏€ฅ +ramp-headphones-1 = ๏€ฅ + +[module/battery] +type = internal/battery +full-at = 100 +battery = BAT0 +adapter = AC0 +poll-interval = 5 +format-charging = +format-discharging = +format-full = +label-charging = ๎†ฃ %percentage%% +label-discharging = ๎†ค %percentage%% +label-full = %{F#77dd77}๎†ค diff --git a/.config/polybar/config.laptop b/.config/polybar/config_common similarity index 66% rename from .config/polybar/config.laptop rename to .config/polybar/config_common index a5b344c..eb64951 100644 --- a/.config/polybar/config.laptop +++ b/.config/polybar/config_common @@ -1,12 +1,3 @@ -;===================================================== -; -; To learn more about how to configure Polybar -; go to https://github.com/jaagr/polybar -; -; The README contains alot of information -; -;===================================================== - [colors] background = #bb2f343f foreground = #eee @@ -18,44 +9,6 @@ accent = #fba922 [global/wm] margin-top=50 -; Common to top and bottom bars -[bar/common] -dpi = 150 -width = 100% -enable-ipc = true -height = 54 -foreground = ${colors.foreground} -background = ${colors.background} -line-size = 3 -line-color = #f00 - -locale = en_US.UTF-8 -monitor = ${env:MONITOR:HDMI-0} - -[bar/chostytopbar] -inherit = bar/common -font-0 = NotoSans-Regular:size=10;2 -font-1 = MaterialIcons-Regular:size=11;4 -font-2 = Symbola:size=11;2 -font-3 = Weather Icons:size=10;3 - -overline-size = 10 -underline-size = 10 -overline-color = ${self.background} -underline-color = ${self.background} -border-bottom-size = 1 -border-bottom-color = #333 -padding-left = 2 -padding-right = 10 -module-margin-left = 4 -module-margin-right = 4 - -modules-left = powermenu system-uptime-pretty battery -modules-center = xwindow -modules-right = system-usb-udev pulseaudio date - -tray-position = right - [bar/chostybottombar] inherit = bar/common bottom = true @@ -79,35 +32,7 @@ font-4 = Font Awesome 5 Free:style=solid:size=10;2 modules-left = i3 ;modules-center = -modules-right = wireless-network wired-network updates-arch-combined temperature cpu memory filesystem-custom - -[module/pulseaudio] -type = internal/pulseaudio -interval = 5 - -format-volume = -label-muted = ๐Ÿ”‡ muted -label-muted-foreground = #666 - -ramp-volume-0 = ๐Ÿ”ˆ -ramp-volume-1 = ๐Ÿ”‰ -ramp-volume-2 = ๐Ÿ”Š - -ramp-headphones-0 = ๏€ฅ -ramp-headphones-1 = ๏€ฅ - -[module/battery] -type = internal/battery -full-at = 100 -battery = BAT0 -adapter = AC0 -poll-interval = 5 -format-charging = -format-discharging = -format-full = -label-charging = ๎†ฃ %percentage%% -label-discharging = ๎†ค %percentage%% -label-full = %{F#77dd77}๎†ค +modules-right = wireless-network updates-arch-combined temperature cpu memory filesystem-custom [module/xwindow] type = internal/xwindow @@ -116,7 +41,7 @@ label-maxlen=100 [module/wireless-network] type = internal/network -interface = wlp2s0 +interface = wlp8s0 interval = 1 label-connected = %{F#ddd}%essid% ๎• %local_ip% %{F#77dd77}๎‹„%{F-}%downspeed% %{F#dd7777}๎‹†%{F-}%upspeed% label-disconnected = Ethernet disconnected @@ -135,7 +60,7 @@ ws-icon-3 = 4;๎‰ ws-icon-4 = 5;๎˜ฏ label-dimmed-underline = ${root.background} - +label-separator = | label-focused = %icon% %name% label-focused-foreground = #f3f3f3 ;label-focused-underline = #${colors.accent} @@ -160,36 +85,6 @@ label-visible-foreground = #55ffffff label-visible-font = 0 label-visible-padding = 4 -[module/xkeyboard] -type = internal/xkeyboard -blacklist-0 = num lock - -format-prefix = "๎‰ฏ " -format-prefix-foreground = ${colors.foreground-alt} -format-prefix-underline = ${colors.secondary} - -label-layout = %layout% -label-layout-underline = ${colors.secondary} - -label-indicator-padding = 2 -label-indicator-margin = 1 -label-indicator-background = ${colors.secondary} -label-indicator-underline = ${colors.secondary} - -[module/filesystem] -type = internal/fs -interval = 25 - -mount-0 = / -mount-1 = /mnt/data -mount-2 = /mnt/backup - -label-mounted = %{F#0a81f5}%mountpoint%%{F-} ยท %percentage_used%% ยท%{F#555} %free% free -label-unmounted = %mountpoint% not mounted -label-unmounted-foreground = ${colors.foreground-alt} - -spacing = 4 - [module/cpu] type = internal/cpu interval = 0.5 @@ -306,7 +201,6 @@ menu-2-1 = Power off menu-2-1-foreground = ${colors.accent} menu-2-1-exec = systemctl poweroff - [module/system-usb-udev] type = custom/script exec = ~/.config/polybar/scripts/system-usb-udev.sh diff --git a/.init_config.sh b/.init_config.sh index 751c0d9..4170c3a 100755 --- a/.init_config.sh +++ b/.init_config.sh @@ -69,9 +69,12 @@ for f in `find ${CONFIG} -type f -name ${DEST_FILENAME}`; do done done -echo -e "\n=== Generate i3 config file ===" -cp ${CONFIG}/i3/config_common ${CONFIG}/i3/config -for f in `find ${CONFIG}/i3/config.d -type f -name "${1}"`; do - echo "Found ${f}, add to regular config file" - cat "${f}" >> ${CONFIG}/i3/config +merge_config="polybar i3" +for m in $merge_config; do + echo -e "\n=== Generate ${m} config file ===" + cp ${CONFIG}/${m}/config_common ${CONFIG}/${m}/config + for f in `find ${CONFIG}/${m}/config.d -type f -name "${1}"`; do + echo "Found ${f}, add to regular config file" + cat "${f}" >> ${CONFIG}/${m}/config + done done