waybar - updated alhp-utils module

This commit is contained in:
2025-05-05 13:02:52 +02:00
parent a2a6395e95
commit 3771ca9115
5 changed files with 152 additions and 159 deletions

View File

@@ -1,18 +1,14 @@
{ {
"layer": "bottom", "layer": "bottom",
"output": ["DP-1", "DP-2", "!HDMI-A-2"],
"position": "bottom", "position": "bottom",
"mod": "dock", "mod": "dock",
"exclusive": true, "exclusive": true,
"gtk-layer-shell": true, "gtk-layer-shell": true,
"passthrough": false, "passthrough": false,
"height": 30, "height": 30,
"modules-left": [ "modules-left": ["hyprland/workspaces"],
"hyprland/workspaces" "modules-center": ["mpris", "privacy"],
],
"modules-center": [
"mpris",
"privacy"
],
"modules-right": [ "modules-right": [
"custom/alhp", "custom/alhp",
"cpu", "cpu",
@@ -23,18 +19,18 @@
"network", "network",
"battery", "battery",
"tray", "tray",
"clock" "clock",
], ],
"hyprland/workspaces": { "hyprland/workspaces": {
"icon-size": 32, "icon-size": 32,
"spacing": 16, "spacing": 16,
"on-scroll-up": "hyprctl dispatch workspace r+1", "on-scroll-up": "hyprctl dispatch workspace r+1",
"on-scroll-down": "hyprctl dispatch workspace r-1" "on-scroll-down": "hyprctl dispatch workspace r-1",
}, },
"cpu": { "cpu": {
"interval": 5, "interval": 5,
"format": " {usage}%", "format": " {usage}%",
"max-length": 10 "max-length": 10,
}, },
"disk": { "disk": {
"interval": 30, "interval": 30,
@@ -42,14 +38,14 @@
"path": "/", "path": "/",
"tooltip": true, "tooltip": true,
"unit": "GB", "unit": "GB",
"tooltip-format": "Available {free} of {total}" "tooltip-format": "Available {free} of {total}",
}, },
"memory": { "memory": {
"interval": 10, "interval": 10,
"format": " {percentage}%", "format": " {percentage}%",
"max-length": 10, "max-length": 10,
"tooltip": true, "tooltip": true,
"tooltip-format": "RAM - {used:0.1f}GiB used" "tooltip-format": "RAM - {used:0.1f}GiB used",
}, },
"wlr/taskbar": { "wlr/taskbar": {
"format": "{icon} {title:.17}", "format": "{icon} {title:.17}",
@@ -58,11 +54,11 @@
"on-click-middle": "close", "on-click-middle": "close",
"tooltip-format": "{title}", "tooltip-format": "{title}",
"ignore-list": [], "ignore-list": [],
"on-click": "activate" "on-click": "activate",
}, },
"tray": { "tray": {
"icon-size": 18, "icon-size": 18,
"spacing": 3 "spacing": 3,
}, },
"clock": { "clock": {
"format": "{:%R | %d.%m.%Y}", "format": "{:%R | %d.%m.%Y}",
@@ -78,16 +74,16 @@
"days": "<span color='#ecc6d9'><b>{}</b></span>", "days": "<span color='#ecc6d9'><b>{}</b></span>",
"weeks": "<span color='#99ffdd'><b>W{}</b></span>", "weeks": "<span color='#99ffdd'><b>W{}</b></span>",
"weekdays": "<span color='#ffcc66'><b>{}</b></span>", "weekdays": "<span color='#ffcc66'><b>{}</b></span>",
"today": "<span color='#ff6699'><b><u>{}</u></b></span>" "today": "<span color='#ff6699'><b><u>{}</u></b></span>",
} },
}, },
"actions": { "actions": {
"on-click-right": "mode", "on-click-right": "mode",
"on-click-forward": "tz_up", "on-click-forward": "tz_up",
"on-click-backward": "tz_down", "on-click-backward": "tz_down",
"on-scroll-up": "shift_up", "on-scroll-up": "shift_up",
"on-scroll-down": "shift_down" "on-scroll-down": "shift_down",
} },
}, },
"network": { "network": {
"format-wifi": "{essid} ({signalStrength}%) {icon}", "format-wifi": "{essid} ({signalStrength}%) {icon}",
@@ -97,37 +93,19 @@
"tooltip-format-wifi": "{essid} ({signalStrength}%) ", "tooltip-format-wifi": "{essid} ({signalStrength}%) ",
"tooltip-format-ethernet": "{ifname} ", "tooltip-format-ethernet": "{ifname} ",
"tooltip-format-disconnected": "Disconnected", "tooltip-format-disconnected": "Disconnected",
"format-icons": [ "format-icons": ["󰤯 ", "󰤟 ", "󰤢 ", "󰤢 ", "󰤨 "],
"󰤯 ",
"󰤟 ",
"󰤢 ",
"󰤢 ",
"󰤨 "
]
}, },
"battery": { "battery": {
"states": { "states": {
"good": 95, "good": 95,
"warning": 30, "warning": 30,
"critical": 20 "critical": 20,
}, },
"format": "{icon} {capacity}%", "format": "{icon} {capacity}%",
"format-charging": " {capacity}%", "format-charging": " {capacity}%",
"format-plugged": " {capacity}%", "format-plugged": " {capacity}%",
"format-alt": "{time} {icon}", "format-alt": "{time} {icon}",
"format-icons": [ "format-icons": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
"󰂎",
"󰁺",
"󰁻",
"󰁼",
"󰁽",
"󰁾",
"󰁿",
"󰂀",
"󰂁",
"󰂂",
"󰁹"
]
}, },
"pulseaudio": { "pulseaudio": {
"format": "{volume}% {icon} ", "format": "{volume}% {icon} ",
@@ -143,16 +121,11 @@
"phone-muted": "", "phone-muted": "",
"portable": "", "portable": "",
"car": "", "car": "",
"default": [ "default": ["", ""],
"",
""
]
}, },
"scroll-step": 5, "scroll-step": 5,
"on-click": "pwvucontrol", "on-click": "pwvucontrol",
"ignored-sinks": [ "ignored-sinks": ["Easy Effects Sink"],
"Easy Effects Sink"
]
}, },
"privacy": { "privacy": {
"icon-spacing": 4, "icon-spacing": 4,
@@ -162,19 +135,19 @@
{ {
"type": "screenshare", "type": "screenshare",
"tooltip": true, "tooltip": true,
"tooltip-icon-size": 12 "tooltip-icon-size": 12,
}, },
{ {
"type": "audio-out", "type": "audio-out",
"tooltip": true, "tooltip": true,
"tooltip-icon-size": 12 "tooltip-icon-size": 12,
}, },
{ {
"type": "audio-in", "type": "audio-in",
"tooltip": true, "tooltip": true,
"tooltip-icon-size": 12 "tooltip-icon-size": 12,
} },
] ],
}, },
"mpris": { "mpris": {
"format": "{player_icon} {dynamic}", "format": "{player_icon} {dynamic}",
@@ -183,11 +156,11 @@
"ellipsis": "…", "ellipsis": "…",
"player-icons": { "player-icons": {
"default": "▶", "default": "▶",
"mpv": "🎵" "mpv": "🎵",
}, },
"status-icons": { "status-icons": {
"paused": "⏸" "paused": "⏸",
} },
}, },
"bluetooth": { "bluetooth": {
"format": " {status}", "format": " {status}",
@@ -197,13 +170,14 @@
"tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected", "tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected",
"tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}", "tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}",
"tooltip-format-enumerate-connected": "{device_alias}\t{device_address}", "tooltip-format-enumerate-connected": "{device_alias}\t{device_address}",
"tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%" "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%",
}, },
"custom/alhp": { "custom/alhp": {
"id": "custom-alhp",
"exec": "$HOME/.config/waybar/scripts/alhp.sh", "exec": "$HOME/.config/waybar/scripts/alhp.sh",
"format": "{} \uEB29 ",
"return-type": "json", "return-type": "json",
"interval": 60, "interval": 60,
"tooltip": true "tooltip": true,
} "format": "{text}",
},
} }

View File

@@ -191,10 +191,11 @@
"tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%" "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%"
}, },
"custom/alhp": { "custom/alhp": {
"id": "custom-alhp",
"exec": "$HOME/.config/waybar/scripts/alhp.sh", "exec": "$HOME/.config/waybar/scripts/alhp.sh",
"format": "{} \uEB29 ",
"return-type": "json", "return-type": "json",
"interval": 60, "interval": 60,
"tooltip": true "tooltip": true,
"format": "{text}",
} }
} }

View File

@@ -1,28 +1,41 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# Retrieve JSON output from alhp.utils. ALHP_OUTPUT=$(alhp.utils -j)
readonly ALHP_OUTPUT=$(alhp.utils -j) total=$(jq -r '.total' <<<"$ALHP_OUTPUT")
mirror_stale=$(jq -r '.mirror_out_of_date' <<<"$ALHP_OUTPUT")
# Extract "total" as a string and read "packages" into a Bash array. # defaults
readonly total=$(echo "$ALHP_OUTPUT" | jq -r '.total | tostring') text=""
readarray -t packages < <(echo "$ALHP_OUTPUT" | jq -r '.packages[]?') tooltip='All good'
# Initialize default tooltip and class.
tooltip=''
class='good' class='good'
# Use arithmetic evaluation to check if total is greater than 0. # safe array even if packages is null
if (( total > 0 )); then readarray -t packages < <(
class='bad' jq -r '.packages // [] | .[]' <<<"$ALHP_OUTPUT"
)
# 1) Mirror stale? highest priority
if [[ "$mirror_stale" == "true" ]]; then
class="stale"
tooltip="Mirror is out of date"
# 2) Any pending PKGBUILDs?
elif (( total > 0 )); then
class="bad"
text="$tooltip"
tooltip=$(printf "%s\n" "${packages[@]}")
fi fi
# If there are any packages, join them with newline as separator. case "$class" in
if (( ${#packages[@]} > 0 )); then good) icon="";;
tooltip=$(IFS=$'\n'; echo "${packages[*]}") stale) icon="󰏖";;
else bad) icon="󰏗";;
tooltip="All good" esac
fi
# Generate compact JSON output (all in one line) with jq. # Emit compact JSON for Statusbar
jq -nc --arg text "$total" --arg class "$class" --arg tooltip "$tooltip" \ jq -nc \
--arg text "$icon $text" \
--arg class "$class" \
--arg tooltip "$tooltip" \
'{text: $text, class: $class, tooltip: $tooltip}' '{text: $text, class: $class, tooltip: $tooltip}'

View File

@@ -1,9 +1,7 @@
/*base background color*/ /*base background color*/
@define-color bg_main rgba(25, 25, 25, 0.65); @define-color bg_main rgba(25, 25, 25, 0.65);
@define-color bg_main_tooltip rgba(0, 0, 0, 0.7); @define-color bg_main_tooltip rgba(0, 0, 0, 0.7);
/*base background color of selections */ /*base background color of selections */
@define-color bg_hover rgba(200, 200, 200, 0.3); @define-color bg_hover rgba(200, 200, 200, 0.3);
/*base background color of active elements */ /*base background color of active elements */
@@ -40,7 +38,7 @@ tooltip {
border-style: solid; border-style: solid;
border-color: @border_main; border-color: @border_main;
} }
tooltip label{ tooltip label {
color: @content_main; color: @content_main;
} }
@@ -74,13 +72,15 @@ tooltip label{
color: @content_main; color: @content_main;
} }
#cpu, #disk, #memory { #cpu,
#disk,
#memory {
border-bottom: 1px solid grey; border-bottom: 1px solid grey;
padding-right: 5px; padding-right: 5px;
padding-left: 5px; padding-left: 5px;
} }
#tray{ #tray {
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
} }
@@ -88,7 +88,6 @@ tooltip label{
border-bottom: none; border-bottom: none;
} }
#tray > .active { #tray > .active {
} }
#tray > .needs-attention { #tray > .needs-attention {
border-bottom: 3px solid @warning_color; border-bottom: 3px solid @warning_color;
@@ -197,6 +196,9 @@ tooltip label{
#custom-alhp.good { #custom-alhp.good {
border-bottom: 1px solid greenyellow; border-bottom: 1px solid greenyellow;
} }
#custom-alhp.stale {
border-bottom: 1px solid yellow;
}
#custom-alhp.bad { #custom-alhp.bad {
border-bottom: 1px solid orangered; border-bottom: 1px solid orangered;
} }

View File

@@ -197,6 +197,9 @@ tooltip label{
#custom-alhp.good { #custom-alhp.good {
border-bottom: 1px solid greenyellow; border-bottom: 1px solid greenyellow;
} }
#custom-alhp.stale {
border-bottom: 1px solid yellow;
}
#custom-alhp.bad { #custom-alhp.bad {
border-bottom: 1px solid orangered; border-bottom: 1px solid orangered;
} }