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