From e476f6b89c4e37c96ad341c38fd8a67908fee9c2 Mon Sep 17 00:00:00 2001 From: Anton Orlov Date: Sun, 8 Jan 2017 18:03:40 +0300 Subject: [PATCH] Song detector script rewrited in AppleScript --- info.plist | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/info.plist b/info.plist index 91a54dd..def2f19 100644 --- a/info.plist +++ b/info.plist @@ -76,24 +76,13 @@ escaping 68 script - function run(argv) { - let player; - if (Application('Spotify').running() && Application('Spotify').playerState() === 'playing') { - player = Application('Spotify') - } else if (Application('iTunes').running() && Application('iTunes').playerState() === 'playing') { - player = Application('iTunes') - } else return - - const track = player.currentTrack - - return `${track.artist()} ${track.name()}` -} + on is_running(appName) tell application "System Events" to (name of processes) contains appName end is_running if is_running("Spotify") then tell application "Spotify" if player state is playing then return (artist of current track) & " " & (name of current track) end if end tell end if if is_running("iTunes") then tell application "iTunes" if player state is playing then return (artist of current track) & " " & (name of current track) end if end tell end if return scriptargtype 1 scriptfile type - 7 + 6 type alfred.workflow.action.script @@ -161,7 +150,7 @@ fi version - 0.4 + 0.5 webaddress pinked.ru