Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
3,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ "$1" = "open" ]]; then
  4. open /Applications/Spotify.app
  5. fi
  6.  
  7. function nowplayingcore(){
  8. osascript<<'END'
  9. on escape_quotes(string_to_escape)
  10. set AppleScript's text item delimiters to the "\""
  11. set the item_list to every text item of string_to_escape
  12. set AppleScript's text item delimiters to the "\\\""
  13. set string_to_escape to the item_list as string
  14. set AppleScript's text item delimiters to ""
  15. return string_to_escape
  16. end escape_quotes
  17.  
  18. if application "Spotify" is running then
  19. tell application "Spotify"
  20. set ctrack to my escape_quotes(current track's name)
  21. set strLength to the length of my escape_quotes(current track's artist)
  22. if strLength > 0 then
  23. set ctrack to ctrack & " – " & my escape_quotes(current track's artist)
  24. end if
  25. return ctrack
  26. end tell
  27. else
  28. return "💚"
  29. end if
  30. END
  31. }
  32. function nowplaying(){
  33. np=$(nowplayingcore)
  34. if [[ $np ]];then
  35. echo "$np|bash=$0 param1=open terminal=false"
  36. fi
  37. }
  38.  
  39. nowplaying
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement