feat: Waybar improvements and refactoring (multiple changes)

This commit is contained in:
2025-09-22 22:37:55 +02:00
parent 8c9fcbbbf4
commit 9e5c90fcb6
8 changed files with 83 additions and 56 deletions

View File

@@ -8,7 +8,7 @@
"passthrough": false, "passthrough": false,
"fixed-center": true, "fixed-center": true,
"height": 32, "height": 32,
"spacing": 8, "spacing": 0,
// Hyprland // Hyprland
"hyprland/workspaces": { "hyprland/workspaces": {
"icon-size": 26, "icon-size": 26,
@@ -91,7 +91,7 @@
"tooltip": true, "tooltip": true,
"on-click": "pavucontrol", "on-click": "pavucontrol",
"on-click-right": "pactl set-sink-mute @DEFAULT_SINK@ toggle", "on-click-right": "pactl set-sink-mute @DEFAULT_SINK@ toggle",
"on-click-middle": "bash -lc \"next=$(pactl list short sinks | awk '{print \\$1}' | awk -v cur=$(pactl get-default-sink) '\\$0!=cur{print; exit}'); if [ -n \\\"$next\\\" ]; then pactl set-default-sink $next; notify-send -a waybar 'Audio' 'Switched default sink to '$next; fi\"", "on-click-middle": "$HOME/.config/waybar/scripts/cycle_sinks.sh",
"format-icons": { "format-icons": {
"alsa_output.usb-SteelSeries_Arctis_7_-00.analog-stereo": "", "alsa_output.usb-SteelSeries_Arctis_7_-00.analog-stereo": "",
"alsa_output.pci-0000_0a_00.4.iec958-stereo": "", "alsa_output.pci-0000_0a_00.4.iec958-stereo": "",
@@ -147,12 +147,14 @@
"on-click": "pkill -SIGRTMIN+4 waybar", "on-click": "pkill -SIGRTMIN+4 waybar",
}, },
"custom/temps": { "custom/temps": {
"exec-if": "command -v sensors >/dev/null", "exec-if": "[ -x $HOME/.config/waybar/scripts/temps.sh ]",
"exec": "bash -lc \"sensors | awk '/Tctl|Tdie|Package id 0/{gsub(/\\+|°C/,\\\"\\\"); print int($2); exit}'\"", "exec": "$HOME/.config/waybar/scripts/temps.sh",
"interval": 5, "interval": 5,
"format": " {output}°C", "format": " {}°C",
"tooltip": true, "tooltip": true,
"on-click": "alacritty -e watch -n 1 sensors", "signal": 6,
"on-click": "pkill -SIGRTMIN+6 waybar",
"on-click-right": "alacritty -e watch -n 1 sensors"
}, },
"custom/hyprsysteminfo": { "custom/hyprsysteminfo": {
"exec-if": "[ -x $HOME/.config/waybar/scripts/hyprsysteminfo.sh ]", "exec-if": "[ -x $HOME/.config/waybar/scripts/hyprsysteminfo.sh ]",
@@ -160,7 +162,9 @@
"return-type": "json", "return-type": "json",
"interval": 5, "interval": 5,
"tooltip": true, "tooltip": true,
"on-click": "bash -lc 'command -v hyprsysteminfo >/dev/null && uwsm app -- hyprsysteminfo'", "signal": 7,
"on-click": "pkill -SIGRTMIN+7 waybar",
"on-click-right": "bash -lc 'command -v hyprsysteminfo >/dev/null && uwsm app -- hyprsysteminfo'"
}, },
"custom/hyprsunset": { "custom/hyprsunset": {
"exec-if": "[ -x $HOME/.config/waybar/scripts/hyprsunset_toggle.sh ]", "exec-if": "[ -x $HOME/.config/waybar/scripts/hyprsunset_toggle.sh ]",
@@ -175,8 +179,14 @@
// Right click: manual on/off (doesnt touch auto flag) // Right click: manual on/off (doesnt touch auto flag)
"on-click-right": "bash -lc '$HOME/.config/waybar/scripts/hyprsunset_toggle.sh --toggle && pkill -SIGRTMIN+5 waybar'", "on-click-right": "bash -lc '$HOME/.config/waybar/scripts/hyprsunset_toggle.sh --toggle && pkill -SIGRTMIN+5 waybar'",
// Scroll: fine tune manual temp (useful when AUTO is OFF) // Scroll: fine tune manual temp (useful when AUTO is OFF)
"on-scroll-up": "bash -lc 't=$($HOME/.config/waybar/scripts/hyprsunset_toggle.sh --print | sed -n \"s/.* \\([0-9]\\+\\)K.*/\\1/p\"); [ -z \"$t\" ] && t=3800; t=$((t+200)); $HOME/.config/waybar/scripts/hyprsunset_toggle.sh --set $t && pkill -SIGRTMIN+5 waybar'", "on-scroll-up": "$HOME/.config/waybar/scripts/hyprsunset_toggle.sh --increase && pkill -SIGRTMIN+5 waybar",
"on-scroll-down": "bash -lc 't=$($HOME/.config/waybar/scripts/hyprsunset_toggle.sh --print | sed -n \"s/.* \\([0-9]\\+\\)K.*/\\1/p\"); [ -z \"$t\" ] && t=3800; t=$((t-200)); if [ $t -lt 1000 ]; then t=1000; fi; $HOME/.config/waybar/scripts/hyprsunset_toggle.sh --set $t && pkill -SIGRTMIN+5 waybar'", "on-scroll-down": "$HOME/.config/waybar/scripts/hyprsunset_toggle.sh --decrease && pkill -SIGRTMIN+5 waybar",
},
"custom/updates": {
"exec": "$HOME/.config/waybar/scripts/updates.sh",
"return-type": "json",
"interval": 3600,
"on-click": "alacritty -e sudo pacman -Syu"
}, },
// Tray / Clock / Privacy // Tray / Clock / Privacy
"tray": { "tray": {

View File

@@ -1,20 +1,18 @@
{ {
"name": "bar-dp1", "name": "bar-dp1",
"output": "DP-1", "output": "DP-1",
"spacing": 8, "spacing": 0,
"modules-left": ["hyprland/workspaces", "hyprland/window"], "modules-left": ["hyprland/workspaces", "privacy", "hyprland/window"],
"modules-center": ["privacy", "mpris"], "modules-center": ["clock"],
"modules-right": [ "modules-right": [
"group/sys", "group/sys",
"custom/updates",
"custom/alhp",
"network", "network",
"pulseaudio", "pulseaudio",
"bluetooth",
"battery",
"power-profiles-daemon", "power-profiles-daemon",
"custom/hyprsysteminfo",
"custom/hyprsunset", "custom/hyprsunset",
"tray", "tray"
"clock",
], ],
"hyprland/window": { "hyprland/window": {
"max-length": 60, "max-length": 60,

View File

@@ -1,26 +1,25 @@
{ {
"name": "bar-dp2", "name": "bar-dp2",
"output": "DP-2", "output": "DP-2",
"spacing": 10, "spacing": 0,
"modules-left": ["hyprland/workspaces", "hyprland/window"], "modules-left": ["hyprland/workspaces", "privacy", "hyprland/window"],
"modules-center": ["privacy", "mpris"], "modules-center": ["clock"],
"modules-right": [ "modules-right": [
"cpu", "cpu",
"memory", "memory",
"disk#nvme0", "disk#nvme0",
"disk#nvme1", "disk#nvme1",
"custom/temps",
"custom/updates",
"custom/alhp",
"network", "network",
"pulseaudio", "pulseaudio",
"bluetooth", "bluetooth",
"battery",
"power-profiles-daemon", "power-profiles-daemon",
"custom/alhp",
"custom/razer-mouse-battery", "custom/razer-mouse-battery",
"custom/temps",
"custom/hyprsysteminfo", "custom/hyprsysteminfo",
"custom/hyprsunset", "custom/hyprsunset",
"tray", "tray"
"clock",
], ],
"hyprland/window": { "hyprland/window": {
"max-length": 80, "max-length": 80,

View File

@@ -2,18 +2,15 @@
"name": "bar-hdmi", "name": "bar-hdmi",
"output": "HDMI-A-1", "output": "HDMI-A-1",
"height": 28, "height": 28,
"spacing": 6, "spacing": 0,
"modules-left": ["hyprland/workspaces", "hyprland/window"], "modules-left": ["hyprland/workspaces", "privacy", "hyprland/window"],
"modules-center": ["privacy", "mpris"], "modules-center": ["clock"],
"modules-right": [ "modules-right": [
"custom/updates",
"custom/alhp",
"network", "network",
"pulseaudio", "pulseaudio",
"bluetooth", "tray"
"battery",
"custom/hyprsysteminfo",
"custom/hyprsunset",
"tray",
"clock",
], ],
"hyprland/workspaces": { "hyprland/workspaces": {
"icon-size": 22, "icon-size": 22,

View File

@@ -45,7 +45,7 @@ esac
# Emit compact JSON for Statusbar # Emit compact JSON for Statusbar
jq -nc \ jq -nc \
--arg text "<span color=\"#4F84CC\">$icon</span> <span color=\"#CAD3E8\">$text</span>" \ --arg text "<span color=\"#FFFFFF\">$icon</span> <span color=\"#FFFFFF\">$text</span>" \
--arg class "$class" \ --arg class "$class" \
--arg tooltip "$tooltip" \ --arg tooltip "$tooltip" \
'{text: $text, class: $class, tooltip: $tooltip}' '{text: $text, class: $class, tooltip: $tooltip}'

View File

@@ -53,6 +53,21 @@ print_json() {
fi fi
} }
increase_temp() {
local t="$(cur_temp)"
[ -z "$t" ] && t=3800
t=$((t+200))
set_temp "$t"
}
decrease_temp() {
local t="$(cur_temp)"
[ -z "$t" ] && t=3800
t=$((t-200))
if [ "$t" -lt 1000 ]; then t=1000; fi
set_temp "$t"
}
case "${1:---print}" in case "${1:---print}" in
--print) print_json ;; --print) print_json ;;
--auto-on) echo -n "1" > "$AUTO_FILE" ; print_json ;; --auto-on) echo -n "1" > "$AUTO_FILE" ; print_json ;;
@@ -84,6 +99,14 @@ case "${1:---print}" in
set_temp "$t" set_temp "$t"
print_json print_json
;; ;;
*) echo "Usage: $0 [--print|--toggle-auto|--auto-on|--auto-off|--toggle|--set TEMP]" >&2; exit 1 ;; --increase)
increase_temp
print_json
;;
--decrease)
decrease_temp
print_json
;;
*) echo "Usage: $0 [--print|--toggle-auto|--auto-on|--auto-off|--toggle|--set TEMP|--increase|--decrease]" >&2; exit 1 ;;
esac esac

View File

@@ -32,7 +32,7 @@ else
fi fi
jq -nc \ jq -nc \
--arg text "<span color=\"#4F84CC\">$icon</span> <span color=\"#CAD3E8\">$text</span>" \ --arg text "<span color=\"#4F84CC\">$icon</span> <span color=\"#CAD3E8\">$text</span>" \
--arg class "$class" \ --arg class "$class" \
--arg tooltip "$tooltip" \ --arg tooltip "$tooltip" \
'{text: $text, class: $class, tooltip: $tooltip}' '{text: $text, class: $class, tooltip: $tooltip}'

View File

@@ -26,7 +26,7 @@
/* Bar Background */ /* Bar Background */
window#waybar { window#waybar {
background: @bg_main; background: linear-gradient(90deg, @bg_main, rgba(21, 37, 53, 0.85));
border-top: 1px solid @border_main; border-top: 1px solid @border_main;
} }
@@ -52,16 +52,14 @@ tooltip {
/* Module Spacing & Hover */ /* Module Spacing & Hover */
.module { .module {
padding: 0 6px; padding: 0 6px;
margin: 0 2px; margin: 0;
} }
.module:hover { .module:hover {
background: @bg_hover; background: @bg_hover;
transition: background-color 0.3s ease;
} }
/* HDMI: tighter modules to free center space */
window#waybar.bar-hdmi .module {
padding: 0 4px;
}
/* Collapse empty/noise modules */ /* Collapse empty/noise modules */
#mpris.empty, #mpris.empty,
@@ -80,11 +78,15 @@ window#waybar.bar-hdmi .module {
#network, #network,
#pulseaudio, #pulseaudio,
#bluetooth, #bluetooth,
#battery,
#power-profiles-daemon, #power-profiles-daemon,
#custom-alhp, #custom-alhp,
#custom-razer-mouse-battery, #custom-razer-mouse-battery,
#custom-hyprsunset { #custom-temps,
/* ← new module gets a separator too */ #custom-hyprsysteminfo,
#custom-hyprsunset,
#custom-updates,
#tray {
border-right: 1px solid @border_main; border-right: 1px solid @border_main;
} }
@@ -93,7 +95,7 @@ window#waybar.bar-hdmi .module {
margin: 0 2px; margin: 0 2px;
} }
#workspaces button { #workspaces button {
padding: 4px 6px; min-width: 30px;
color: @content_inactive; color: @content_inactive;
} }
#workspaces button:hover { #workspaces button:hover {
@@ -114,19 +116,19 @@ window#waybar.bar-hdmi .module {
#window { #window {
min-width: 0; min-width: 0;
font-weight: 500; font-weight: 500;
padding: 0 6px;
} }
/* MPRIS */ /* MPRIS */
#mpris { #mpris {
min-width: 0; min-width: 0;
padding: 0 6px;
} }
/* Tray & Clock */ /* Tray & Clock */
#tray, #tray,
#clock { #clock {
padding: 0 6px; }
#privacy {
min-width: 30px;
} }
#tray > .passive { #tray > .passive {
opacity: 0.7; opacity: 0.7;
@@ -153,16 +155,15 @@ window#waybar.bar-hdmi .module {
#bluetooth, #bluetooth,
#mpris, #mpris,
#custom-hyprsunset { #custom-hyprsunset {
color: #dee6f7; /* very light tint; still reads as white on dark */ color: #FFFFFF; /* very light tint; still reads as white on dark */
} }
/* Drawer polish (DP-1) */ /* Drawer polish (DP-1) */
#custom-sys { #custom-sys {
padding: 0 8px; min-width: 30px;
font-weight: 600; font-weight: 600;
} }
.sys { .sys {
padding: 0 6px;
} }
.revealed .sys { .revealed .sys {
background: rgba(79, 132, 204, 0.12); background: rgba(79, 132, 204, 0.12);
@@ -172,7 +173,6 @@ window#waybar.bar-hdmi .module {
#custom-alhp, #custom-alhp,
#custom-razer-mouse-battery, #custom-razer-mouse-battery,
#custom-hyprsunset { #custom-hyprsunset {
padding: 0 6px;
} }
/* Network states */ /* Network states */
@@ -186,6 +186,6 @@ window#waybar.bar-hdmi .module {
#temperature.critical { color: #FFCC33; font-weight: 600; } #temperature.critical { color: #FFCC33; font-weight: 600; }
/* Backlight spacing */ /* Backlight spacing */
#backlight { padding: 0 6px; border-right: 1px solid @border_main; } #backlight { border-right: 1px solid @border_main; }
#custom-mic, #custom-touchpad { padding: 0 6px; } #custom-mic, #custom-touchpad { }