It is a simple script that works on the assumption that the first and last thing I do at work is something involving moving my mouse at the desk (the assumption is fairly correct). The script is a quick thing done in Ruby, with this essential part:
require 'dbus'
bus = DBus::SessionBus.instance
ss_serv = bus.service("org.gnome.ScreenSaver")
ss_obj = ss_serv.object("/org/gnome/ScreenSaver")
ss_obj.introspect
ss_obj.default_iface = "org.gnome.ScreenSaver"
while true:
if not ss_obj.GetActive then
on_work
end
sleep 10
end
This code basically polls the screensaver every 10 seconds and calls a function to say that I am currently at work. I have not included the on_work - function. This is also a fairly simple thing that uses a PStore to persistently store the first and last time the screen saver is not in use - code not included because of risk of embarrassment.
1 less angry manager and learning more Ruby in the progress, that is what I call a win-win situation!
No comments:
Post a Comment