From 07fc2644a237187dd4c5680e88f4adadbf533603 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Wed, 12 Aug 2015 12:06:23 -0600 Subject: Initial commit of the working files --- segments/np_spotify_mac.script | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 segments/np_spotify_mac.script (limited to 'segments/np_spotify_mac.script') diff --git a/segments/np_spotify_mac.script b/segments/np_spotify_mac.script new file mode 100755 index 0000000..91fbb63 --- /dev/null +++ b/segments/np_spotify_mac.script @@ -0,0 +1,23 @@ +#!/usr/bin/env osascript +# Returns the current playing song in Spotify for OSX + +tell application "System Events" + set process_list to (name of every process) +end tell + +if process_list contains "Spotify" then + tell application "Spotify" + if player state is playing then + set track_name to name of current track + set artist_name to artist of current track + #set album_name to album of current track + set trim_length to 40 + set now_playing to artist_name & " - " & track_name + if length of now_playing is less than trim_length then + set now_playing_trim to now_playing + else + set now_playing_trim to characters 1 thru trim_length of now_playing as string + end if + end if + end tell +end if -- cgit v1.2.3