This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Spotato.sh
executable file
·99 lines (91 loc) · 2.9 KB
/
Spotato.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
_help () {
echo 'Usage: spotato [play|pause|toggle|next|previous|mediaplayer]'
echo '\nThese are the common Spotato commands uses:\n'
echo 'Play and stop the music'
echo '\tplay\tIf the music is stopped then unstop it'
echo '\tpause\tIf the music is running then stop it'
echo '\ttoggle\tIf the music is stopped this unstop it,'
echo '\t\tif the music is running than stop it'
echo ''
echo 'Change the music'
echo '\tnext\tGo to the next track'
echo '\tprevious\tReturn to the previous track'
echo ''
echo 'Change the music'
echo '\tmediaplayer\tChoose the mediaplayer to use'
echo '\tmediaplayer <option>\tSet mediaplayer to use'
}
_set_mediaplayer () {
echo $1 > ~/.config/spotato/mediaplayer
}
_choose_mediaplayer () {
echo 'Mediaplayer in use: '$mediaplayer
echo ' ---> What media player do you want to use?'
echo ' 1) Spotify'
echo ' 2) Headset'
echo ' 3) Nuclear'
echo ' 4) Chromium'
echo 'If not in the list you can type your mediaplayer'
read -p ' ---> Type selection: ' key
case $key in
4)
mediaplayer=$( dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep chromium | awk -F ' ' '/string/ {print $2}' | cut -c25- | rev | cut -c2- | rev)
;;
3)
mediaplayer=Nuclear_Music_Player
;;
2)
mediaplayer=headset
;;
1)
mediaplayer=spotify
;;
*)
mediaplayer=$key
;;
esac
_set_mediaplayer $mediaplayer
echo 'New mediaplayer: '$mediaplayer
}
mediaplayer=$(head -n 1 ~/.config/spotato/mediaplayer)
if [ $# -eq 0 ] ;
then
echo ' THIS IS SPOTATO '
echo 'Manage mediaplayer with potato'
echo '********************************'
_help
exit 1
fi
case "$1" in
mediaplayer)
if [ $# -eq 1 ] ;
then
_choose_mediaplayer
elif [ $# -eq 2 ] ;
then
_set_mediaplayer $2
fi
;;
play)
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.$mediaplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play
;;
pause)
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.$mediaplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause
;;
toggle)
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.$mediaplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
;;
next)
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.$mediaplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
;;
previous)
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.$mediaplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
;;
help)
_help
;;
*)
echo "Spotato: '"$1"' is not a spotato command. See 'spotato help'"
esac
exit 0