itunes playlist first commit (#5860)
Added playlist feature for the itunes command: if a variable is passed and is valid - will play the playlist if a variable is passed and is invalid(no such playlist) - will stop all playing if no variable is passed will print all playlists available on the host
This commit is contained in:
parent
ef9f3d97f0
commit
d874c73f19
@ -184,6 +184,7 @@ function vncviewer() {
|
|||||||
# iTunes control function
|
# iTunes control function
|
||||||
function itunes() {
|
function itunes() {
|
||||||
local opt=$1
|
local opt=$1
|
||||||
|
local playlist=$2
|
||||||
shift
|
shift
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
launch|play|pause|stop|rewind|resume|quit)
|
launch|play|pause|stop|rewind|resume|quit)
|
||||||
@ -200,6 +201,19 @@ function itunes() {
|
|||||||
vol)
|
vol)
|
||||||
opt="set sound volume to $1" #$1 Due to the shift
|
opt="set sound volume to $1" #$1 Due to the shift
|
||||||
;;
|
;;
|
||||||
|
playlist)
|
||||||
|
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||||
|
if [[ ! -z "$playlist" ]]; then
|
||||||
|
osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
|
||||||
|
if [[ $? -eq 0 ]]; then
|
||||||
|
opt="play"
|
||||||
|
else
|
||||||
|
opt="stop"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
opt="set allPlaylists to (get name of every playlist)"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
playing|status)
|
playing|status)
|
||||||
local state=`osascript -e 'tell application "iTunes" to player state as string'`
|
local state=`osascript -e 'tell application "iTunes" to player state as string'`
|
||||||
if [[ "$state" = "playing" ]]; then
|
if [[ "$state" = "playing" ]]; then
|
||||||
@ -250,6 +264,7 @@ EOF
|
|||||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||||
echo "\tvol\tSet the volume, takes an argument from 0 to 100"
|
echo "\tvol\tSet the volume, takes an argument from 0 to 100"
|
||||||
echo "\tplaying|status\tShow what song is currently playing in iTunes."
|
echo "\tplaying|status\tShow what song is currently playing in iTunes."
|
||||||
|
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||||
echo "\thelp\tshow this message and exit"
|
echo "\thelp\tshow this message and exit"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user