-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.spotify.zsh
More file actions
executable file
·51 lines (48 loc) · 2.3 KB
/
.spotify.zsh
File metadata and controls
executable file
·51 lines (48 loc) · 2.3 KB
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
#!/usr/bin/env zsh
export-spotify-status () {
export spotify_state=`osascript -e 'tell application "Spotify" to player state as string'`;
export spotify_artist=`osascript -e 'tell application "Spotify" to artist of current track as string'`;
export spotify_album=`osascript -e 'tell application "Spotify" to album of current track as string'`;
export spotify_track=`osascript -e 'tell application "Spotify" to name of current track as string'`;
export spotify_duration=`osascript -e 'tell application "Spotify"
set durSec to (duration of current track / 1000) as text
set tM to (round (durSec / 60) rounding down) as text
if length of ((durSec mod 60 div 1) as text) is greater than 1 then
set tS to (durSec mod 60 div 1) as text
else
set tS to ("0" & (durSec mod 60 div 1)) as text
end if
set myTime to tM as text & ":" & tS as text
end tell
return myTime'`;
export spotify_position=`osascript -e 'tell application "Spotify"
set pos to player position
set nM to (round (pos / 60) rounding down) as text
if length of ((round (pos mod 60) rounding down) as text) is greater than 1 then
set nS to (round (pos mod 60) rounding down) as text
else
set nS to ("0" & (round (pos mod 60) rounding down)) as text
end if
set nowAt to nM as text & ":" & nS as text
end tell
return nowAt'`;
spotify_duration_raw=`osascript -e 'tell application "Spotify" to (duration of current track / 1000) as string'`;
export spotify_position_raw=`osascript -e 'tell application "Spotify" to player position as string'`;
export spotify_percent_progress=$(($spotify_position_raw * 100 / $spotify_duration_raw))
echo "$spotify_artist\n$spotify_album\n$spotify_track\n$spotify_percent_progress\n$spotify_position\n$spotify_duration" | tee ~/.debug_async
}
##tracks
#storm="spotify:track:1HfJV18PHF2UQqh4TuySBJ"
#
##playlists
#this_is_dmst="spotify:user:mohitmun:playlist:036d9YTeH4rzGIJTbylzPG"
#
#spotify_play(){
# osascript -e "tell application \"Spotify\" to play track \"$1\""
#}
#
#alias storm="spotify_play $storm"
myspotify(){
}
myspotify "$@"
#export-spotify-status