Created
March 5, 2013 16:12
-
-
Save mikker/5091433 to your computer and use it in GitHub Desktop.
Something I use everyday.
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 ruby | |
# In the morning: | |
# $ firmafon | |
# In the afternoon | |
# $ firmafon -q | |
apps = %w{BreakTime Fogbugz HipChat FirmafonApps} | |
def bracketize(str = "") | |
str.gsub(/^([A-Z])/, '["\1"]') | |
end | |
def run(app) | |
puts "Running #{app}" | |
`open -g -a '#{app}'` | |
end | |
def quit(app) | |
running = `ps -A | grep "#{bracketize app}"`.length > 0 | |
if running | |
puts "Quitting #{app}" | |
`osascript -e 'tell application "#{app}" to quit'` | |
end | |
end | |
def mysql_running? | |
running = File.exist?("/usr/local/var/mysql/#{`hostname`.strip}.pid") | |
end | |
def start_mysql | |
puts "Starting MySQL server" | |
`mysql.server start` unless mysql_running? | |
end | |
def stop_mysql | |
puts "Stopping MySQL server" | |
`mysql.server stop` if mysql_running? | |
end | |
def unmount_sidekick | |
puts "Unmounting disk" | |
`if [ -d /Volumes/Sidekick ]; then diskutil unmountDisk /Volumes/Sidekick; fi` | |
end | |
if ARGV.include?("-q") | |
apps.each { |app| quit app } | |
# stop_mysql | |
unmount_sidekick | |
else | |
apps.each { |app| run app } | |
# start_mysql | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment