Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
9248052e
Commit
9248052e
authored
Aug 30, 2016
by
mahi97
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial spotify control
parent
3c8a3336
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
osx.plugin.zsh
plugins/osx/osx.plugin.zsh
+98
-0
No files found.
plugins/osx/osx.plugin.zsh
View file @
9248052e
...
@@ -261,6 +261,104 @@ EOF
...
@@ -261,6 +261,104 @@ EOF
osascript
-e
"tell application
\"
iTunes
\"
to
$opt
"
osascript
-e
"tell application
\"
iTunes
\"
to
$opt
"
}
}
# Spotify control function
function
spotify
()
{
showHelp
()
{
echo
"Usage:"
;
echo
;
echo
"
$(
basename
"
$0
"
)
<command>"
;
echo
;
echo
"Commands:"
;
echo
;
echo
" play # Resumes playback where Spotify last left off."
;
echo
" pause # Pauses Spotify playback."
;
echo
" next # Skips to the next song in a playlist."
;
echo
" prev # Returns to the previous song in a playlist."
;
echo
" pos [time] # Jumps to a time (in secs) in the current song."
;
echo
" quit # Stops playback and quits Spotify."
;
echo
;
echo
" vol [amount] # Sets the volume to an amount between 0 and 100."
;
echo
" vol show # Shows the current Spotify volume."
;
echo
;
echo
" toggle shuffle # Toggles shuffle playback mode."
;
echo
" toggle repeat # Toggles repeat playback mode."
;
}
if
[
$#
=
0
]
;
then
showHelp
;
else
if
[
"
$(
osascript
-e
'application "Spotify" is running'
)
"
=
"false"
]
;
then
osascript
-e
'tell application "Spotify" to activate'
sleep
2
fi
fi
while
[
$#
-gt
0
]
;
do
arg
=
$1
;
case
$arg
in
"play"
)
echo
"Playing Spotify."
;
osascript
-e
'tell application "Spotify" to play'
;
break
;;
"pause"
)
echo
"Pausing Spotify."
;
osascript
-e
'tell application "Spotify" to pause'
;
break
;;
"quit"
)
echo
"Quitting Spotify."
;
osascript
-e
'tell application "Spotify" to quit'
;
exit
1
;;
"next"
)
echo
"Going to next track."
;
osascript
-e
'tell application "Spotify" to next track'
;
break
;;
"prev"
)
echo
"Going to previous track."
;
osascript
-e
'tell application "Spotify" to previous track'
;
break
;;
"vol"
)
vol
=
$(
osascript
-e
'tell application "Spotify" to sound volume as integer'
)
;
if
[[
"
$2
"
=
"show"
||
"
$2
"
=
""
]]
;
then
echo
"Current Spotify volume level is
$vol
."
;
break
;
elif
[
"
$2
"
-ge
0
]
;
then
newvol
=
$2
;
fi
osascript
-e
"tell application
\"
Spotify
\"
to set sound volume to
$newvol
"
;
break
;;
"toggle"
)
if
[
"
$2
"
=
"shuffle"
]
;
then
osascript
-e
'tell application "Spotify" to set shuffling to not shuffling'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to shuffling'
)
;
echo
"Spotify shuffling set to
$curr
"
;
elif
[
"
$2
"
=
"repeat"
]
;
then
osascript
-e
'tell application "Spotify" to set repeating to not repeating'
;
curr
=
$(
osascript
-e
'tell application "Spotify" to repeating'
)
;
echo
"Spotify repeating set to
$curr
"
;
fi
break
;;
"pos"
)
echo
"Adjusting Spotify play position."
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
break
;;
-h
|
--help
|
*
)
showHelp
;
break
;;
esac
done
}
# Show/hide hidden files in the Finder
# Show/hide hidden files in the Finder
alias
showfiles
=
"defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias
showfiles
=
"defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias
hidefiles
=
"defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias
hidefiles
=
"defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment