Skip to content

Instantly share code, notes, and snippets.

@horimislime
Created April 14, 2012 07:21
Show Gist options
  • Save horimislime/2382615 to your computer and use it in GitHub Desktop.
Save horimislime/2382615 to your computer and use it in GitHub Desktop.
指定したアプリケーション以外が一定時間アクティブだとgrowl通知する
#!/usr/bin/python
#!-*-coding:utf-8-*-
import sched,time
import gntp.notifier
from AppKit import NSWorkspace
CHECK_INTERVAL=10 #Seconds
ALLOW_NAME=["iTerm","Emacs","Preview"]
sch=sched.scheduler(time.time,time.sleep)
workspace=NSWorkspace.sharedWorkspace()
growl = gntp.notifier.GrowlNotifier(
applicationName = "do-your-work", notifications = ["Default"])
growl.register()
def checkWindow():
appname=workspace.activeApplication()["NSApplicationName"]
if appname not in ALLOW_NAME:
growl.notify(
noteType="Default",
title="おい",
description="仕事しろ",
icon="http://dic.nicovideo.jp/oekaki/193525.png",
sticky=True,
)
if __name__=="__main__":
print "仕事しろ.py started!"
while True:
sch.enter(CHECK_INTERVAL,1,checkWindow,())
sch.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment