polybar: add nvidia

This commit is contained in:
Pavel Korytov 2024-01-25 20:35:02 +03:00
parent 23e102db15
commit d36329b316
3 changed files with 108 additions and 37 deletions

View file

@ -2,20 +2,28 @@
[colors] [colors]
black = #222222 black = #222222
light-black = #303030 light-black = #303030
dark-black = #131313
red = #e28b8b red = #e28b8b
light-red = #f69d9d light-red = #f69d9d
dark-red = #cd7879
green = #31ba54 green = #31ba54
light-green = #4acd65 light-green = #4acd65
dark-green = #09a642
yellow = #e49300 yellow = #e49300
light-yellow = #faa522 light-yellow = #faa522
dark-yellow = #ce8000
blue = #8f9fe3 blue = #8f9fe3
light-blue = #a2b1f7 light-blue = #a2b1f7
dark-blue = #7b8ccf
magenta = #db81cf magenta = #db81cf
light-magenta = #ef93e2 light-magenta = #ef93e2
dark-magenta = #c66ebb
cyan = #66a7e4 cyan = #66a7e4
light-cyan = #7ab9f8 light-cyan = #7ab9f8
dark-cyan = #5094d0
white = #fff8f0 white = #fff8f0
light-white = #fffef6 light-white = #fffef6
dark-white = #eae3dc
background = #c7c0ba background = #c7c0ba
foreground = #000000 foreground = #000000
; Colors:2 ends here ; Colors:2 ends here
@ -27,9 +35,16 @@ gright = 
; Glyph settings:1 ends here ; Glyph settings:1 ends here
; [[file:../../Desktop.org::*Generating glyphs][Generating glyphs:3]] ; [[file:../../Desktop.org::*Generating glyphs][Generating glyphs:3]]
[module/glyph-light-cyan--light-cyan] [module/glyph-light-cyan--cyan]
type = custom/text type = custom/text
content-background = ${colors.light-cyan} content-background = ${colors.light-cyan}
content-foreground = ${colors.cyan}
content = ${glyph.gright}
content-font = 5
[module/glyph-magenta--light-cyan]
type = custom/text
content-background = ${colors.magenta}
content-foreground = ${colors.light-cyan} content-foreground = ${colors.light-cyan}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
@ -90,17 +105,17 @@ content-foreground = ${colors.light-green}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-light-cyan--cyan] [module/glyph-cyan--cyan]
type = custom/text type = custom/text
content-background = ${colors.light-cyan} content-background = ${colors.cyan}
content-foreground = ${colors.cyan} content-foreground = ${colors.cyan}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
[module/glyph-magenta--light-cyan] [module/glyph-magenta--cyan]
type = custom/text type = custom/text
content-background = ${colors.magenta} content-background = ${colors.magenta}
content-foreground = ${colors.light-cyan} content-foreground = ${colors.cyan}
content = ${glyph.gright} content = ${glyph.gright}
content-font = 5 content-font = 5
@ -300,6 +315,18 @@ format-background = ${colors.cyan}
format-foreground = ${colors.foreground} format-foreground = ${colors.foreground}
; cpu:1 ends here ; cpu:1 ends here
; [[file:../../Desktop.org::*nvidia][nvidia:2]]
[module/nvidia]
type = custom/script
exec = /home/pavel/bin/polybar/nvidia.sh
interval = 2
format =  <label>
; tail = true
format-background = ${colors.light-cyan}
format-foreground = ${colors.foreground}
; nvidia:2 ends here
; [[file:../../Desktop.org::*ram-memory][ram-memory:1]] ; [[file:../../Desktop.org::*ram-memory][ram-memory:1]]
[module/ram-memory] [module/ram-memory]
type = internal/memory type = internal/memory
@ -407,9 +434,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-cyan} format-discharging-background = ${colors.cyan}
format-charging-background = ${colors.light-cyan} format-charging-background = ${colors.cyan}
format-full-background = ${colors.light-cyan} format-full-background = ${colors.cyan}
format-foreground = ${colors.foreground} format-foreground = ${colors.foreground}
label-discharging = %percentage%% %time% label-discharging = %percentage%% %time%
label-charging =  %percentage%% %time% label-charging =  %percentage%% %time%
@ -426,12 +453,14 @@ ramp-capacity-4 = 
type = internal/temperature type = internal/temperature
interval = 10 interval = 10
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
format = <label> format = <label>
format-foreground = ${colors.foreground} format-foreground = ${colors.foreground}
format-background = ${colors.light-cyan} format-background = ${colors.cyan}
format-warn =  <label-warn> format-warn =  <label-warn>
format-warn-foreground = ${colors.foreground} format-warn-foreground = ${colors.foreground}
format-warn-background = ${colors.light-cyan} format-warn-background = ${colors.cyan}
; temperature:1 ends here ; temperature:1 ends here
; [[file:../../Desktop.org::*weather][weather:2]] ; [[file:../../Desktop.org::*weather][weather:2]]

View file

@ -1863,7 +1863,12 @@ So...
(ct-edit-lab-l-inc (ct-edit-lab-l-inc
color color
my/alpha-for-light)) my/alpha-for-light))
acc)) acc)
(push (cons (format "dark-%s" name)
(ct-edit-lab-l-dec
color
my/alpha-for-light))
acc) )
acc) acc)
'("black" "red" "green" "yellow" "blue" "magenta" "cyan" "white") '("black" "red" "green" "yellow" "blue" "magenta" "cyan" "white")
:initial-value nil)) :initial-value nil))
@ -1875,23 +1880,31 @@ So...
#+RESULTS: get-polybar-colors #+RESULTS: get-polybar-colors
#+begin_example #+begin_example
black = #292D3E black = #222222
light-black = #383c4e light-black = #303030
red = #f18388 dark-black = #131313
light-red = #ff959a red = #e28b8b
green = #c3e88d light-red = #f69d9d
light-green = #d6fc9f dark-red = #cd7879
yellow = #ffcb6b green = #31ba54
light-yellow = #ffde7d light-green = #4acd65
blue = #82aaff dark-green = #09a642
light-blue = #96bcff yellow = #e49300
magenta = #c792ea light-yellow = #faa522
light-magenta = #daa4fe dark-yellow = #ce8000
cyan = #89DDFF blue = #8f9fe3
light-cyan = #9df0ff light-blue = #a2b1f7
white = #EEFFFF dark-blue = #7b8ccf
light-white = #f1ffff magenta = #db81cf
background = #292D3E light-magenta = #ef93e2
dark-magenta = #c66ebb
cyan = #66a7e4
light-cyan = #7ab9f8
dark-cyan = #5094d0
white = #fff8f0
light-white = #fffef6
dark-white = #eae3dc
background = #c7c0ba
foreground = #000000 foreground = #000000
#+end_example #+end_example
@ -1926,9 +1939,10 @@ As we want to interweave polybar modules with these glyphs in the right order an
|-------+-------------+---------------+-------| |-------+-------------+---------------+-------|
| 1 | pulseaudio | light-magenta | + | | 1 | pulseaudio | light-magenta | + |
| 2 | mpd | magenta | + | | 2 | mpd | magenta | + |
| 15 | temperature | light-cyan | + | | 16 | nvidia | light-cyan | + |
| 9 | battery | light-cyan | + |
| 3 | cpu | cyan | + | | 3 | cpu | cyan | + |
| 15 | temperature | cyan | + |
| 9 | battery | cyan | + |
| 4 | ram-memory | light-green | + | | 4 | ram-memory | light-green | + |
| 5 | swap-memory | green | + | | 5 | swap-memory | green | + |
| 6 | bandwidth | light-red | + | | 6 | bandwidth | light-red | + |
@ -1948,6 +1962,11 @@ Also excluding some modules from certain monitors, which for now is about exclud
| HDMI-A-0 | battery | | HDMI-A-0 | battery |
| HDMI-0 | battery | | HDMI-0 | battery |
| DP-1 | battery | | DP-1 | battery |
| eDP | nvidia |
| eDP-1 | nvidia |
| DVI-D-0 | nvidia |
| HDMI-A-0 | nvidia |
| HDMI-1 | nvidia |
Another thing we need to do is to set the color of modules in accordance with the =polybar_modules= table. The background can be determined from the =Color= column with the following code block: Another thing we need to do is to set the color of modules in accordance with the =polybar_modules= table. The background can be determined from the =Color= column with the following code block:
#+NAME: get-polybar-bg #+NAME: get-polybar-bg
@ -2369,6 +2388,25 @@ label = %percentage%%
format-background = <<get-polybar-bg(module="cpu")>> format-background = <<get-polybar-bg(module="cpu")>>
format-foreground = ${colors.foreground} format-foreground = ${colors.foreground}
#+end_src #+end_src
*** nvidia
Display NVIDIA usage with nvidia-smi
#+begin_src bash :tangle ~/bin/polybar/nvidia.sh
nvidia-smi --query-gpu=utilization.gpu,power.draw,temperature.gpu,memory.used --format=csv,noheader | sed -s 's/ %/%/;s/W, [0-9]\+/&°C/;s/,/ /g'
#+end_src
#+begin_src conf-windows :noweb yes
[module/nvidia]
type = custom/script
exec = /home/pavel/bin/polybar/nvidia.sh
interval = 2
format =  <label>
; tail = true
format-background = <<get-polybar-bg(module="nvidia")>>
format-foreground = ${colors.foreground}
#+end_src
*** ram-memory *** ram-memory
RAM usage RAM usage
#+begin_src conf-windows :noweb yes #+begin_src conf-windows :noweb yes
@ -2657,6 +2695,8 @@ ramp-capacity-4 = 
type = internal/temperature type = internal/temperature
interval = 10 interval = 10
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
format = <label> format = <label>
format-foreground = ${colors.foreground} format-foreground = ${colors.foreground}
format-background = <<get-polybar-bg(module="battery")>> format-background = <<get-polybar-bg(module="battery")>>
@ -3767,6 +3807,7 @@ This section generates manifests for various desktop software that I'm using.
| dev | docker-compose | | | dev | docker-compose | |
| dev | postgresql | | | dev | postgresql | |
| dev | virt-manager | | | dev | virt-manager | |
| dev | dnsmasq | |
| dev | git-filter-repo | | | dev | git-filter-repo | |
| dev | node | | | dev | node | |
| dev | openjdk:jdk | | | dev | openjdk:jdk | |
@ -3789,6 +3830,7 @@ This section generates manifests for various desktop software that I'm using.
| dev | socat | | | dev | socat | |
| dev | wireshark | | | dev | wireshark | |
| dev | python-chess | | | dev | python-chess | |
| dev | python-cairosvg | |
** Manifests ** Manifests
#+NAME: packages #+NAME: packages
#+begin_src emacs-lisp :tangle no :var category="" #+begin_src emacs-lisp :tangle no :var category=""

View file

@ -45,13 +45,13 @@ declare -A BAR_HEIGHT=(
["DP-1"]="29" ["DP-1"]="29"
) )
declare -A BLOCKS=( declare -A BLOCKS=(
["eDP"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--light-cyan battery glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 " ["eDP"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--cyan temperature glyph-cyan--cyan battery glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 "
["eDP-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--light-cyan battery glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 " ["eDP-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--cyan temperature glyph-cyan--cyan battery glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 "
["DVI-D-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 " ["DVI-D-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--cyan temperature glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--cyan temperature glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--light-cyan battery glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--cyan cpu glyph-cyan--cyan temperature glyph-cyan--cyan battery glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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-0"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan nvidia glyph-light-cyan--cyan cpu glyph-cyan--cyan temperature glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 "
["DP-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan temperature glyph-light-cyan--cyan cpu glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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 " ["DP-1"]="glyph-background--light-magenta pulseaudio glyph-light-magenta--magenta mpd glyph-magenta--light-cyan nvidia glyph-light-cyan--cyan cpu glyph-cyan--cyan temperature glyph-cyan--light-green ram-memory glyph-light-green--green swap-memory glyph-green--light-red bandwidth 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