Skip to content
This repository
Browse code

Hu now records which application is active (i.e. front-most).

  • Loading branch information...
commit 647e0957cdec41dff6ce0a4d27c36dbe9ad2bc02 1 parent 430b996
Scott Jackson authored
11  hu.py
@@ -48,6 +48,12 @@ def getOpenBrowserTabs(browser):
48 48
 	"""
49 49
 	return commands.getoutput("osascript scripts/urls.applescript")
50 50
 	
  51
+def getCurrentApp():
  52
+	"""
  53
+	Gets the name of the front-most application.
  54
+	"""
  55
+	return commands.getoutput("osascript scripts/frontApplication.applescript")
  56
+	
51 57
 	
52 58
 
53 59
 def takeSnapshot():
@@ -67,7 +73,10 @@ def takeSnapshot():
67 73
 	newFile.write(getWeather(myLocation) + "\n")
68 74
 	
69 75
 	# put current track in file.
70  
-	newFile.write("Now Playing: " + str(getCurrentlyPlaying()) + "\n\n")
  76
+	newFile.write("Now Playing: " + str(getCurrentlyPlaying()) + "\n")
  77
+	
  78
+	# put front app in file.
  79
+	newFile.write("Current Application: " + str(getCurrentApp()) + "\n\n")
71 80
 	
72 81
 	tracks = getRecentTracks(myLastFmUsername)
73 82
 	for track in tracks:
3  scripts/frontApplication.applescript
... ...
@@ -0,0 +1,3 @@
  1
+tell application "System Events"
  2
+item 1 of (get name of processes whose frontmost is true)
  3
+end tell

0 notes on commit 647e095

Please sign in to comment.
Something went wrong with that request. Please try again.