-
Notifications
You must be signed in to change notification settings - Fork 0
/
rofi-playerctl.sh
executable file
·43 lines (39 loc) · 1008 Bytes
/
rofi-playerctl.sh
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
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
status_function () {
if playerctl status > /dev/null; then
echo "$(playerctl status -f "{{playerName}}"): $(playerctl metadata -f "{{trunc(default(title, \"[Unknown]\"), 25)}} by {{trunc(default(artist, \"[Unknown]\"), 25)}}") ($(playerctl status))"
else
echo "Nothing is playing"
fi
}
status=$(status_function)
# Options
toggle="⏯️ Play/Pause"
next="⏭️ Next"
prev="⏮ Previous"
seekminus="⏪ Go back 15 seconds"
seekplus="⏩ Go ahead 15 seconds"
switch="🔄 Change selected player"
# Variable passed to rofi
options="$toggle\n$next\n$prev\n$seekplus\n$seekminus\n$switch"
chosen="$(echo -e "$options" | rofi -show -p "${status^}" -dmenu -selected-row 0)"
case $chosen in
$toggle)
playerctl play-pause
;;
$next)
playerctl next
;;
$prev)
playerctl previous
;;
$seekminus)
playerctl position 15-
;;
$seekplus)
playerctl position 15+
;;
$switch)
playerctld shift
;;
esac