Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
92586e38
Commit
92586e38
authored
Aug 31, 2016
by
mahi97
Browse files
add info, share and status option
parent
8f47c964
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/osx/osx.plugin.zsh
View file @
92586e38
...
@@ -263,6 +263,7 @@ EOF
...
@@ -263,6 +263,7 @@ EOF
# Spotify control function
# Spotify control function
function
spotify
()
{
function
spotify
()
{
showHelp
()
{
showHelp
()
{
echo
"Usage:"
;
echo
"Usage:"
;
echo
;
echo
;
...
@@ -277,13 +278,35 @@ function spotify() {
...
@@ -277,13 +278,35 @@ function spotify() {
echo
" pos [time] # Jumps to a time (in secs) in the current song."
;
echo
" pos [time] # Jumps to a time (in secs) in the current song."
;
echo
" quit # Stops playback and quits Spotify."
;
echo
" quit # Stops playback and quits Spotify."
;
echo
;
echo
;
echo
" vol up # Increases the volume by 10%."
;
echo
" vol down # Decreases the volume by 10%."
;
echo
" vol [amount] # Sets the volume to an amount between 0 and 100."
;
echo
" vol [amount] # Sets the volume to an amount between 0 and 100."
;
echo
" vol show # Shows the current Spotify volume."
;
echo
" vol show # Shows the current Spotify volume."
;
echo
;
echo
;
echo
" status # Shows the current player status."
;
echo
" share # Copies the current song URL to the clipboard."
echo
" info # Shows Full Information about song that is playing."
;
echo
;
echo
" toggle shuffle # Toggles shuffle playback mode."
;
echo
" toggle shuffle # Toggles shuffle playback mode."
;
echo
" toggle repeat # Toggles repeat playback mode."
;
echo
" toggle repeat # Toggles repeat playback mode."
;
}
}
showStatus
()
{
state
=
$(
osascript
-e
'tell application "Spotify" to player state as string'
)
;
echo
"Spotify is currently
$state
."
;
if
[
"
$state
"
=
"playing"
]
;
then
artist
=
$(
osascript
-e
'tell application "Spotify" to artist of current track as string'
)
;
album
=
$(
osascript
-e
'tell application "Spotify" to album of current track as string'
)
;
track
=
$(
osascript
-e
'tell application "Spotify" to name of current track as string'
)
;
duration
=
$(
osascript
-e
'tell application "Spotify" to duration of current track as string'
)
;
duration
=
$(
echo
"scale=2;
$duration
/ 60 / 1000"
| bc
)
;
position
=
$(
osascript
-e
'tell application "Spotify" to player position as string'
|
tr
','
'.'
)
;
position
=
$(
echo
"scale=2;
$position
/ 60"
| bc |
awk
'{printf "%0.2f", $0}'
)
;
echo
"
$reset
""Artist:
$artist
\n
Album:
$album
\n
Track:
$track
\n
Position:
$position
/
$duration
"
;
fi
}
if
[
$#
=
0
]
;
then
if
[
$#
=
0
]
;
then
showHelp
;
showHelp
;
else
else
...
@@ -367,6 +390,51 @@ function spotify() {
...
@@ -367,6 +390,51 @@ function spotify() {
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
osascript
-e
"tell application
\"
Spotify
\"
to set player position to
$2
"
;
break
;;
break
;;
"status"
)
showStatus
;
break
;;
"info"
)
info
=
$(
osascript
-e
'tell application "Spotify"
set tM to round (duration of current track / 60) rounding down
set tS to duration of current track mod 60
set pos to player position as text
set myTime to tM as text & "min " & tS as text & "s"
set nM to round (player position / 60) rounding down
set nS to round (player position mod 60) rounding down
set nowAt to nM as text & "min " & nS as text & "s"
set info to "" & "\nArtist: " & artist of current track
set info to info & "\nTrack: " & name of current track
set info to info & "\nAlbum Artist: " & album artist of current track
set info to info & "\nAlbum: " & album of current track
set info to info & "\nSeconds: " & duration of current track
set info to info & "\nSeconds played: " & pos
set info to info & "\nDuration: " & mytime
set info to info & "\nNow at: " & nowAt
set info to info & "\nPlayed Count: " & played count of current track
set info to info & "\nTrack Number: " & track number of current track
set info to info & "\nPopularity: " & popularity of current track
set info to info & "\nId: " & id of current track
set info to info & "\nSpotify URL: " & spotify url of current track
set info to info & "\nArtwork: " & artwork of current track
set info to info & "\nPlayer: " & player state
set info to info & "\nVolume: " & sound volume
set info to info & "\nShuffle: " & shuffling
set info to info & "\nRepeating: " & repeating
end tell
return info'
)
echo
"
$info
"
;
break
;;
"share"
)
url
=
$(
osascript
-e
'tell application "Spotify" to spotify url of current track'
)
;
remove
=
'spotify:track:'
url
=
${
url
#
$remove
}
url
=
"http://open.spotify.com/track/
$url
"
echo
"Share URL:
$url
"
;
echo
-n
"
$url
"
| pbcopy
break
;;
-h
|
--help
|
*
)
-h
|
--help
|
*
)
showHelp
;
showHelp
;
break
;;
break
;;
...
...
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