Fix night light indicator state
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
ON_TEMP=4000
|
ON_TEMP=4000
|
||||||
OFF_TEMP=6500
|
OFF_TEMP=6500
|
||||||
|
IDENTITY_TEMP=6000
|
||||||
|
|
||||||
current_temp() {
|
current_temp() {
|
||||||
local output
|
local output
|
||||||
@@ -18,7 +19,7 @@ status_json() {
|
|||||||
local temp enabled
|
local temp enabled
|
||||||
|
|
||||||
temp=$(current_temp)
|
temp=$(current_temp)
|
||||||
if [[ -n $temp && $temp != $OFF_TEMP ]]; then
|
if [[ -n $temp ]] && (( temp < IDENTITY_TEMP )); then
|
||||||
enabled=true
|
enabled=true
|
||||||
else
|
else
|
||||||
enabled=false
|
enabled=false
|
||||||
@@ -48,4 +49,4 @@ else
|
|||||||
hyprctl hyprsunset temperature $OFF_TEMP
|
hyprctl hyprsunset temperature $OFF_TEMP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
omarchy-shell -q Indicators refresh
|
omarchy-shell -q omarchy.indicators refresh
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ WidgetButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncIndicatorOpacity() {
|
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()
|
Component.onCompleted: syncIndicatorOpacity()
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ BarIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
|
nightlight = !nightlight
|
||||||
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
|
if (root.bar) root.bar.run("omarchy-toggle-nightlight")
|
||||||
refreshTimer.restart()
|
refreshTimer.restart()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
Reference in New Issue
Block a user