From 384340ad2a727d7f6723ada5f6a9b9134eac7aa9 Mon Sep 17 00:00:00 2001 From: GaspardCulis Date: Tue, 14 Nov 2023 15:58:32 +0100 Subject: [PATCH] Add GPU status to waybar --- bar/waybar/config.jsonc | 300 ++++++++++++++++--------------- bar/waybar/scripts/gpu_status.sh | 16 ++ bar/waybar/style.css | 34 ++-- 3 files changed, 198 insertions(+), 152 deletions(-) create mode 100755 bar/waybar/scripts/gpu_status.sh diff --git a/bar/waybar/config.jsonc b/bar/waybar/config.jsonc index a9afa2d..aaf7ef5 100755 --- a/bar/waybar/config.jsonc +++ b/bar/waybar/config.jsonc @@ -1,23 +1,35 @@ { - "layer": "top", - "position": "top", - "mod": "dock", - "exclusive": true, - "passthrough": false, - "gtk-layer-shell": true, - "height": 50, - "modules-left": ["clock","custom/weather","hyprland/workspaces"], - "modules-center": ["hyprland/window"], - "modules-right": ["network", "bluetooth", "memory", "cpu", "temperature","custom/power_profile","battery","pulseaudio","pulseaudio#microphone","tray"], - "hyprland/window": { - "format": "{}" - }, + "layer": "top", + "position": "top", + "mod": "dock", + "exclusive": true, + "passthrough": false, + "gtk-layer-shell": true, + "height": 50, + "modules-left": ["clock", "custom/weather", "hyprland/workspaces"], + "modules-center": ["hyprland/window"], + "modules-right": [ + "network", + "bluetooth", + "memory", + "cpu", + "temperature", + "custom/power_profile", + "custom/gpu_status", + "battery", + "pulseaudio", + "pulseaudio#microphone", + "tray" + ], + "hyprland/window": { + "format": "{}" + }, - "hyprland/workspaces": { - "disable-scroll": true, - "all-outputs": true, - "on-click": "activate", - /* + "hyprland/workspaces": { + "disable-scroll": true, + "all-outputs": true, + "on-click": "activate" + /* "persistent_workspaces": { "1": [], "2": [], @@ -30,136 +42,144 @@ "9": [], "10": [] }*/ - }, - - "custom/power_profile":{ - //shows the current power profile and switches to next on click - "exec": "~/.config/waybar/scripts/powerprofile.sh", - "return-type": "json", - "interval": 30, - "tooltip": false, - "format": "󰈐 {}", - "on-click": "asusctl profile -n; pkill -SIGRTMIN+8 waybar", - "signal": 8 - }, + }, - "custom/weather" : { - //shows the current weather and forecast - "tooltip" : true, - "format" : "{}", - "interval" : 30, - "exec" : "~/.config/waybar/scripts/waybar-wttr.py", - "return-type" : "json" - }, + "custom/power_profile": { + //shows the current power profile and switches to next on click + "exec": "~/.config/waybar/scripts/powerprofile.sh", + "return-type": "json", + "interval": 30, + "tooltip": false, + "format": "󰈐 {}", + "on-click": "asusctl profile -n; pkill -SIGRTMIN+8 waybar", + "signal": 8 + }, - "tray": { - "icon-size": 18, - "spacing": 10 - }, + "custom/weather": { + //shows the current weather and forecast + "tooltip": true, + "format": "{}", + "interval": 120, + "exec": "~/.config/waybar/scripts/waybar-wttr.py", + "return-type": "json" + }, - "clock": { - "format": "{: %H:%M  %a, %b %e}", - "tooltip-format": "{:%Y %B}\n{calendar}" - }, + "tray": { + "icon-size": 18, + "spacing": 10 + }, - "backlight": { - "device": "asus::kbd_backlight", - "format": "{icon} {percent}%", - "format-icons": ["", "", ""], - "on-scroll-up": "brightnessctl set 1%+", - "on-scroll-down": "brightnessctl set 1%-", - "min-length": 6 - }, + "clock": { + "format": "{: %H:%M  %a, %b %e}", + "tooltip-format": "{:%Y %B}\n{calendar}" + }, - "battery": { - "states": { - "good": 95, - "warning": 30, - "critical": 20 - }, - "format": "{icon} {capacity}%", - "format-charging": " {capacity}%", - "format-plugged": " {capacity}%", - "format-alt": "{time} {icon}", - "format-icons": ["", "", "", "", ""] - }, + "backlight": { + "device": "asus::kbd_backlight", + "format": "{icon} {percent}%", + "format-icons": ["", "", ""], + "on-scroll-up": "brightnessctl set 1%+", + "on-scroll-down": "brightnessctl set 1%-", + "min-length": 6 + }, - "pulseaudio": { - "format": "{icon} {volume}%", - "tooltip": false, - "format-muted": " Muted", - "on-click": "pamixer -t", - "on-scroll-up": "pamixer -i 5", - "on-scroll-down": "pamixer -d 5", - "scroll-step": 5, - "format-icons": { - "headphone": "", - "hands-free": "", - "headset": "", - "phone": "", - "portable": "", - "car": "", - "default": ["", "", ""] - } + "battery": { + "states": { + "good": 95, + "warning": 30, + "critical": 20 }, + "format": "{icon} {capacity}%", + "format-charging": " {capacity}%", + "format-plugged": " {capacity}%", + "format-alt": "{time} {icon}", + "format-icons": ["", "", "", "", ""] + }, - "pulseaudio#microphone": { - "format": "{format_source}", - "format-source": " {volume}%", - "format-source-muted": " Muted", - "on-click": "pamixer --default-source -t", - "on-scroll-up": "pamixer --default-source -i 5", - "on-scroll-down": "pamixer --default-source -d 5", - "scroll-step": 5, - "tooltip": false - }, - - "temperature": { - "thermal-zone": 0, - "critical-threshold": 80, - "format": "{temperatureC}°C ", - "format-critical": "{temperatureC}°C ", - "tooltip": false - }, + "custom/gpu_status": { + "exec": "~/.config/waybar/scripts/gpu_status.sh", + "return-type": "json", + "interval": 2, + "tooltip": false, + "format": "{}", + "signal": 9 + }, - "network": { - "interface": "wlan0", // (Optional) To force the use of this interface - "format-wifi": " {signalStrength}%", - "format-ethernet": "{ifname}: {ipaddr}/{cidr} ", - "tooltip-format": "{essid} - {ifname} via {gwaddr} ", - "format-linked": "{ifname} (No IP) ", - "format-disconnected": "Disconnected ⚠", - "format-alt": "{ifname}:{essid} {ipaddr}/{cidr}" - }, - - "cpu": { - "interval": 1, - "format": "󰻠 {usage:>2}%", - "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"], - "states": { - "critical": 90, - "warning": 50 - }, - }, - - "memory": { - "interval": 1, - "format": "󰍛 {used:0.1f}G/{total:0.1f}G", - "states": { - "critical": 90, - "warning": 50 - }, - "tooltip": false - }, - - "bluetooth": { - "format": " {status}", - "format-disabled": "", // an empty format will hide the module - "format-connected": " {num_connections}", - "tooltip-format": "{device_alias}", - "tooltip-format-connected": " {device_enumerate}", - "tooltip-format-enumerate-connected": "{device_alias}", - "on-click": "/usr/bin/blueman-manager" + "pulseaudio": { + "format": "{icon} {volume}%", + "tooltip": false, + "format-muted": " Muted", + "on-click": "pamixer -t", + "on-scroll-up": "pamixer -i 5", + "on-scroll-down": "pamixer -d 5", + "scroll-step": 5, + "format-icons": { + "headphone": "", + "hands-free": "", + "headset": "", + "phone": "", + "portable": "", + "car": "", + "default": ["", "", ""] } -} + }, + "pulseaudio#microphone": { + "format": "{format_source}", + "format-source": " {volume}%", + "format-source-muted": " Muted", + "on-click": "pamixer --default-source -t", + "on-scroll-up": "pamixer --default-source -i 5", + "on-scroll-down": "pamixer --default-source -d 5", + "scroll-step": 5, + "tooltip": false + }, + + "temperature": { + "thermal-zone": 0, + "critical-threshold": 80, + "format": "{temperatureC}°C ", + "format-critical": "{temperatureC}°C ", + "tooltip": false + }, + + "network": { + "interface": "wlan0", // (Optional) To force the use of this interface + "format-wifi": " {signalStrength}%", + "format-ethernet": "{ifname}: {ipaddr}/{cidr} ", + "tooltip-format": "{essid} - {ifname} via {gwaddr} ", + "format-linked": "{ifname} (No IP) ", + "format-disconnected": "Disconnected ⚠", + "format-alt": "{ifname}:{essid} {ipaddr}/{cidr}" + }, + + "cpu": { + "interval": 1, + "format": "󰻠 {usage:>2}%", + "format-icons": ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"], + "states": { + "critical": 90, + "warning": 50 + } + }, + + "memory": { + "interval": 1, + "format": "󰍛 {used:0.1f}G/{total:0.1f}G", + "states": { + "critical": 90, + "warning": 50 + }, + "tooltip": false + }, + + "bluetooth": { + "format": " {status}", + "format-disabled": "", // an empty format will hide the module + "format-connected": " {num_connections}", + "tooltip-format": "{device_alias}", + "tooltip-format-connected": " {device_enumerate}", + "tooltip-format-enumerate-connected": "{device_alias}", + "on-click": "/usr/bin/blueman-manager" + } +} diff --git a/bar/waybar/scripts/gpu_status.sh b/bar/waybar/scripts/gpu_status.sh new file mode 100755 index 0000000..d969429 --- /dev/null +++ b/bar/waybar/scripts/gpu_status.sh @@ -0,0 +1,16 @@ +#!/bin/bash +ACTIVE_ICON='󰍹' +SUSPENDED_ICON='󰶐' +RESUMING_ICON='󱄄' + +icon=$ACTIVE_ICON +status=$(cat /sys/bus/pci/devices/0000:01:00.0/power/runtime_status) + +if [ "$status" == "suspended" ]; then + icon=$SUSPENDED_ICON +elif [ "$status" == "resuming" ]; then + icon=$RESUMING_ICON +fi + +echo "{\"text\": \"$icon\", \"class\": \"$status\"}" + diff --git a/bar/waybar/style.css b/bar/waybar/style.css index f1df6b1..c40f55f 100755 --- a/bar/waybar/style.css +++ b/bar/waybar/style.css @@ -28,13 +28,13 @@ tooltip { #workspaces button.active { color: #a6adc8; - background: #3F84E5; + background: #3f84e5; border-radius: 10px; } #workspaces button.urgent { color: #11111b; - background: #FC6471; + background: #fc6471; border-radius: 10px; } @@ -44,6 +44,7 @@ tooltip { } #custom-power_profile, +#custom-gpu_status, #custom-weather, #window, #clock, @@ -62,7 +63,6 @@ tooltip { padding: 0px 10px; margin: 3px 0px; margin-top: 10px; - border: 1px solid #181825; } #memory { @@ -71,11 +71,11 @@ tooltip { } #memory.warning { - color: #EDAE49; + color: #edae49; } #memory.critical { - color: #FC6471; + color: #fc6471; } #cpu { @@ -84,11 +84,11 @@ tooltip { } #cpu.warning { - color: #EDAE49; + color: #edae49; } #cpu.critical { - color: #FC6471; + color: #fc6471; } #temperature { @@ -97,7 +97,7 @@ tooltip { } #temperature.critical { - color: #FC6471; + color: #fc6471; } #backlight { @@ -124,11 +124,21 @@ tooltip { } #custom-power_profile.Performance { - color: #FC6471; + color: #fc6471; } #custom-power_profile.Balanced { - color: #EDAE49; + color: #edae49; +} + +#custom-gpu_status { + color: #a6e3a1; + padding-top: 3px; + padding-left: 3px; +} + +#custom-gpu_status:not(.suspended) { + color: #edae49; } #window { @@ -154,7 +164,7 @@ tooltip { #bluetooth { color: #89b4fa; border-radius: 0px 10px 10px 0px; - margin-right: 10px + margin-right: 10px; } #pulseaudio { @@ -183,4 +193,4 @@ tooltip { border-radius: 0px 10px 10px 0px; border-left: 0px; margin-left: 0px; -} \ No newline at end of file +}