Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions packages/omamobile-shell/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -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=$?
Expand Down
36 changes: 36 additions & 0 deletions packages/omamobile-shell/test/dnd-state.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion packages/omamobile-shell/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.126
0.2.127