From c0b6da7bc7629adb64cc94333bf76e1f9e1536f9 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Thu, 12 Nov 2026 09:04:28 -0500 Subject: [PATCH] omamobile-shell 0.2.127: the Do Not Disturb tile and home toggle read Omarchy 4.5's state The quick-settings tile and the home screen's toggle read Do Not Disturb with the notification service's dndState call. Omarchy 4.5 renamed it to isDnd and answers "Function not found" to the old name, so on 4.5 both kept whatever state they started with: turning Do Not Disturb on from anywhere else never showed. Setting it from the tile still worked, since setDnd kept its name. Both now run one line that asks isDnd first and dndState second, so 4.0 phones are unchanged. test/dnd-state.sh takes that line from the QML and runs it against a stand-in for each service. On the Pixel 7 Pro (Omarchy 4.5.0-3): `notifications dndState` answers "Function not found." and `isDnd` answers "off". The changed tile has not been run on the phone. Found by the round 53 review of #652. Co-Authored-By: Claude Fable 5.2 --- .../plugins/omamobile.home/TogglesWidget.qml | 3 +- .../omamobile.quicksettings/QuickSettings.qml | 4 ++- packages/omamobile-shell/test/all | 1 + packages/omamobile-shell/test/dnd-state.sh | 36 +++++++++++++++++++ packages/omamobile-shell/version | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 packages/omamobile-shell/test/dnd-state.sh diff --git a/packages/omamobile-shell/plugins/omamobile.home/TogglesWidget.qml b/packages/omamobile-shell/plugins/omamobile.home/TogglesWidget.qml index 4abfe86aa..389a8b3b8 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/TogglesWidget.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/TogglesWidget.qml @@ -52,7 +52,8 @@ Item { Process { id: dndProc - command: widget.ipc(["notifications", "dndState"]) + // isDnd on Omarchy 4.5, dndState on 4.0 (QuickSettings.qml has the same line) + command: ["sh", "-c", "for m in isDnd dndState; do v=$(qs ipc -p \"$1\" call notifications $m 2>/dev/null); case $v in on|off) echo $v; exit 0;; esac; done", "sh", Quickshell.shellDir] stdout: StdioCollector { waitForEnd: true onStreamFinished: { diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index 55fef7ff1..46c1d6757 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -814,7 +814,9 @@ Item { function refreshDnd() { if (dndProc.running) return - dndProc.command = ["qs", "ipc", "-p", Quickshell.shellDir, "call", "notifications", "dndState"] + // Omarchy 4.5 calls the read isDnd; 4.0 called it dndState, and each + // answers "Function not found" to the other's name. Ask 4.5's first. + dndProc.command = ["sh", "-c", "for m in isDnd dndState; do v=$(qs ipc -p \"$1\" call notifications $m 2>/dev/null); case $v in on|off) echo $v; exit 0;; esac; done", "sh", Quickshell.shellDir] dndProc.running = true } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 1a41a1b11..30dcb5f16 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -1228,6 +1228,7 @@ pass "install stages the package" test/keys.sh || fail "omamobile-keys volume keys" test/home-command.sh || fail "omamobile-home" test/reboot-command.sh || fail "omamobile-reboot" +bash test/dnd-state.sh || fail "the Do Not Disturb read on Omarchy 4.5 and 4.0" # Every surface on Back's list, and the order, in Qt. rc=0; out=$(python3 -B test/back-surfaces.py 2>&1) || rc=$? diff --git a/packages/omamobile-shell/test/dnd-state.sh b/packages/omamobile-shell/test/dnd-state.sh new file mode 100755 index 000000000..63d3ef05c --- /dev/null +++ b/packages/omamobile-shell/test/dnd-state.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# The Do Not Disturb read in the quick-settings tile and the home toggles, +# against a stand-in `qs`: Omarchy 4.5's notification service answers isDnd +# and says "Function not found" to 4.0's dndState, and 4.0's the other way +# round. Both callers run the same line, taken here from the QML itself. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +line() { + python3 - "$1" <<'PY' +import json, re, sys +m = re.search(r'\["sh", "-c", ("(?:[^"\\]|\\.)*"), "sh", Quickshell\.shellDir\]', open(sys.argv[1]).read().split("isDnd", 1)[0][-400:] + "isDnd" + open(sys.argv[1]).read().split("isDnd", 1)[1][:400]) +if not m: sys.exit("no Do Not Disturb read in " + sys.argv[1]) +print(json.loads(m.group(1)), end="") +PY +} +qs_line=$(line plugins/omamobile.quicksettings/QuickSettings.qml) || fail "found the tile's read" +home_line=$(line plugins/omamobile.home/TogglesWidget.qml) || fail "found the home toggles' read" +[[ $qs_line == "$home_line" ]] || fail "the tile and the home toggles read Do Not Disturb the same way" +mkdir -p "$t/bin" +cat > "$t/bin/qs" <<'QS' +#!/bin/sh +# qs ipc -p DIR call notifications METHOD +echo "$6" >> "$T/calls" +if [ "$6" = "$HAVE" ]; then echo "$STATE"; else echo "Function not found."; fi +QS +chmod +x "$t/bin/qs" +ask() { : > "$t/calls"; T=$t HAVE=$1 STATE=$2 PATH="$t/bin:$PATH" sh -c "$qs_line" sh /some/dir; } +[[ $(ask isDnd on) == on && $(cat "$t/calls") == isDnd ]] || fail "Omarchy 4.5: isDnd is asked first and its answer is used" +[[ $(ask isDnd off) == off ]] || fail "Omarchy 4.5: off is read as off" +[[ $(ask dndState on) == on && $(tr '\n' ' ' < "$t/calls") == "isDnd dndState " ]] || fail "Omarchy 4.0: dndState is asked when isDnd isn't there" +[[ -z $(ask neither on) ]] || fail "neither name: nothing is printed, so the tile keeps its state" +pass "Do Not Disturb is read with isDnd on Omarchy 4.5 and dndState on 4.0, the same way in both places" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index 6cf0bd9e1..4f079a5e5 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.126 +0.2.127