#!/usr/bin/env bash # sims-cli — talk to the running `sims` status bar over DBus. set -euo pipefail DEST=org.Fabric.fabric.sims OBJ=/org/Fabric/fabric IFACE=org.Fabric.fabric invoke() { dbus-send --session --print-reply --dest="$DEST" "$OBJ" \ "$IFACE.InvokeAction" "string:$1" "array:string:" >/dev/null } list_actions() { dbus-send --session --print-reply --dest="$DEST" "$OBJ" \ org.freedesktop.DBus.Properties.Get \ "string:$IFACE" string:Actions } usage() { cat <<'EOF' >&2 usage: sims-cli [args] finder open window finder apps open application launcher notmuch-refresh refresh unread mail count screenrec menu open screenrec menu (auto-detects state) screenrec start-monitor start recording the focused monitor screenrec start-region start recording a slurp-selected region screenrec stop stop active recording list list registered actions EOF exit 2 } case "${1:-}" in finder) invoke open-finder ;; apps) invoke open-app-launcher ;; notmuch-refresh) invoke refresh-notmuch ;; screenrec) case "${2:-}" in menu) invoke open-screenrec-menu ;; start-monitor) invoke screenrec-start-monitor ;; start-region) invoke screenrec-start-region ;; stop) invoke screenrec-stop ;; *) usage ;; esac ;; list) list_actions ;; *) usage ;; esac