Created
March 24, 2014 18:26
-
-
Save tbeseda/9746123 to your computer and use it in GitHub Desktop.
Append current Rdio track to commit message
This file contains 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/ruby | |
message_file = ARGV[0] | |
def app_is_running?(app_name) | |
`ps aux` =~ /#{app_name}/ ? true : false | |
end | |
while true | |
if app_is_running?('Rdio.app') | |
artist = `osascript -e 'tell application "Rdio" to get the artist of the current track'` | |
track = `osascript -e 'tell application "Rdio" to get the name of the current track'` | |
File.open(message_file, 'a') do |file| | |
file.puts "\n♫ #{artist.chomp} - #{track.chomp}" | |
end | |
end | |
break | |
end |
Credit https://stackoverflow.com/questions/8395270/ruby-script-to-check-if-a-mac-os-x-app-is-currently-running for app_is_running?
method
You could also add this to a crontab, so it's asynchronous.
It's fast, but maybe the ps, osacript calls, and writing to the filesystem will slow down the responsiveness of your git commands?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this file to .git/hooks/ and
chmod 755
it.Looks like this:
♫ Seasick Steve - Down On The Farm