feat(triggershell): add Spotify stop playback command
Pauses Spotify via its MPRIS D-Bus interface. Talks to the user bus socket directly ($XDG_RUNTIME_DIR/bus) since triggershell.service starts before the graphical session and lacks DBUS_SESSION_BUS_ADDRESS. No-op when Spotify is not running. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016uCHmJ3PGcHZGtx8mYqmQG
This commit is contained in:
@@ -378,6 +378,33 @@ scripts:
|
||||
timeoutSeconds: 20
|
||||
variables: []
|
||||
|
||||
- id: spotify-stop
|
||||
name: "Spotify: Stop Playback"
|
||||
description: >-
|
||||
Pauses Spotify playback on the local session via its MPRIS D-Bus
|
||||
interface. Does nothing if Spotify is not running.
|
||||
command: bash
|
||||
args:
|
||||
- -c
|
||||
- |
|
||||
# triggershell.service starts before the graphical session and has no
|
||||
# DBUS_SESSION_BUS_ADDRESS, so point dbus-send at the user bus socket
|
||||
# directly (systemctl --user works here, so this socket exists).
|
||||
bus="unix:path=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/bus"
|
||||
if ! dbus-send --bus="$bus" --print-reply --dest=org.freedesktop.DBus \
|
||||
/org/freedesktop/DBus org.freedesktop.DBus.ListNames 2>/dev/null \
|
||||
| grep -q '"org.mpris.MediaPlayer2.spotify"'; then
|
||||
echo "Spotify is not running."
|
||||
exit 0
|
||||
fi
|
||||
exec dbus-send --bus="$bus" --print-reply --type=method_call \
|
||||
--dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 \
|
||||
org.mpris.MediaPlayer2.Player.Pause
|
||||
- spotify-stop
|
||||
cwd: ./
|
||||
timeoutSeconds: 15
|
||||
variables: []
|
||||
|
||||
- id: system-shutdown
|
||||
name: "System: Shutdown"
|
||||
description: >-
|
||||
|
||||
Reference in New Issue
Block a user