feat(polybar): restructure

This commit is contained in:
Pavel Korytov 2021-11-23 18:24:51 +03:00
parent b85731122c
commit f31ada645d
3 changed files with 86 additions and 78 deletions

View file

@ -28,17 +28,17 @@ gright = 
; Glyphs:1 ends here ; Glyphs:1 ends here
; [[file:../../Desktop.org::*Modules][Modules:4]] ; [[file:../../Desktop.org::*Modules][Modules:4]]
[module/glyph-light-blue--green] [module/glyph-green--light-yellow]
type = custom/text type = custom/text
content-background = ${colors.light-blue} content-background = ${colors.green}
content-foreground = ${colors.green} content-foreground = ${colors.light-yellow}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-red--light-blue] [module/glyph-red--green]
type = custom/text type = custom/text
content-background = ${colors.red} content-background = ${colors.red}
content-foreground = ${colors.light-blue} content-foreground = ${colors.green}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
@ -56,59 +56,59 @@ content-foreground = ${colors.light-blue}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-green--yellow] [module/glyph-light-yellow--yellow]
type = custom/text type = custom/text
content-background = ${colors.green} content-background = ${colors.light-yellow}
content-foreground = ${colors.yellow} content-foreground = ${colors.yellow}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-red--green] [module/glyph-red--light-yellow]
type = custom/text type = custom/text
content-background = ${colors.red} content-background = ${colors.red}
content-foreground = ${colors.green} content-foreground = ${colors.light-yellow}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-green--red] [module/glyph-light-red--red]
type = custom/text type = custom/text
content-background = ${colors.green} content-background = ${colors.light-red}
content-foreground = ${colors.red} content-foreground = ${colors.red}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-yellow--green] [module/glyph-green--light-red]
type = custom/text type = custom/text
content-background = ${colors.yellow} content-background = ${colors.green}
content-foreground = ${colors.light-red}
content = ${glyph.gright}
content-font = 5
[module/glyph-light-green--green]
type = custom/text
content-background = ${colors.light-green}
content-foreground = ${colors.green} content-foreground = ${colors.green}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-blue--yellow] [module/glyph-cyan--light-green]
type = custom/text type = custom/text
content-background = ${colors.blue} content-background = ${colors.cyan}
content-foreground = ${colors.yellow}
content = ${glyph.gright}
content-font = 5
[module/glyph-light-green--blue]
type = custom/text
content-background = ${colors.light-green}
content-foreground = ${colors.blue}
content = ${glyph.gright}
content-font = 5
[module/glyph-yellow--light-green]
type = custom/text
content-background = ${colors.yellow}
content-foreground = ${colors.light-green} content-foreground = ${colors.light-green}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-white--yellow] [module/glyph-magenta--cyan]
type = custom/text type = custom/text
content-background = ${colors.white} content-background = ${colors.magenta}
content-foreground = ${colors.yellow} content-foreground = ${colors.cyan}
content = ${glyph.gright}
content-font = 5
[module/glyph-light-magenta--magenta]
type = custom/text
content-background = ${colors.light-magenta}
content-foreground = ${colors.magenta}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
@ -119,6 +119,13 @@ content-foreground = ${colors.background}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-background--light-magenta]
type = custom/text
content-background = ${colors.background}
content-foreground = ${colors.light-magenta}
content = ${glyph.gright}
content-font = 5
[module/glyph-background--white] [module/glyph-background--white]
type = custom/text type = custom/text
content-background = ${colors.background} content-background = ${colors.background}
@ -164,10 +171,10 @@ radius = 0.0
; font-2 = ${env:FONT2:fontawesome:pixelsize=10;1} ; font-2 = ${env:FONT2:fontawesome:pixelsize=10;1}
; font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1} ; font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1}
font-0 = pango:monospace:size=13;1 font-0 = pango:monospace:size=13;2
font-1 = NotoEmoji:scale=10:antialias=false;0 font-1 = NotoEmoji:scale=10:antialias=false;1
font-2 = fontawesome:pixelsize=13;2 font-2 = fontawesome:pixelsize=13;3
font-3 = JetBrains Mono Nerd Font:monospace:size=13;3 font-3 = JetBrains Mono Nerd Font:monospace:size=13;4
font-4 = JetBrains Mono Nerd Font:monospace:size=17;4 font-4 = JetBrains Mono Nerd Font:monospace:size=17;4
; Global bar config:3 ends here ; Global bar config:3 ends here
@ -242,8 +249,8 @@ ramp-volume-7 = █
format-muted = ♪ <label-muted> format-muted = ♪ <label-muted>
label-muted = MUTE label-muted = MUTE
format-volume-background = ${colors.white} format-volume-background = ${colors.light-magenta}
format-muted-background = ${colors.white} format-muted-background = ${colors.light-magenta}
; format-volume-underline = ${colors.white} ; format-volume-underline = ${colors.white}
; format-muted-underline = ${colors.light-black} ; format-muted-underline = ${colors.light-black}
@ -266,9 +273,9 @@ label-song-ellipsis = true
; format-paused-underline = ${colors.yellow} ; format-paused-underline = ${colors.yellow}
; format-stopped-underline = ${colors.yellow} ; format-stopped-underline = ${colors.yellow}
format-playing-background = ${colors.yellow} format-playing-background = ${colors.magenta}
format-paused-background = ${colors.yellow} format-paused-background = ${colors.magenta}
format-stopped-background = ${colors.yellow} format-stopped-background = ${colors.magenta}
label-separator = 0 label-separator = 0
separator-foreground = ${colors.red} separator-foreground = ${colors.red}
@ -285,7 +292,7 @@ icon-next = 2
type = internal/cpu type = internal/cpu
format = " <label>" format = " <label>"
label = %percentage%% label = %percentage%%
format-background = ${colors.light-green} format-background = ${colors.cyan}
; cpu:1 ends here ; cpu:1 ends here
; [[file:../../Desktop.org::*ram-memory][ram-memory:1]] ; [[file:../../Desktop.org::*ram-memory][ram-memory:1]]
@ -306,7 +313,7 @@ format =  <label>
label=%gb_used:.1f% label=%gb_used:.1f%
; format-underline = ${colors.blue} ; format-underline = ${colors.blue}
format-background = ${colors.blue} format-background = ${colors.light-green}
; ram-memory:1 ends here ; ram-memory:1 ends here
; [[file:../../Desktop.org::*swap-memory][swap-memory:1]] ; [[file:../../Desktop.org::*swap-memory][swap-memory:1]]
@ -315,7 +322,7 @@ type = internal/memory
interval = 10 interval = 10
label= %gb_swap_used:.1f% label= %gb_swap_used:.1f%
format-background = ${colors.yellow} format-background = ${colors.green}
; swap-memory:1 ends here ; swap-memory:1 ends here
; [[file:../../Desktop.org::*network][network:1]] ; [[file:../../Desktop.org::*network][network:1]]
@ -332,8 +339,8 @@ label-disconnected = X
; format-connected-underline = ${colors.green} ; format-connected-underline = ${colors.green}
; format-disconnected-underline = ${colors.red} ; format-disconnected-underline = ${colors.red}
format-connected-background = ${colors.green} format-connected-background = ${colors.light-red}
format-disconnected-background = ${colors.green} format-disconnected-background = ${colors.light-red}
ramp-signal-0 = 0 ramp-signal-0 = 0
ramp-signal-1 = 1 ramp-signal-1 = 1
@ -354,7 +361,7 @@ interval = 1200
[module/openvpn] [module/openvpn]
type = custom/script type = custom/script
exec = /home/pavel/bin/polybar/openvpn.sh exec = /home/pavel/bin/polybar/openvpn.sh
format-background = ${colors.green} format-background = ${colors.light-red}
interval = 1200 interval = 1200
; openvpn:2 ends here ; openvpn:2 ends here
@ -378,9 +385,9 @@ adapter = ADP0
time-format = %H:%M time-format = %H:%M
format-discharging = <ramp-capacity> <label-discharging> format-discharging = <ramp-capacity> <label-discharging>
format-discharging-background = ${colors.light-blue} format-discharging-background = ${colors.green}
format-charging-background = ${colors.light-blue} format-charging-background = ${colors.green}
format-full-background = ${colors.light-blue} format-full-background = ${colors.green}
label-discharging = %percentage%% %time% label-discharging = %percentage%% %time%
label-charging =  %percentage%% %time% label-charging =  %percentage%% %time%
@ -396,7 +403,7 @@ ramp-capacity-4 = 
type = custom/script type = custom/script
exec = /home/pavel/bin/polybar/weather.sh exec = /home/pavel/bin/polybar/weather.sh
; format-underline = ${colors.red} ; format-underline = ${colors.red}
format-background = ${colors.green} format-background = ${colors.light-yellow}
interval = 1200 interval = 1200
; weather:2 ends here ; weather:2 ends here

View file

@ -1365,21 +1365,21 @@ To make life a bit easier, I'll define a single source of truth for modules and
So, here is a table with all modules. So, here is a table with all modules.
#+NAME: polybar_modules #+NAME: polybar_modules
| Index | Module | Color | Glyph | | Index | Module | Color | Glyph |
|-------+-------------+-------------+-------| |-------+-------------+---------------+-------|
| 1 | pulseaudio | white | + | | 1 | pulseaudio | light-magenta | + |
| 2 | mpd | yellow | + | | 2 | mpd | magenta | + |
| 3 | cpu | light-green | + | | 3 | cpu | cyan | + |
| 4 | ram-memory | blue | + | | 4 | ram-memory | light-green | + |
| 5 | swap-memory | yellow | + | | 5 | swap-memory | green | + |
| 6 | network | green | + | | 6 | network | light-red | + |
| 7 | openvpn | green | | | 7 | openvpn | light-red | |
| 8 | xkeyboard | red | + | | 8 | xkeyboard | red | + |
| 9 | battery | light-blue | + | | 9 | battery | green | + |
| 10 | weather | green | + | | 10 | weather | light-yellow | + |
| 12 | sun | yellow | + | | 12 | sun | yellow | + |
| 13 | aw-afk | light-blue | + | | 13 | aw-afk | light-blue | + |
| 14 | date | blue | + | | 14 | date | blue | + |
Some functions to use colors in the individual modules: Some functions to use colors in the individual modules:
#+NAME: get-polybar-bg #+NAME: get-polybar-bg
@ -1408,10 +1408,11 @@ Also, I want to exclude some modules from certain monitors and machines. For now
Now, we need to generate a set of glyphs. The code below generates all the required glyhps so that every combination of neighoring colors in the bar had one. Now, we need to generate a set of glyphs. The code below generates all the required glyhps so that every combination of neighoring colors in the bar had one.
#+NAME: polybar_extra_colors #+NAME: polybar_extra_colors
| Color 1 | Color 2 | | Color 1 | Color 2 |
|------------+------------| |------------+---------------|
| background | white | | background | white |
| blue | background | | background | light-magenta |
| blue | background |
#+NAME: polybar-generate-glyphs #+NAME: polybar-generate-glyphs
#+begin_src emacs-lisp :var table=polybar_modules exclude-table=polybar_modules_exclude extra=polybar_extra_colors #+begin_src emacs-lisp :var table=polybar_modules exclude-table=polybar_modules_exclude extra=polybar_extra_colors
@ -1554,10 +1555,10 @@ Fonts
; font-2 = ${env:FONT2:fontawesome:pixelsize=10;1} ; font-2 = ${env:FONT2:fontawesome:pixelsize=10;1}
; font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1} ; font-3 = ${env:FONT3:JetBrains Mono Nerd Font:monospace:size=10;1}
font-0 = pango:monospace:size=13;1 font-0 = pango:monospace:size=13;2
font-1 = NotoEmoji:scale=10:antialias=false;0 font-1 = NotoEmoji:scale=10:antialias=false;1
font-2 = fontawesome:pixelsize=13;2 font-2 = fontawesome:pixelsize=13;3
font-3 = JetBrains Mono Nerd Font:monospace:size=13;3 font-3 = JetBrains Mono Nerd Font:monospace:size=13;4
font-4 = JetBrains Mono Nerd Font:monospace:size=17;4 font-4 = JetBrains Mono Nerd Font:monospace:size=17;4
#+end_src #+end_src

View file

@ -34,10 +34,10 @@ declare -A BAR_HEIGHT=(
["HDMI-A-0"]="29" ["HDMI-A-0"]="29"
) )
declare -A BLOCKS=( declare -A BLOCKS=(
["eDP"]="glyph-background--white pulseaudio glyph-white--yellow mpd glyph-yellow--light-green cpu glyph-light-green--blue ram-memory glyph-blue--yellow swap-memory glyph-yellow--green network openvpn glyph-green--red xkeyboard glyph-red--light-blue battery glyph-light-blue--green weather glyph-green--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background " ["eDP"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red network openvpn glyph-light-red--red xkeyboard glyph-red--green battery glyph-green--light-yellow weather glyph-light-yellow--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background "
["eDP-1"]="glyph-background--white pulseaudio glyph-white--yellow mpd glyph-yellow--light-green cpu glyph-light-green--blue ram-memory glyph-blue--yellow swap-memory glyph-yellow--green network openvpn glyph-green--red xkeyboard glyph-red--light-blue battery glyph-light-blue--green weather glyph-green--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background " ["eDP-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red network openvpn glyph-light-red--red xkeyboard glyph-red--green battery glyph-green--light-yellow weather glyph-light-yellow--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background "
["DVI-D-0"]="glyph-background--white pulseaudio glyph-white--yellow mpd glyph-yellow--light-green cpu glyph-light-green--blue ram-memory glyph-blue--yellow swap-memory glyph-yellow--green network openvpn glyph-green--red xkeyboard glyph-red--green weather glyph-green--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background " ["DVI-D-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red network openvpn glyph-light-red--red xkeyboard glyph-red--light-yellow weather glyph-light-yellow--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background "
["HDMI-A-0"]="glyph-background--white pulseaudio glyph-white--yellow mpd glyph-yellow--light-green cpu glyph-light-green--blue ram-memory glyph-blue--yellow swap-memory glyph-yellow--green network openvpn glyph-green--red xkeyboard glyph-red--green weather glyph-green--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background " ["HDMI-A-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red network openvpn glyph-light-red--red xkeyboard glyph-red--light-yellow weather glyph-light-yellow--yellow sun glyph-yellow--light-blue aw-afk glyph-light-blue--blue date glyph-blue--background "
) )
# Geolocation for some modules # Geolocation for some modules