Created
August 31, 2018 00:27
-
-
Save progrium/2980b759d5c5f3bc501fa0fd55545637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
ObjC.import("Cocoa"); | |
function run(argv) { | |
var app = $.NSApplication.sharedApplication; | |
var statusBarItem = $.NSStatusBar.systemStatusBar.statusItemWithLength($.NSVariableStatusItemLength); | |
var track = Application('Spotify').currentTrack | |
ObjC.registerSubclass({ | |
name: "ProgramDelegate", | |
methods: { | |
"interval:": { | |
types: ["void", ["id"]], | |
implementation: function () { | |
statusBarItem.button.title = $("🎶 "+track.name()+" - "+track.artist()); | |
} | |
} | |
} | |
}); | |
$.NSTimer.scheduledTimerWithTimeIntervalTargetSelectorUserInfoRepeats(0.5, $.ProgramDelegate.alloc.init, "interval:", null, true); | |
app.run; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment