Skip to content

Instantly share code, notes, and snippets.

@jarib
Created May 3, 2009 23:47
Show Gist options
  • Save jarib/106205 to your computer and use it in GitHub Desktop.
Save jarib/106205 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -wKU
require "osx/cocoa"
include OSX
class Sleeper < NSObject
def initialize
NSWorkspace.sharedWorkspace.notificationCenter.objc_send(
:addObserver, self,
:selector, :on_sleep,
:name, NSWorkspaceWillSleepNotification,
:object, nil
)
end
def on_sleep(notification)
p :notification => notification
end
end
Sleeper.new
NSApplication.sharedApplication.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment