Add Panama commands to the launcher
This commit is contained in:
@@ -91,4 +91,8 @@ run_helper media next
|
||||
assert_line 'playerctl <next>'
|
||||
assert_line 'qs <ipc> <call> <osd> <message> <media-next> <Horizon — Tycho>'
|
||||
|
||||
: >"$log"
|
||||
run_helper message notifications-disabled-symbolic 'Do Not Disturb On'
|
||||
assert_line 'qs <ipc> <call> <osd> <message> <notifications-disabled-symbolic> <Do Not Disturb On>'
|
||||
|
||||
printf 'osd helper contract: PASS\n'
|
||||
|
||||
Executable
+152
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
dispatcher="$repo_dir/config/dot/quickshell/scripts/panama-action"
|
||||
work="$(mktemp -d /tmp/panama-action.XXXXXX)"
|
||||
fake_bin="$work/bin"
|
||||
command_log="$work/commands.log"
|
||||
|
||||
fail() {
|
||||
printf 'Panama action contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$work"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
[[ -x "$dispatcher" ]] || fail 'dispatcher is missing or not executable'
|
||||
|
||||
mkdir -p "$fake_bin" "$work/home/.config/quickshell/scripts"
|
||||
|
||||
make_recorder() {
|
||||
local command_name="$1"
|
||||
cp /dev/stdin "$fake_bin/$command_name"
|
||||
chmod +x "$fake_bin/$command_name"
|
||||
}
|
||||
|
||||
make_recorder qs <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'qs' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
case "$*" in
|
||||
'ipc call notifications dnd'|'ipc call caffeine toggle'|'ipc call night-light toggle')
|
||||
printf '%s\n' "${PANAMA_ACTION_TEST_STATE:-true}"
|
||||
;;
|
||||
esac
|
||||
[[ ${PANAMA_ACTION_TEST_FAIL_QS:-false} != true ]]
|
||||
EOF
|
||||
|
||||
make_recorder quickshell <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'quickshell' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder panama-osd <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'panama-osd' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder panama-prism-gallery <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'panama-prism-gallery' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
if (( $# > 0 )); then
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
fi
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
make_recorder notify-send <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'notify-send' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_ACTION_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_ACTION_TEST_LOG"
|
||||
EOF
|
||||
|
||||
run_action() {
|
||||
: >"$command_log"
|
||||
HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" "$1"
|
||||
}
|
||||
|
||||
assert_commands() {
|
||||
local expected="$1"
|
||||
local actual
|
||||
actual="$(cat "$command_log")"
|
||||
[[ "$actual" == "$expected" ]] \
|
||||
|| fail "wrong command sequence; expected [$expected], got [$actual]"
|
||||
}
|
||||
|
||||
run_action control-center
|
||||
assert_commands 'qs <ipc> <call> <quicksettings> <open>'
|
||||
|
||||
run_action notifications
|
||||
assert_commands 'qs <ipc> <call> <notifications> <open>'
|
||||
|
||||
run_action calendar
|
||||
assert_commands 'qs <ipc> <call> <calendar-agenda> <open>'
|
||||
|
||||
run_action clipboard
|
||||
assert_commands 'qs <ipc> <call> <clipboard> <open>'
|
||||
|
||||
run_action overview
|
||||
assert_commands 'qs <ipc> <call> <overview> <open>'
|
||||
|
||||
run_action settings
|
||||
assert_commands 'qs <ipc> <call> <settings> <open>'
|
||||
|
||||
run_action dnd
|
||||
assert_commands $'qs <ipc> <call> <notifications> <dnd>\npanama-osd <message> <notifications-disabled-symbolic> <Do Not Disturb On>'
|
||||
|
||||
PANAMA_ACTION_TEST_STATE=false run_action caffeine
|
||||
assert_commands $'qs <ipc> <call> <caffeine> <toggle>\npanama-osd <message> <weather-clear-night-symbolic> <Caffeine Off>'
|
||||
|
||||
run_action night-light
|
||||
assert_commands $'qs <ipc> <call> <night-light> <toggle>\npanama-osd <message> <night-light-symbolic> <Night Light On>'
|
||||
|
||||
run_action focus-start
|
||||
assert_commands $'qs <ipc> <call> <focus> <start>\npanama-osd <message> <preferences-system-time-symbolic> <Focus Session Started>'
|
||||
|
||||
run_action focus-end
|
||||
assert_commands $'qs <ipc> <call> <focus> <end>\npanama-osd <message> <media-playback-stop-symbolic> <Focus Session Ended>'
|
||||
|
||||
run_action capture
|
||||
assert_commands 'qs <ipc> <call> <capture> <open>'
|
||||
|
||||
run_action intelligence
|
||||
assert_commands 'qs <ipc> <call> <screen-intelligence> <open>'
|
||||
|
||||
run_action screenshot
|
||||
assert_commands 'qs <ipc> <call> <capture> <screenNow>'
|
||||
|
||||
run_action microphone
|
||||
assert_commands 'panama-osd <microphone> <toggle>'
|
||||
|
||||
run_action gallery
|
||||
assert_commands 'panama-prism-gallery'
|
||||
|
||||
run_action restart-shell
|
||||
assert_commands $'qs <kill>\nquickshell <--daemonize>'
|
||||
|
||||
if HOME="$work/home" PATH="$fake_bin:$PATH" PANAMA_ACTION_TEST_LOG="$command_log" \
|
||||
"$dispatcher" definitely-not-an-action >/dev/null 2>&1; then
|
||||
fail 'unknown action was accepted'
|
||||
fi
|
||||
|
||||
: >"$command_log"
|
||||
if PANAMA_ACTION_TEST_FAIL_QS=true HOME="$work/home" PATH="$fake_bin:$PATH" \
|
||||
PANAMA_ACTION_TEST_LOG="$command_log" "$dispatcher" control-center >/dev/null 2>&1; then
|
||||
fail 'failed shell action returned success'
|
||||
fi
|
||||
assert_commands $'qs <ipc> <call> <quicksettings> <open>\nnotify-send <-a> <Panama> <-i> <dialog-error-symbolic> <Panama action failed> <The “control center” action could not be completed.>'
|
||||
|
||||
printf 'Panama action contract: PASS\n'
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
fail() {
|
||||
printf 'Panama action IPC contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
active_target=""
|
||||
original_state=""
|
||||
|
||||
restore_target() {
|
||||
local target="$1" expected="$2" current
|
||||
current="$(qs ipc call "$target" status 2>/dev/null || true)"
|
||||
if [[ $current != "$expected" && ( $expected == true || $expected == false ) ]]; then
|
||||
qs ipc call "$target" toggle >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if [[ -n $active_target ]]; then
|
||||
restore_target "$active_target" "$original_state"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
exercise_toggle() {
|
||||
local target="$1" before after restored
|
||||
before="$(qs ipc call "$target" status)"
|
||||
active_target="$target"
|
||||
original_state="$before"
|
||||
|
||||
[[ $before == true || $before == false ]] \
|
||||
|| fail "$target returned a non-boolean status: $before"
|
||||
|
||||
after="$(qs ipc call "$target" toggle)"
|
||||
[[ $after != "$before" ]] \
|
||||
|| fail "$target did not change state: before=$before after=$after"
|
||||
|
||||
restored="$(qs ipc call "$target" toggle)"
|
||||
[[ $restored == "$before" ]] \
|
||||
|| fail "$target did not restore its original state: before=$before restored=$restored"
|
||||
|
||||
active_target=""
|
||||
original_state=""
|
||||
}
|
||||
|
||||
ipc="$(qs ipc show)"
|
||||
rg -q '^target caffeine$' <<<"$ipc" || fail 'caffeine IPC target is missing'
|
||||
rg -q '^target night-light$' <<<"$ipc" || fail 'night-light IPC target is missing'
|
||||
|
||||
exercise_toggle caffeine
|
||||
exercise_toggle night-light
|
||||
|
||||
printf 'Panama action IPC contract: PASS\n'
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
installer="$repo_dir/setup/scripts/link-vicinae-scripts"
|
||||
work="$(mktemp -d /tmp/panama-command-install.XXXXXX)"
|
||||
data_dir="$work/share/vicinae"
|
||||
fake_bin="$work/bin"
|
||||
vicinae_log="$work/vicinae.log"
|
||||
|
||||
fail() {
|
||||
printf 'Panama command install contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$work"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
[[ -x "$installer" ]] || fail 'Vicinae script installer is missing or not executable'
|
||||
|
||||
mkdir -p "$data_dir/scripts/panama" "$fake_bin"
|
||||
printf 'user-owned\n' >"$data_dir/scripts/panama/keep.sh"
|
||||
|
||||
cat >"$fake_bin/vicinae" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'vicinae' >>"$PANAMA_VICINAE_TEST_LOG"
|
||||
printf ' <%s>' "$@" >>"$PANAMA_VICINAE_TEST_LOG"
|
||||
printf '\n' >>"$PANAMA_VICINAE_TEST_LOG"
|
||||
[[ ${1:-} == ping || ${1:-} == cmd ]]
|
||||
EOF
|
||||
chmod +x "$fake_bin/vicinae"
|
||||
|
||||
PATH="$fake_bin:$PATH" PANAMA_PATH="$repo_dir" VICINAE_DATA_DIR="$data_dir" \
|
||||
PANAMA_VICINAE_TEST_LOG="$vicinae_log" "$installer" >/dev/null
|
||||
|
||||
target="$data_dir/scripts/panama"
|
||||
backup="$data_dir/scripts/panama.pre-panama"
|
||||
[[ -L "$target" ]] || fail 'Panama command directory was not linked'
|
||||
[[ "$(readlink -f "$target")" == "$(readlink -f "$repo_dir/config/local/share/vicinae/scripts")" ]] \
|
||||
|| fail 'runtime command link points outside the tracked source'
|
||||
[[ -f "$backup/keep.sh" ]] || fail 'pre-existing user command directory was not preserved'
|
||||
[[ "$(cat "$backup/keep.sh")" == user-owned ]] || fail 'preserved user command changed'
|
||||
|
||||
expected_calls=$'vicinae <ping>\nvicinae <cmd> <launch> <core:reload-scripts>'
|
||||
[[ "$(cat "$vicinae_log")" == "$expected_calls" ]] \
|
||||
|| fail "Vicinae reload sequence was wrong: $(cat "$vicinae_log")"
|
||||
|
||||
# A second setup pass must update the same narrow link without creating more
|
||||
# backups or disturbing the preserved directory.
|
||||
: >"$vicinae_log"
|
||||
PATH="$fake_bin:$PATH" PANAMA_PATH="$repo_dir" VICINAE_DATA_DIR="$data_dir" \
|
||||
PANAMA_VICINAE_TEST_LOG="$vicinae_log" "$installer" >/dev/null
|
||||
[[ -L "$target" ]] || fail 'second install did not leave the command link intact'
|
||||
[[ -f "$backup/keep.sh" ]] || fail 'second install disturbed the original backup'
|
||||
[[ ! -e "$data_dir/scripts/panama.pre-panama.pre-panama" ]] \
|
||||
|| fail 'second install created a duplicate backup'
|
||||
|
||||
printf 'Panama command install contract: PASS\n'
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
commands_dir="$repo_dir/config/local/share/vicinae/scripts"
|
||||
work="$(mktemp -d /tmp/panama-commands.XXXXXX)"
|
||||
dispatch_log="$work/dispatch.log"
|
||||
|
||||
fail() {
|
||||
printf 'Panama commands contract: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$work"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
declare -A expected=(
|
||||
[open-control-center.sh]=control-center
|
||||
[open-notifications.sh]=notifications
|
||||
[open-calendar.sh]=calendar
|
||||
[open-clipboard.sh]=clipboard
|
||||
[open-mission-control.sh]=overview
|
||||
[open-settings.sh]=settings
|
||||
[toggle-dnd.sh]=dnd
|
||||
[toggle-caffeine.sh]=caffeine
|
||||
[toggle-night-light.sh]=night-light
|
||||
[start-focus.sh]=focus-start
|
||||
[end-focus.sh]=focus-end
|
||||
[capture.sh]=capture
|
||||
[screen-intelligence.sh]=intelligence
|
||||
[quick-screenshot.sh]=screenshot
|
||||
[toggle-microphone.sh]=microphone
|
||||
[open-prism-gallery.sh]=gallery
|
||||
[restart-shell.sh]=restart-shell
|
||||
)
|
||||
|
||||
mkdir -p "$work/home/.config/quickshell/scripts"
|
||||
cat >"$work/home/.config/quickshell/scripts/panama-action" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf '%s\n' "$*" >>"$PANAMA_COMMAND_TEST_LOG"
|
||||
EOF
|
||||
chmod +x "$work/home/.config/quickshell/scripts/panama-action"
|
||||
|
||||
[[ -d "$commands_dir" ]] || fail 'Vicinae command directory is missing'
|
||||
|
||||
mapfile -t actual_files < <(find "$commands_dir" -maxdepth 1 -type f -name '*.sh' -printf '%f\n' | sort)
|
||||
[[ ${#actual_files[@]} -eq ${#expected[@]} ]] \
|
||||
|| fail "expected ${#expected[@]} commands, found ${#actual_files[@]}"
|
||||
|
||||
declare -A seen_titles=()
|
||||
for script_name in "${!expected[@]}"; do
|
||||
script="$commands_dir/$script_name"
|
||||
[[ -x "$script" ]] || fail "$script_name is missing or not executable"
|
||||
|
||||
vicinae script check "$script" >/dev/null \
|
||||
|| fail "$script_name is rejected by Vicinae"
|
||||
|
||||
title="$(sed -n 's/^# @vicinae.title //p' "$script")"
|
||||
[[ $title == 'Panama: '* ]] || fail "$script_name has an ungrouped title: $title"
|
||||
[[ -z ${seen_titles[$title]+x} ]] || fail "duplicate launcher title: $title"
|
||||
seen_titles[$title]=1
|
||||
|
||||
grep -Fxq '# @vicinae.mode silent' "$script" \
|
||||
|| fail "$script_name does not close quietly after success"
|
||||
grep -Fq '# @vicinae.description ' "$script" \
|
||||
|| fail "$script_name has no searchable description"
|
||||
grep -Fq '# @vicinae.keywords ' "$script" \
|
||||
|| fail "$script_name has no search vocabulary"
|
||||
grep -Fxq '# @vicinae.icon ../../icons/hicolor/scalable/apps/panama-settings.svg' "$script" \
|
||||
|| fail "$script_name does not use the Panama application identity"
|
||||
|
||||
: >"$dispatch_log"
|
||||
HOME="$work/home" PANAMA_COMMAND_TEST_LOG="$dispatch_log" "$script"
|
||||
dispatched="$(cat "$dispatch_log")"
|
||||
[[ $dispatched == "${expected[$script_name]}" ]] \
|
||||
|| fail "$script_name dispatched [$dispatched], expected [${expected[$script_name]}]"
|
||||
done
|
||||
|
||||
printf 'Panama commands contract: PASS (%d commands)\n' "${#expected[@]}"
|
||||
Reference in New Issue
Block a user