0a7e725950e98050c1c3a87d047c6f42c7f017c1

Author
Pavle Portic <git@theedgeofrage.com>
Committer
Pavle Portic <git@theedgeofrage.com>
Date

Message

Add playerctl-wrapper

Diff

 1diff --git a/dot_local/bin/executable_playerctl-wrapper b/dot_local/bin/executable_playerctl-wrapper
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..9f87f167c1ce3be93743257fc45245759eaa8776
 4--- /dev/null
 5+++ b/dot_local/bin/executable_playerctl-wrapper
 6@@ -0,0 +1,18 @@
 7+#!/bin/bash
 8+#
 9+# playerctl wrapper that controls the currently playing player
10+handler() {
11+	players=$(playerctl -l)
12+	for player in $players; do
13+		player_status=$(playerctl -p $player status)
14+		if [ $player_status == 'Playing' ]; then
15+			playerctl -p $player $@
16+			echo -n $player > /tmp/last_player
17+			return
18+		fi
19+	done
20+	last_player=$(cat /tmp/last_player)
21+	playerctl -p $last_player $@
22+}
23+
24+handler $@