Fix night light indicator state

This commit is contained in:
David Heinemeier Hansson
2026-05-29 09:42:24 +02:00
parent c795d52201
commit 6be9b8b6d9
4 changed files with 44 additions and 3 deletions
+3 -2
View File
@@ -6,6 +6,7 @@
ON_TEMP=4000
OFF_TEMP=6500
IDENTITY_TEMP=6000
current_temp() {
local output
@@ -18,7 +19,7 @@ status_json() {
local temp enabled
temp=$(current_temp)
if [[ -n $temp && $temp != $OFF_TEMP ]]; then
if [[ -n $temp ]] && (( temp < IDENTITY_TEMP )); then
enabled=true
else
enabled=false
@@ -48,4 +49,4 @@ else
hyprctl hyprsunset temperature $OFF_TEMP
fi
omarchy-shell -q Indicators refresh
omarchy-shell -q omarchy.indicators refresh
+1 -1
View File
@@ -22,7 +22,7 @@ WidgetButton {
}
function syncIndicatorOpacity() {
root.opacity = !belongsInBlock ? 0 : (active ? 1 : (inactiveRevealed ? 0.45 : 0))
root.opacity = !belongsInBlock ? 0 : (effectiveActive ? 1 : (inactiveRevealed ? 0.45 : 0))
}
Component.onCompleted: syncIndicatorOpacity()
@@ -23,6 +23,7 @@ BarIndicator {
}
function toggle() {
nightlight = !nightlight
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
refreshTimer.restart()
}
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
mkdir -p "$TMPDIR/bin"
cat >"$TMPDIR/bin/hyprctl" <<'SH'
#!/bin/bash
if [[ ${1:-} == "hyprsunset" && ${2:-} == "temperature" ]]; then
printf '%s\n' "${HYPRSUNSET_TEMP:-6500}"
exit 0
fi
exit 1
SH
chmod +x "$TMPDIR/bin/hyprctl"
nightlight_status() {
HYPRSUNSET_TEMP="$1" PATH="$TMPDIR/bin:$PATH" "$ROOT/bin/omarchy-toggle-nightlight" --status
}
[[ $(nightlight_status 4000 | jq -r .enabled) == "true" ]] || fail "nightlight status reports 4000K as enabled"
pass "nightlight status reports 4000K as enabled"
[[ $(nightlight_status 5999 | jq -r .enabled) == "true" ]] || fail "nightlight status reports warmer-than-identity values as enabled"
pass "nightlight status reports warmer-than-identity values as enabled"
[[ $(nightlight_status 6000 | jq -r .enabled) == "false" ]] || fail "nightlight status reports identity temperature as disabled"
pass "nightlight status reports identity temperature as disabled"
[[ $(nightlight_status 6500 | jq -r .enabled) == "false" ]] || fail "nightlight status reports daylight temperature as disabled"
pass "nightlight status reports daylight temperature as disabled"