Skip to content
Browse files

Achievements tweaks + notification voice command support

  • Loading branch information...
1 parent 6c695d9 commit 792ae6b2ed8d8bacd285e1c32d9aa46ce29bc0c4 @aerosol committed Aug 18, 2011
Showing with 23 additions and 8 deletions.
  1. +4 −0 plugin/timechi.vim
  2. +1 −1 plugin/timechi/__init__.py
  3. +17 −3 plugin/timechi/achievements.py
  4. +1 −4 plugin/timechi/helpers.py
View
4 plugin/timechi.vim
@@ -14,6 +14,10 @@ if !exists("g:timechi_debug")
let g:timechi_debug = 0
endif
+if !exists("g:timechi_notification_command")
+ let g:timechi_notification_command = 'say "%s"'
+endif
+
let s:plugin_dir = expand('<sfile>:p:h')
function! s:InitTimeChi()
View
2 plugin/timechi/__init__.py
@@ -64,7 +64,7 @@ def append(self, k, v):
li = db.get(k, [])
li.append(v)
db[k] = li
- return (db, v)
+ return (db, li)
@atomic
def store(self, k, v):
View
20 plugin/timechi/achievements.py
@@ -1,19 +1,31 @@
#!/usr/bin/env python
import time
+import subprocess
+#import platform
from timechi.helpers import log
+try:
+ import vim
+ say_command = vim.eval("g:timechi_notification_command")
+except ImportError:
+ say_command = "echo %s"
+
ACHIEVEMENTS = {
'save': [
(lambda x: int(x) == 1,
'Act like a pro'),
+ (lambda x: int(x) == 10,
+ 'Act like a pro'),
+ (lambda x: int(x) == 15,
+ 'Act like a pro'),
(lambda x: int(x) == 50,
- 'ANIMALITY!'),
+ 'Animality!'),
(lambda x: int(x) == 100,
'Violence'),
(lambda x: int(x) == 500,
'500 Cent'),
(lambda x: int(x) == 1024,
- 'Kilobyte'),
+ 'Kilosave'),
(lambda x: int(x) == 10000,
'Professional rapist'),
(lambda x: int(x) == 1000000,
@@ -25,8 +37,10 @@
def notify(session, achievements):
for (_fn, achievement) in achievements:
print "Timechi achievement unlocked: %s" % achievement
+ cmd = say_command % achievement
+ subprocess.Popen(cmd.split(" "))
session.append('achievements', achievement)
- time.sleep(2)
+ time.sleep(1)
def achievement(fn):
"""Poor man's events"""
View
5 plugin/timechi/helpers.py
@@ -3,10 +3,7 @@
DEBUG = False
try:
import vim
- try:
- DEBUG = bool(vim.eval("g:timechi_debug"))
- except:
- DEBUG = False
+ DEBUG = bool(vim.eval("g:timechi_debug"))
except ImportError:
print "Couldnt import vim - debug mode"
DEBUG = True

0 comments on commit 792ae6b

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