-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcustomizable_alarm_lister.py
67 lines (45 loc) · 2.01 KB
/
customizable_alarm_lister.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
# Print various attributes of alarm(s) by modifying various things
# Author: slarti
import dbus
from datetime import datetime, timedelta, date
bus = dbus.SystemBus()
time_obj = bus.get_object('com.nokia.time', '/com/nokia/time')
time_intf = dbus.Interface(time_obj, 'com.nokia.time')
alarm_obj = bus.get_object('com.nokia.time', '/org/maemo/contextkit/Alarm/Trigger')
alarms = alarm_obj.Get(dbus_interface='org.maemo.contextkit.Property')[0]
cookies = alarms[0].keys()
alarms_list = []
for cookie in cookies:
timestamp = alarms[0][cookie]
attributes = time_intf.query_attributes(cookie)
alarms_list.append(((timestamp,cookie,attributes)))
alarms_list.sort()
# Change these to your own language in the order
# they are in if you want to print the weekday:
abb_weekdays = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
# Choose the limit for the number of alarms (lines) to print:
limit = 5
# If you want to print "No alarms", if there are none,
# leave this as is (the string can be changed).
# If you don't want it, comment this out or delete it:
if len(alarms_list) == 0:
print 'No alarms'
# Don't touch this:
if len(alarms_list) < limit:
limit = len(alarms_list)
# This generates what to print on every line:
for i in range(limit):
# Don't touch this:
alarm_timestamp = datetime.fromtimestamp((alarms_list[i][0])/1000000000)
# You can choose from these:
weekday = abb_weekdays[date.weekday(alarm_timestamp)]
title = alarms_list[i][2]['TITLE']
alarmtime = datetime.strftime(alarm_timestamp,"%H:%M")
time_to_alarm = ':'.join(str(alarm_timestamp - datetime.now()).split(':')[:2])
snooze = alarms_list[i][2]['snooze']+'min'
# This is the special character. Look for the Python source code
# string at e.g. http://www.fileformat.info/info/unicode/block/index.htm
sc = u"\u2691"
# Here you can decide what to print in which order:
print (weekday+' '+title+' '+alarmtime+' '+time_to_alarm+' '+snooze+' '+sc).encode('utf-8')