added monitor layout icon to waybar when external monitors are connected

This commit is contained in:
2026-09-13 00:38:21 -06:00
parent dd7868e732
commit 315b19970d
3 changed files with 67 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# monitor-status: waybar module for external display layout.
#
# Emits a JSON update on stdout every couple of seconds so the module appears
# as soon as an external (non-eDP/HEADLESS) monitor is detected and collapses
# again when it is disconnected. Clicking the icon opens monique to manage the
# display layout.
#
# Outputs (return-type json):
# connected: { "text": "󰍹", "class": "active", "tooltip": "<monitor list>" }
# otherwise: { "text": "", "class": "hidden", "tooltip": "" }
set -uo pipefail
POLL_SECONDS=2
emit() {
local out_json
out_json="$(hyprctl monitors -j 2>/dev/null)" || {
echo '{"text":"","class":"hidden","tooltip":""}'
return
}
jq -c '
[.[] | select((.name | test("^(eDP|HEADLESS)-")) | not)] as $ext |
if ($ext | length) == 0 then
{ text: "", class: "hidden", tooltip: "" }
else
{ text: "󰍹",
class: "active",
tooltip: (($ext | map("\(.description) \(.width)x\(.height) @ \(.refreshRate | floor) Hz") | join("\n"))) }
end
' <<<"$out_json" 2>/dev/null || echo '{"text":"","class":"hidden","tooltip":""}'
}
while true; do
emit
sleep "$POLL_SECONDS"
done