Add Panama commands to the launcher
This commit is contained in:
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# One stable command boundary for launcher actions. Vicinae scripts stay tiny,
|
||||
# while the actual mapping to Quickshell IPC remains testable in one place.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
action="${1:-}"
|
||||
|
||||
if command -v panama-osd >/dev/null 2>&1; then
|
||||
osd_command=(panama-osd)
|
||||
else
|
||||
osd_command=("$script_dir/panama-osd")
|
||||
fi
|
||||
|
||||
if command -v panama-prism-gallery >/dev/null 2>&1; then
|
||||
gallery_command=(panama-prism-gallery)
|
||||
else
|
||||
gallery_command=("$script_dir/panama-prism-gallery")
|
||||
fi
|
||||
|
||||
report_failure() {
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
if (( status != 0 )) && command -v notify-send >/dev/null 2>&1; then
|
||||
notify-send -a Panama -i dialog-error-symbolic \
|
||||
"Panama action failed" \
|
||||
"The “${action//-/ }” action could not be completed." || true
|
||||
fi
|
||||
exit "$status"
|
||||
}
|
||||
trap report_failure EXIT
|
||||
|
||||
show_state() {
|
||||
local state="$1" on_icon="$2" off_icon="$3" label="$4"
|
||||
case "$state" in
|
||||
true) "${osd_command[@]}" message "$on_icon" "$label On" ;;
|
||||
false) "${osd_command[@]}" message "$off_icon" "$label Off" ;;
|
||||
*)
|
||||
printf 'Panama action returned an invalid state: %s\n' "$state" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
toggle_state() {
|
||||
local target="$1" on_icon="$2" off_icon="$3" label="$4" state
|
||||
state="$(qs ipc call "$target" toggle)"
|
||||
show_state "$state" "$on_icon" "$off_icon" "$label"
|
||||
}
|
||||
|
||||
case "$action" in
|
||||
control-center) qs ipc call quicksettings open ;;
|
||||
notifications) qs ipc call notifications open ;;
|
||||
calendar) qs ipc call calendar-agenda open ;;
|
||||
clipboard) qs ipc call clipboard open ;;
|
||||
overview) qs ipc call overview open ;;
|
||||
settings) qs ipc call settings open ;;
|
||||
|
||||
dnd)
|
||||
state="$(qs ipc call notifications dnd)"
|
||||
show_state "$state" notifications-disabled-symbolic notifications-symbolic "Do Not Disturb"
|
||||
;;
|
||||
caffeine)
|
||||
toggle_state caffeine weather-clear-symbolic weather-clear-night-symbolic Caffeine
|
||||
;;
|
||||
night-light)
|
||||
toggle_state night-light night-light-symbolic night-light-disabled-symbolic "Night Light"
|
||||
;;
|
||||
focus-start)
|
||||
qs ipc call focus start
|
||||
"${osd_command[@]}" message preferences-system-time-symbolic "Focus Session Started"
|
||||
;;
|
||||
focus-end)
|
||||
qs ipc call focus end
|
||||
"${osd_command[@]}" message media-playback-stop-symbolic "Focus Session Ended"
|
||||
;;
|
||||
|
||||
capture) qs ipc call capture open ;;
|
||||
intelligence) qs ipc call screen-intelligence open ;;
|
||||
screenshot) qs ipc call capture screenNow ;;
|
||||
microphone) "${osd_command[@]}" microphone toggle ;;
|
||||
|
||||
gallery) "${gallery_command[@]}" ;;
|
||||
restart-shell)
|
||||
qs kill
|
||||
quickshell --daemonize
|
||||
;;
|
||||
*)
|
||||
printf 'Usage: panama-action {%s}\n' \
|
||||
'control-center|notifications|calendar|clipboard|overview|settings|dnd|caffeine|night-light|focus-start|focus-end|capture|intelligence|screenshot|microphone|gallery|restart-shell' >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -100,8 +100,18 @@ case "${1:-}" in
|
||||
microphone) shift; adjust_microphone "$@" ;;
|
||||
brightness) shift; adjust_brightness "$@" ;;
|
||||
media) shift; media_action "$@" ;;
|
||||
message)
|
||||
shift
|
||||
kind="${1:-}"
|
||||
[[ -n $kind && $# -ge 2 ]] || {
|
||||
printf 'Usage: panama-osd message ICON LABEL\n' >&2
|
||||
exit 2
|
||||
}
|
||||
shift
|
||||
show_message "$kind" "$*"
|
||||
;;
|
||||
*)
|
||||
printf 'Usage: panama-osd volume|microphone|brightness|media ACTION [step]\n' >&2
|
||||
printf 'Usage: panama-osd volume|microphone|brightness|media|message ACTION [value]\n' >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -257,6 +257,27 @@ ShellRoot {
|
||||
}
|
||||
}
|
||||
|
||||
// Small stateful controls used by launcher commands. Returning the state
|
||||
// after mutation lets callers give accurate OSD feedback without keeping a
|
||||
// second copy of service state in a shell script.
|
||||
IpcHandler {
|
||||
target: "caffeine"
|
||||
function toggle(): bool {
|
||||
Caffeine.toggle();
|
||||
return Caffeine.enabled;
|
||||
}
|
||||
function status(): bool { return Caffeine.enabled; }
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "night-light"
|
||||
function toggle(): bool {
|
||||
NightLight.toggle();
|
||||
return NightLight.active;
|
||||
}
|
||||
function status(): bool { return NightLight.active; }
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "kdeconnect"
|
||||
function fixture(name: string): void { KdeConnect.applyFixture(name); }
|
||||
|
||||
Reference in New Issue
Block a user