From 528d96221a1c41fb640505a4f0d0cc3a5353142a Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Mon, 30 Sep 2024 23:02:57 -0400 Subject: [PATCH] Add System76 Power Module - Remove sleep from waybar launch script - Re-order and re-arrange modules - Add left and right click events for modules - Change module colors - Remove commented lines - Add a slower scroll step to pavucontrol module --- README.org | 71 ++++++++++++++++++++++------- waybar/config.jsonc | 27 ++++++++--- waybar/launch.sh | 2 - waybar/scripts/get-media-playing.sh | 1 - waybar/scripts/system76-power.sh | 7 +++ waybar/style.css | 19 +++++--- 6 files changed, 93 insertions(+), 34 deletions(-) create mode 100755 waybar/scripts/system76-power.sh diff --git a/README.org b/README.org index f86445b..21b9480 100644 --- a/README.org +++ b/README.org @@ -52,6 +52,7 @@ - [[#playerctl][Playerctl]] - [[#power-menu][Power Menu]] - [[#pulseaudio][Pulseaudio]] + - [[#system76-power][System76 Power]] - [[#tray][Tray]] - [[#end-configuration][End Configuration]] - [[#justfile][Justfile]] @@ -499,8 +500,6 @@ static const Button buttons[] = { #+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/launch.sh killall waybar -sleep 5 - /usr/bin/waybar \ -c $HOME/.config/dwl/waybar/config.jsonc \ -s $HOME/.config/dwl/waybar/style.css & @@ -532,19 +531,20 @@ sleep 5 "modules-left": [ "custom/power-menu", "dwl/tags", - ], - "modules-center": [ "tray", ], - "modules-right": [ - "group/media-playing", + "modules-center": [ + "group/dunst", "pulseaudio", + "group/media-playing", + ], + "modules-right": [ + "custom/system76-power", "cpu", "memory", "disk", "battery", "clock", - "group/dunst", ], "group/media-playing": { "orientation": "horizontal", @@ -554,7 +554,6 @@ sleep 5 "custom/media-playing-play-pause", "custom/media-playing-next", ], - /* "drawer": {}, */ }, "group/dunst": { "orientation": "horizontal", @@ -622,6 +621,7 @@ window#waybar { "interval": 5, "format": " {usage}%", "tooltip": true, + "on-click-right": "kitty btop", }, #+END_SRC @@ -629,7 +629,7 @@ window#waybar { #+BEGIN_SRC css :tangle waybar/style.css #cpu { - background: #bd93f9; + background: #ff79c6; color: #282a36; } #+END_SRC @@ -765,6 +765,7 @@ fi "format": "󰋊 {percentage_used}%", "tooltip": true, "tooltip-format": "Used: {used} ({percentage_used}%)\nFree: {free} ({percentage_free}%)\nTotal: {total}", + "on-click-right": "qdirstat", }, #+END_SRC @@ -772,7 +773,7 @@ fi #+BEGIN_SRC css :tangle waybar/style.css #disk { - background: #ff79c6; + background: #f1fa8c; color: #282a36; } #+END_SRC @@ -787,6 +788,7 @@ fi "format": " {percentage}%", "tooltip": true, "tooltip-format": "RAM:\n\tUsed: {used} GiB ({percentage}%)\n\tFree: {avail} GiB\n\tTotal: {total} GiB\nSwap:\n\tUsed: {swapUsed} GiB ({swapPercentage}%)\n\tFree: {swapAvail} GiB\n\tTotal: {swapTotal} GiB", + "on-click-right": "kitty btop", }, #+END_SRC @@ -833,19 +835,19 @@ fi #+BEGIN_SRC css :tangle waybar/style.css #custom-media-playing-change { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-prev { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-play-pause { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-next { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #+END_SRC @@ -939,7 +941,6 @@ else fi fi -# echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r󰀥\t'$album'\r󰐎\t'$status'"}' | jq --unbuffered --compact-output echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r󰀥\t'$album'\r󰐎\t'$status'"}' #+END_SRC @@ -984,9 +985,11 @@ echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r "default": "", }, "scroll-step": 5, - "on-click": "pavucontrol", + "on-click": "~/.scripts/pactl.sh --mute", + "on-click-right": "~/.scripts/pactl.sh --mixer", "tooltip": true, "tooltip-format": "{desc}", + "scroll-step": 0.25, }, #+END_SRC @@ -994,11 +997,45 @@ echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r #+BEGIN_SRC css :tangle waybar/style.css #pulseaudio { - background: #ff5555; + background: #8be9fd; color: #282a36; } #+END_SRC +*** System76 Power + +**** Configuration + +#+BEGIN_SRC jsonc :tangle waybar/config.jsonc + "custom/system76-power": { + "exec": "~/.config/dwl/waybar/scripts/system76-power.sh", + "return-type": "json", + "restart-interval": 60, + "on-click-right": "~/.scripts/cpu-gpu.sh --rofi", + "tooltip": true, + }, +#+END_SRC + +**** Styling + +#+BEGIN_SRC css :tangle waybar/style.css +#custom-system76-power { + background: #ffb86c; + color: #282a36; +} +#+END_SRC + +**** Script + +#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/system76-power.sh +profile="$(sudo system76-power profile | sed -z '$ s/\n$//' | tr '\n' '\r')" +graphics="$(sudo system76-power graphics)" +graphicsPower="$(sudo system76-power graphics power)" +chargeThresholds="$(sudo system76-power charge-thresholds | sed -z '$ s/\n$//' | tr '\n' '\r')" + +echo '{"text":"󰢮 '$graphics'","tooltip":"󰢮\t'$graphics'\r󰐥\t'$graphicsPower'\r\r Profile\r'$profile'\r\r󰚥 Charge Thresholds\r'$chargeThresholds'"}' +#+END_SRC + *** Tray **** Configuration diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 083b649..5f1880b 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -15,19 +15,20 @@ "modules-left": [ "custom/power-menu", "dwl/tags", - ], - "modules-center": [ "tray", ], - "modules-right": [ - "group/media-playing", + "modules-center": [ + "group/dunst", "pulseaudio", + "group/media-playing", + ], + "modules-right": [ + "custom/system76-power", "cpu", "memory", "disk", "battery", "clock", - "group/dunst", ], "group/media-playing": { "orientation": "horizontal", @@ -37,7 +38,6 @@ "custom/media-playing-play-pause", "custom/media-playing-next", ], - /* "drawer": {}, */ }, "group/dunst": { "orientation": "horizontal", @@ -66,6 +66,7 @@ "interval": 5, "format": " {usage}%", "tooltip": true, + "on-click-right": "kitty btop", }, "clock": { @@ -112,6 +113,7 @@ "format": "󰋊 {percentage_used}%", "tooltip": true, "tooltip-format": "Used: {used} ({percentage_used}%)\nFree: {free} ({percentage_free}%)\nTotal: {total}", + "on-click-right": "qdirstat", }, "memory": { @@ -119,6 +121,7 @@ "format": " {percentage}%", "tooltip": true, "tooltip-format": "RAM:\n\tUsed: {used} GiB ({percentage}%)\n\tFree: {avail} GiB\n\tTotal: {total} GiB\nSwap:\n\tUsed: {swapUsed} GiB ({swapPercentage}%)\n\tFree: {swapAvail} GiB\n\tTotal: {swapTotal} GiB", + "on-click-right": "kitty btop", }, "custom/media-playing-change": { @@ -166,9 +169,19 @@ "default": "", }, "scroll-step": 5, - "on-click": "pavucontrol", + "on-click": "~/.scripts/pactl.sh --mute", + "on-click-right": "~/.scripts/pactl.sh --mixer", "tooltip": true, "tooltip-format": "{desc}", + "scroll-step": 0.25, + }, + + "custom/system76-power": { + "exec": "~/.config/dwl/waybar/scripts/system76-power.sh", + "return-type": "json", + "restart-interval": 60, + "on-click-right": "~/.scripts/cpu-gpu.sh --rofi", + "tooltip": true, }, "tray": { diff --git a/waybar/launch.sh b/waybar/launch.sh index fe29551..47eb919 100755 --- a/waybar/launch.sh +++ b/waybar/launch.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash killall waybar -sleep 5 - /usr/bin/waybar \ -c $HOME/.config/dwl/waybar/config.jsonc \ -s $HOME/.config/dwl/waybar/style.css & diff --git a/waybar/scripts/get-media-playing.sh b/waybar/scripts/get-media-playing.sh index 4b6e10f..aa80d92 100755 --- a/waybar/scripts/get-media-playing.sh +++ b/waybar/scripts/get-media-playing.sh @@ -30,5 +30,4 @@ else fi fi -# echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r󰀥\t'$album'\r󰐎\t'$status'"}' | jq --unbuffered --compact-output echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'$title'\r󰠃\t'$artist'\r󰀥\t'$album'\r󰐎\t'$status'"}' diff --git a/waybar/scripts/system76-power.sh b/waybar/scripts/system76-power.sh new file mode 100755 index 0000000..48531a8 --- /dev/null +++ b/waybar/scripts/system76-power.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +profile="$(sudo system76-power profile | sed -z '$ s/\n$//' | tr '\n' '\r')" +graphics="$(sudo system76-power graphics)" +graphicsPower="$(sudo system76-power graphics power)" +chargeThresholds="$(sudo system76-power charge-thresholds | sed -z '$ s/\n$//' | tr '\n' '\r')" + +echo '{"text":"󰢮 '$graphics'","tooltip":"󰢮\t'$graphics'\r󰐥\t'$graphicsPower'\r\r Profile\r'$profile'\r\r󰚥 Charge Thresholds\r'$chargeThresholds'"}' diff --git a/waybar/style.css b/waybar/style.css index c00e6e6..c25d428 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -16,7 +16,7 @@ window#waybar { } #cpu { - background: #bd93f9; + background: #ff79c6; color: #282a36; } @@ -60,7 +60,7 @@ window#waybar { } #disk { - background: #ff79c6; + background: #f1fa8c; color: #282a36; } @@ -70,19 +70,19 @@ window#waybar { } #custom-media-playing-change { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-prev { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-play-pause { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } #custom-media-playing-next { - background: #50fa7b; + background: #f1fa8c; color: #282a36; } @@ -92,7 +92,12 @@ window#waybar { } #pulseaudio { - background: #ff5555; + background: #8be9fd; + color: #282a36; +} + +#custom-system76-power { + background: #ffb86c; color: #282a36; }