Created
November 29, 2024 06:49
-
-
Save Strajk/f7000ce9594ed734ba24cd54e2140a6b 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
| // Name: Lyrics on Genius | |
| // Description: Look up Lyrics of Current Song on Rap Genius | |
| // Acknowledgments: | |
| // - Ryan Rudzitis: Look up Lyrics of Current Song on Rap Genius | |
| import "@johnlindquist/kit" | |
| let appsToTry = [ | |
| "Music", | |
| "Spotify" | |
| ] | |
| let qs: string | |
| for (let app of appsToTry) { | |
| qs = await applescript(/* applescript */ ` | |
| tell application "${app}" | |
| if player state is playing then | |
| set aTrack to the current track | |
| set aName to name of aTrack | |
| set aArtist to artist of aTrack | |
| return quoted form of (aArtist & " - " & aName) | |
| else | |
| return "" | |
| end if | |
| end tell | |
| `) | |
| if (qs) break | |
| } | |
| if (!qs) { | |
| notify(`No music is playing in: ` + appsToTry.join(", ")) | |
| } else { | |
| open(`http://genius.com/search?q=${qs}`) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment