Skip to content

Instantly share code, notes, and snippets.

@antranigv
Created April 24, 2025 22:27
Show Gist options
  • Select an option

  • Save antranigv/c778de1e49c4810b33a9d5228d552a8b to your computer and use it in GitHub Desktop.

Select an option

Save antranigv/c778de1e49c4810b33a9d5228d552a8b to your computer and use it in GitHub Desktop.
Adium Music Status that works with Music.app written in AppleScript

Testing:

  • Open the code above using Utilities/Script Editor
  • Run Adium
  • Run Music.app and play your favorite track
  • Back in Script Editor, do ⌘-R, the track info should set as your status

Building:

  • In Script Editor do "File → Export...". Set the "File Format" to "Application" and check the box "Stay open after run handler"
  • Save the App somewhere
  • Now add the following in diumMusicPresence.app/Contents/Info.plist
<key>LSUIElement</key>
<string>true</string>

Running:

You can run the App by double clicking on it, or using the Unix Shell: open -a AdiumMusicPresence.app

It will ask you for basic permissions such as "Can I control Music.app?" and "Can I control Adium?". Answer with "Allow" if you want the program to work.

Thank you for using Jabber/XMPP.

property lastTrack : "" -- Last known track (name & artist)
property lastState : "stopped" -- Last known playback state
property lastRunning : false -- Last known running state of Apple Music
on clearAdiumStatus()
tell application "Adium"
if it is running then
set status message of every account to ""
end if
end tell
end clearAdiumStatus
on quit
clearAdiumStatus()
display dialog "Goodbye!"
continue quit
end quit
on run
display notification "Script is running. Enjoy your music." with title "AdiumMusicStatus"
idle -- triggers the idle handler
end run
on idle
-- Core loop logic
set statusMessage to "" -- Default to empty status
set currentTrack to ""
set currentState to "stopped"
set currentRunning to false
-- Check Apple Music for current track and state
tell application "Music"
if it is running then
set currentRunning to true
try
set playerStateRaw to player state
if playerStateRaw is playing then
set currentState to "playing"
else if playerStateRaw is paused then
set currentState to "paused"
else if playerStateRaw is stopped then
set currentState to "stopped"
else
set currentState to "unknown"
end if
if currentState is "playing" then
set songName to name of current track
set songArtist to artist of current track
set currentTrack to songName & " by " & songArtist
set statusMessage to "Listening to: " & currentTrack
end if
on error errMsg
display dialog "Error accessing Music: " & errMsg
set currentTrack to ""
set statusMessage to ""
end try
end if
end tell
-- Check for changes
set hasChanged to false
if currentRunning is not lastRunning then
set hasChanged to true
else if currentState is not lastState then
set hasChanged to true
else if currentTrack is not lastTrack then
set hasChanged to true
end if
-- Update Adium only if something changed
if hasChanged then
tell application "Adium"
if it is running then
repeat with a in accounts
set status message of a to statusMessage
end repeat
end if
end tell
set lastTrack to currentTrack
set lastState to currentState
set lastRunning to currentRunning
end if
return 5 -- Wait 5 seconds before next idle cycle
end idle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment