Add idle lock indicator

This commit is contained in:
David Heinemeier Hansson
2026-02-20 16:48:36 +01:00
parent 87600497da
commit bf962f0042
5 changed files with 62 additions and 3 deletions
+2
View File
@@ -7,3 +7,5 @@ else
uwsm-app -- hypridle >/dev/null 2>&1 &
notify-send "Now locking computer when idle"
fi
pkill -RTMIN+9 waybar
+7 -1
View File
@@ -5,7 +5,7 @@
"spacing": 0,
"height": 26,
"modules-left": ["custom/omarchy", "hyprland/workspaces"],
"modules-center": ["clock", "custom/update", "custom/voxtype", "custom/screenrecording-indicator"],
"modules-center": ["clock", "custom/update", "custom/voxtype", "custom/screenrecording-indicator", "custom/idle-indicator"],
"modules-right": [
"group/tray-expander",
"bluetooth",
@@ -142,6 +142,12 @@
"signal": 8,
"return-type": "json"
},
"custom/idle-indicator": {
"on-click": "omarchy-toggle-idle",
"exec": "$OMARCHY_PATH/default/waybar/indicators/idle.sh",
"signal": 9,
"return-type": "json"
},
"custom/voxtype": {
"exec": "omarchy-voxtype-status",
"return-type": "json",
+7 -2
View File
@@ -34,7 +34,6 @@
#battery,
#pulseaudio,
#custom-omarchy,
#custom-screenrecording-indicator,
#custom-update {
min-width: 12px;
margin: 0 7.5px;
@@ -72,9 +71,11 @@ tooltip {
opacity: 0;
}
#custom-screenrecording-indicator {
#custom-screenrecording-indicator,
#custom-idle-indicator {
min-width: 12px;
margin-left: 5px;
margin-right: 0;
font-size: 10px;
padding-bottom: 1px;
}
@@ -83,6 +84,10 @@ tooltip {
color: #a55555;
}
#custom-idle-indicator.active {
color: #a55555;
}
#custom-voxtype {
min-width: 12px;
margin: 0 0 0 7.5px;
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
if pgrep -x hypridle >/dev/null; then
echo '{"text": ""}'
else
echo '{"text": "󱫖", "tooltip": "Idle lock disabled", "class": "active"}'
fi
+39
View File
@@ -0,0 +1,39 @@
echo "Add idle lock indicator to Waybar"
STYLE_FILE=~/.config/waybar/style.css
CONFIG_FILE=~/.config/waybar/config.jsonc
# Add idle-indicator to modules-center if not present
if ! grep -q "custom/idle-indicator" "$CONFIG_FILE"; then
sed -i 's/"custom\/screenrecording-indicator"]/"custom\/screenrecording-indicator", "custom\/idle-indicator"]/' "$CONFIG_FILE"
sed -i '/"tray": {/i\ "custom/idle-indicator": {\n "on-click": "omarchy-toggle-idle",\n "exec": "$OMARCHY_PATH/default/waybar/indicators/idle.sh",\n "signal": 9,\n "return-type": "json"\n },' "$CONFIG_FILE"
fi
# Add idle-indicator CSS if not present
if ! grep -q "#custom-idle-indicator" "$STYLE_FILE"; then
# Remove screenrecording-indicator from shared margin block and pair it with idle-indicator instead
sed -i 's/^#custom-screenrecording-indicator,$//' "$STYLE_FILE"
# Add shared rule for both indicators and idle-indicator active state
sed -i '/#custom-screenrecording-indicator.active {/i\#custom-screenrecording-indicator,\n#custom-idle-indicator {\n min-width: 12px;\n margin-left: 5px;\n margin-right: 0;\n font-size: 10px;\n padding-bottom: 1px;\n}\n' "$STYLE_FILE"
# Remove the now-duplicated properties from the standalone screenrecording block
sed -i '/#custom-screenrecording-indicator {/,/^}/ {
/min-width:/d
/margin-left:/d
/font-size:/d
/padding-bottom:/d
/^#custom-screenrecording-indicator {/d
/^}$/d
}' "$STYLE_FILE"
cat >> "$STYLE_FILE" << 'EOF'
#custom-idle-indicator.active {
color: #a55555;
}
EOF
fi
omarchy-restart-waybar