From 437dea9d5701022c56491d992758b9538c43395d Mon Sep 17 00:00:00 2001 From: Quentin Duchemin Date: Thu, 14 Nov 2019 19:06:44 +0100 Subject: [PATCH] Further polybar refactoring thanks to variables --- .config/polybar/config | 112 ++++++++++++++++++-------------- .config/polybar/config.d/desk | 41 ++---------- .config/polybar/config.d/laptop | 40 ++---------- .config/polybar/config_common | 40 +++++++++++- .init_config.sh | 3 + 5 files changed, 116 insertions(+), 120 deletions(-) diff --git a/.config/polybar/config b/.config/polybar/config index 75c712d..533ec74 100644 --- a/.config/polybar/config +++ b/.config/polybar/config @@ -9,6 +9,44 @@ accent = #fba922 [global/wm] margin-top=50 +; Common to top and bottom bars +[bar/common] +width = 100% +dpi = ${variables.dpi} +enable-ipc = true +height = ${variables.height} +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 = ${variables.top_left} +modules-center = ${variables.top_center} +modules-right = ${variables.top_right} + +tray-position = right + [bar/chostybottombar] inherit = bar/common bottom = true @@ -41,7 +79,7 @@ label-maxlen=100 [module/wireless-network] type = internal/network -interface = wlp8s0 +interface = ${variables.wireless_interface} interval = 1 label-connected = %{F#ddd}%essid%  %local_ip% %{F#77dd77}%{F-}%downspeed% %{F#dd7777}%{F-}%upspeed% label-disconnected = Ethernet disconnected @@ -222,58 +260,21 @@ 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 +[variables] +dpi = 150 +height = 54 +wireless_interface = wlp2s0 +top_left = powermenu system-uptime-pretty battery +top_center = xwindow +top_right = system-usb-udev pulseaudio date -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 +[module/pulseaudio] +type = internal/pulseaudio +interval = 5 format-volume = label-muted = 🔇 muted -label-muted-foreground = #66 +label-muted-foreground = #666 ramp-volume-0 = 🔈 ramp-volume-1 = 🔉 @@ -281,3 +282,16 @@ 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.d/desk b/.config/polybar/config.d/desk index 8823f20..80dd8c9 100644 --- a/.config/polybar/config.d/desk +++ b/.config/polybar/config.d/desk @@ -1,39 +1,10 @@ -; Common to top and bottom bars -[bar/common] -width = 100% -enable-ipc = true +[variables] +dpi = 100 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 +wireless_interface = wlp8s0 +top_left = powermenu system-uptime-pretty +top_center = xwindow +top_right = system-usb-udev volume date [module/volume] type = internal/volume diff --git a/.config/polybar/config.d/laptop b/.config/polybar/config.d/laptop index 84cb8e8..9e36aae 100644 --- a/.config/polybar/config.d/laptop +++ b/.config/polybar/config.d/laptop @@ -1,40 +1,10 @@ -; Common to top and bottom bars -[bar/common] +[variables] 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 +wireless_interface = wlp2s0 +top_left = powermenu system-uptime-pretty battery +top_center = xwindow +top_right = system-usb-udev pulseaudio date [module/pulseaudio] type = internal/pulseaudio diff --git a/.config/polybar/config_common b/.config/polybar/config_common index eb64951..824dea5 100644 --- a/.config/polybar/config_common +++ b/.config/polybar/config_common @@ -9,6 +9,44 @@ accent = #fba922 [global/wm] margin-top=50 +; Common to top and bottom bars +[bar/common] +width = 100% +dpi = ${variables.dpi} +enable-ipc = true +height = ${variables.height} +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 = ${variables.top_left} +modules-center = ${variables.top_center} +modules-right = ${variables.top_right} + +tray-position = right + [bar/chostybottombar] inherit = bar/common bottom = true @@ -41,7 +79,7 @@ label-maxlen=100 [module/wireless-network] type = internal/network -interface = wlp8s0 +interface = ${variables.wireless_interface} interval = 1 label-connected = %{F#ddd}%essid%  %local_ip% %{F#77dd77}%{F-}%downspeed% %{F#dd7777}%{F-}%upspeed% label-disconnected = Ethernet disconnected diff --git a/.init_config.sh b/.init_config.sh index 4170c3a..9f172df 100755 --- a/.init_config.sh +++ b/.init_config.sh @@ -78,3 +78,6 @@ for m in $merge_config; do cat "${f}" >> ${CONFIG}/${m}/config done done + +# Reload i3 configuration +i3-msg reload && echo "Successfully reloaded i3 config"