diff --git a/bin/omarchy-toggle-nightlight b/bin/omarchy-toggle-nightlight index cf7463b6..3db4e41f 100755 --- a/bin/omarchy-toggle-nightlight +++ b/bin/omarchy-toggle-nightlight @@ -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 diff --git a/shell/Ui/BarIndicator.qml b/shell/Ui/BarIndicator.qml index 81b45a29..8a628f70 100644 --- a/shell/Ui/BarIndicator.qml +++ b/shell/Ui/BarIndicator.qml @@ -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() diff --git a/shell/plugins/bar/indicators/NightLight.qml b/shell/plugins/bar/indicators/NightLight.qml index e8f3b43c..9fadf12d 100644 --- a/shell/plugins/bar/indicators/NightLight.qml +++ b/shell/plugins/bar/indicators/NightLight.qml @@ -23,6 +23,7 @@ BarIndicator { } function toggle() { + nightlight = !nightlight if (root.bar) root.bar.run("omarchy-toggle-nightlight") refreshTimer.restart() } diff --git a/test/shell.d/nightlight-test.sh b/test/shell.d/nightlight-test.sh new file mode 100644 index 00000000..a075d5b7 --- /dev/null +++ b/test/shell.d/nightlight-test.sh @@ -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"