Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ "$1" = "open" ]]; then
- open /Applications/Spotify.app
- fi
- function nowplayingcore(){
- osascript<<'END'
- on escape_quotes(string_to_escape)
- set AppleScript's text item delimiters to the "\""
- set the item_list to every text item of string_to_escape
- set AppleScript's text item delimiters to the "\\\""
- set string_to_escape to the item_list as string
- set AppleScript's text item delimiters to ""
- return string_to_escape
- end escape_quotes
- if application "Spotify" is running then
- tell application "Spotify"
- set ctrack to my escape_quotes(current track's name)
- set strLength to the length of my escape_quotes(current track's artist)
- if strLength > 0 then
- set ctrack to ctrack & " – " & my escape_quotes(current track's artist)
- end if
- return ctrack
- end tell
- else
- return "💚"
- end if
- END
- }
- function nowplaying(){
- np=$(nowplayingcore)
- if [[ $np ]];then
- echo "$np|bash=$0 param1=open terminal=false"
- fi
- }
- nowplaying
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement