Vendor the command set the menu and shell depend on

This commit is contained in:
2026-09-19 23:57:12 -04:00
parent 9501f2bb4d
commit c5434026a8
179 changed files with 12414 additions and 54 deletions
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
# blob:summary=Toggle nightlight screen temperature
# blob:args=[--status]
# blob:examples=blob toggle nightlight
ON_TEMP=4000
OFF_TEMP=6500
IDENTITY_TEMP=6000
current_temp() {
local output
output=$(hyprctl hyprsunset temperature 2>/dev/null) || return
grep -oE '[0-9]+' <<<"$output" | head -n1
}
status_json() {
local temp enabled
temp=$(current_temp)
if [[ -n $temp ]] && (( temp < IDENTITY_TEMP )); then
enabled=true
else
enabled=false
fi
jq -cn --argjson enabled "$enabled" --arg temp "$temp" \
'{enabled:$enabled, temperature:(($temp | tonumber?) // null)}'
}
if [[ ${1:-} == "--status" ]]; then
status_json
exit 0
fi
# Ensure hyprsunset is running
if ! pgrep -x hyprsunset >/dev/null; then
setsid uwsm-app -- hyprsunset &
fi
# Query the current temperature
CURRENT_TEMP=$(current_temp)
if [[ -z $CURRENT_TEMP || $CURRENT_TEMP == $OFF_TEMP ]]; then
TARGET_TEMP=$ON_TEMP
else
TARGET_TEMP=$OFF_TEMP
fi
# A freshly-started hyprsunset applies its default temperature at the end of
# its boot, overriding anything set before then — so resend until it sticks
for _ in {1..10}; do
hyprctl hyprsunset temperature $TARGET_TEMP >/dev/null 2>&1
sleep 0.2
[[ $(current_temp) == "$TARGET_TEMP" ]] && break
done
blob-shell -q nightlight refresh