-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmedia-control
More file actions
executable file
·33 lines (30 loc) · 879 Bytes
/
media-control
File metadata and controls
executable file
·33 lines (30 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# media-control is a script that acts like playerctl, but controls MPD
# instead of MPRIS if MPD is runnning.
# I created media-control to replace playerctl when binding media keys.
if mpc status >/dev/null 2>/dev/null; then
# translate playerctl commands to mpc commands
case "$1" in
play-pause)
mpc toggle
;;
previous)
mpc prev
;;
next)
mpc next
mpc sticker "$(mpc status -f '%file%' | sed 1q)" list
;;
*) mpc "$@" ;;
esac
elif playerctlpath="$(command -v playerctl >/dev/null)"; then
if echo "$playerctlpath" | grep "^$HOME/.local" >/dev/null; then
LD_LIBRARY_PATH="$HOME/.local/lib/:$LD_LIBRARY_PATH"
GI_TYPELIB_PATH="$HOME/.local/lib/:$GI_TYPELIB_PATH"
fi
playerctl "$@"
else
# shellcheck disable=SC2016 # I don't want expansion in this string
echo 'mpd is not running, and playerctl is not in your $PATH'
fi
# vi:ft=sh