feat: waybar gpu usage and new style

This commit is contained in:
hesam-init 2024-02-23 18:20:31 +03:30
parent d44ffe82bc
commit 3732e50dd1
3 changed files with 43 additions and 74 deletions

View file

@ -8,6 +8,8 @@
"margin-left": 6, "margin-left": 6,
"margin-right": 6, "margin-right": 6,
"modules-right": [ "modules-right": [
"cpu",
"custom/gpu-usage",
"wireplumber", "wireplumber",
"hyprland/language", "hyprland/language",
"clock" "clock"
@ -18,17 +20,15 @@
"tray" "tray"
], ],
"modules-center": [ "modules-center": [
"battery",
"cpu",
"memory",
"network#network-2"
// "network"
// "pulseaudio" // "pulseaudio"
// "custom/snip" // "custom/snip"
// "custom/updater", // "custom/updater",
// "custom/wallpaper", // "custom/wallpaper",
// "pulseaudio/slider", // "pulseaudio/slider",
// "keyboard-state", "battery",
"memory",
"network#network-2",
"network"
], ],
"hyprland/language": { "hyprland/language": {
"format": "{}", "format": "{}",
@ -148,10 +148,15 @@
}, },
"cpu": { "cpu": {
"interval": 1, "interval": 1,
"format": "{usage}% " "format": "{usage}% "
},
"custom/gpu-usage": {
"exec": "~/.config/waybar/scripts/gpu-usage.sh",
"format": "{}% ",
"interval": 1
}, },
"memory": { "memory": {
"format": "{used:0.1f}/{total:0.1f} GB", "format": "{used:0.1f}/{total:0.1f} ",
"interval": 5 "interval": 5
}, },
"backlight": { "backlight": {
@ -196,23 +201,11 @@
"format-wifi": " : {bandwidthDownBytes}  : {bandwidthUpBytes}", "format-wifi": " : {bandwidthDownBytes}  : {bandwidthUpBytes}",
"format-ethernet": " : {bandwidthDownBytes}  : {bandwidthUpBytes}", "format-ethernet": " : {bandwidthDownBytes}  : {bandwidthUpBytes}",
"format-linked": "(No IP) ", "format-linked": "(No IP) ",
"format-disconnected": " 0.0B/s  0.0B/s", "format-disconnected": " : {bandwidthDownBytes}  : {bandwidthUpBytes}",
"on-click-right": "~/.config/hypr/scripts/nmtui-launch.sh", "on-click-right": "~/.config/hypr/scripts/nmtui-launch.sh",
"tooltip": false, "tooltip": false,
"interval": 1 "interval": 1
}, },
"custom/media": {
"format": "{icon} {}",
"return-type": "json",
"max-length": 20,
"format-icons": {
"spotify": " ",
"default": " "
},
"escape": true,
"exec": "~/.config/system_scripts/mediaplayer.py 2> /dev/null",
"on-click": "playerctl play-pause"
},
"custom/launcher": { "custom/launcher": {
"format": "", "format": "",
"on-click": "~/.config/hypr/scripts/rofi-launch.sh d", "on-click": "~/.config/hypr/scripts/rofi-launch.sh d",
@ -223,10 +216,6 @@
"on-click": "~/.config/hypr/scripts/rofi-launch.sh p", "on-click": "~/.config/hypr/scripts/rofi-launch.sh p",
"on-click-right": "pkill rofi" "on-click-right": "pkill rofi"
}, },
"custom/snip": {
"format": " ",
"on-click": "grimshot --notify save area $HOME/Pictures/$(zenity --entry --text 'Set filename:' --entry-text '.png')"
},
"custom/wallpaper": { "custom/wallpaper": {
"format": " ", "format": " ",
"on-click": "bash ~/.config/system_scripts/pkill_bc" "on-click": "bash ~/.config/system_scripts/pkill_bc"

View file

@ -46,6 +46,7 @@ window#waybar.hidden {
#clock, #clock,
#battery, #battery,
#cpu, #cpu,
#custom-gpu-usage,
#memory, #memory,
#disk, #disk,
#temperature, #temperature,
@ -55,11 +56,7 @@ window#waybar.hidden {
#custom-media, #custom-media,
#custom-launcher, #custom-launcher,
#custom-power, #custom-power,
#custom-layout,
#custom-updater,
#custom-snip,
#custom-wallpaper, #custom-wallpaper,
#custom-playerlabel,
#tags, #tags,
#taskbar, #taskbar,
#tray, #tray,
@ -137,47 +134,11 @@ window#waybar.hidden {
font-size: 18px; font-size: 18px;
} }
#custom-layout {
color: white;
font-size: 20px;
}
#custom-updater {
color: white;
}
#custom-snip {
color: skyblue;
font-size: 20px;
}
#custom-wallpaper { #custom-wallpaper {
color: pink; color: pink;
font-size: 20px; font-size: 20px;
} }
#tags {
font-size: 20px;
}
#tags button.occupied {
color: skyblue;
margin: 5px;
background-color: #272727;
}
#tags button.focused {
color: black;
margin: 5px;
background-color: white;
}
#tags button.urgent {
color: red;
margin: 5px;
background-color: white;
}
#temperature.critical { #temperature.critical {
background-color: #eb4d4b; background-color: #eb4d4b;
} }
@ -190,17 +151,16 @@ window#waybar.hidden {
color: red; color: red;
} }
#memory,
#cpu {
min-width: 90px;
}
#language, #language,
#clock, #clock,
#wireplumber { #wireplumber,
min-width: 70px; #cpu,
#custom-gpu-usage {
min-width: 65px;
}
#memory {
min-width: 80px;
} }
#wireplumber.muted { #wireplumber.muted {

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
file_exists() {
if [ -f "$1" ]; then
return 0
else
return 1
fi
}
device_id="0"
gpu_busy_file="/sys/class/hwmon/hwmon$device_id/device/gpu_busy_percent"
if file_exists "$gpu_busy_file"; then
gpu_busy_percent=$(cat "$gpu_busy_file")
echo "$gpu_busy_percent"
else
echo "Error !" >&2
exit 1
fi