Last active
December 12, 2015 00:08
-
-
Save hryk/4681703 to your computer and use it in GitHub Desktop.
Terminate and re-launch an application with MacRuby.
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 | |
#encoding: utf-8 | |
framework 'Cocoa' | |
framework 'ApplicationServices' | |
framework 'AppKit' | |
# Get a list of applications currently running. | |
ws = NSWorkspace.sharedWorkspace | |
apps = ws.runningApplications | |
applist = {} | |
apps.each do |app| | |
applist[app.localizedName] = app.executableURL.path.lastPathComponent | |
# Terminate 夜フクロウ | |
if app.localizedName == "夜フクロウ" | |
app.terminate | |
end | |
end | |
sleep 5 | |
# Re-launch 夜フクロウ | |
ws.launchApplication(applist["夜フクロウ"]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment