data/wakeup/plugin_scripts/MusicPlayer/play_music.sh000775 001750 001750 00000002213 11741113010 024052 0ustar00dglassdglass000000 000000 #!/bin/bash # plugin script for MusicPlayer, which plays a given file with mpg123 # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 trap "killall mpg123; exit" SIGHUP SIGINT SIGTERM plugin_file=/home/$1/.wakeup/$ALARM/plugins/MusicPlayer/MusicPlayer.config MUSIC=$(sed -rn 's/music_file\s*=\s*(.*)\s*$/\1/p' $plugin_file) ENDPOS=$(sed -rn 's/time\s*=\s*(.*)\s*$/\1/p' $plugin_file) # note making volume 3/4 is a hack to make the music volume equal the # low festival volume. It only needs to be done when not logged in. if [[ `who` == "" ]]; then volume=$(sudo /usr/bin/amixer get Master | grep -oP "\d+%" | grep -oP "\d+") sudo /usr/bin/amixer set Master $(($volume * 3 / 4))\% fi if [[ $ENDPOS == 0 ]]; then mpg123 "$MUSIC" else mpg123 "$MUSIC" & x=$! if [[ $ENDPOS =~ [0-9]+:[0-9]{2} ]]; then mins=$(echo $ENDPOS | grep -oP "^[0-9]+") secs=$(echo $ENDPOS | grep -oP "[0-9]+$") ENDPOS=$(( 60 * mins + secs )) fi sleep $ENDPOS kill $x fi #reset volume if [[ `who` == "" ]]; then sudo /usr/bin/amixer set Master $volume\% fi data/wakeup/plugin_scripts/Weather/Weather.glade000664 001750 001750 00000022514 11741113010 023113 0ustar00dglassdglass000000 000000 mph knots F C True False 6 Weather Preferences False center dialog True False True False 2 2 3 Manually set location (e.g.: city,state): True True False False True True False True False False 1 2 True False 4 True False Temperature units: True True 0 True False liststore2 1 0 False False 1 True False Wind Speed units: True True 2 True False liststore1 1 0 False False 3 2 1 2 False False 3 0 True False True False 8 True gtk-ok True True True False True True True 0 gtk-cancel True True True False True True True 1 True True 20 0 False True 1 data/wakeup/plugin_settings/000770 001750 001750 00000000000 11741113010 017257 5ustar00dglassdglass000000 000000 data/wakeup/default_plugin_confs/000770 001750 001750 00000000000 11741113010 020233 5ustar00dglassdglass000000 000000 data/wakeup/default_plugin_confs/MusicPlayer/000770 001750 001750 00000000000 11741113010 022470 5ustar00dglassdglass000000 000000 doc/wakeup.1000664 001750 001750 00000003141 12315674007 014003 0ustar00dglassdglass000000 000000 .TH wakeup 1 "Version 1.4" "Mar 2014" .SH NAME wakeup \- A talking and fully customizable alarm clock .SH SYNOPSIS .B wakeup username alarmID .SH DESCRIPTION .B wakeup plays an alarm for the given username, whose settings for the alarm can be modified using the .B wakeup\-settings utility. The user's alarm that is run is specified by alarmID, which corresponds to the folder number in the user's wakeup settings folder ~/.wakeup. Alarm text and all associated options should be defined by running .B wakeup\-settings as \fBusername\fR. Although it is possible to modify the settings directly by editing the files in ~/.wakeup/, this is not recommended and make cause you to lose alarm settings. .P An option in .B wakeup\-settings allows the alarm to wake the computer (from poweroff if the bios allows). In this case, .B wakeup is set by to run from root's cron, and the alarm will run in this case even if no user is logged in. One must log in or be logged in to stop the alarm. .P Note that for any part of the alarm which depends on information from the web to work when you are not logged in, you will need to set the wireless network(s) you connect to so that they connect before you log in. This can be done through NetworkManager, by selecting a connection, clicking "Edit..." and checking "Available to all users." .SH "SEE ALSO" \fBsetalarm\fR(1), \fBwakeup\-settings\fR(1), \fBcron\fR, \fBcrontab\fR .SH AUTHOR The program and its documentation are copyrighted (C) 2012 by David Glass . All rights reserved. They are distributed under the terms of the GNU General Public License version 3 or later. data/wakeup/plugin_scripts/MusicPlayer/MusicPlayer.glade000664 001750 001750 00000013243 11741113010 024606 0ustar00dglassdglass000000 000000 True 6 Select music file... False center dialog south-east True 6 True 6 True Music file: 0 True True 2 gtk-open True True True True False end 1 0 True 7 True Play for (seconds, or mm:ss, 0=entire song): 0 True True 6 False False 1 1 True True 9 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 2 data/wakeup/plugin_settings/HebrewCalendar.plugin000664 001750 001750 00000000421 11741113010 023347 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Get date and events from the Hebrew calendar' p2 sS'script' p3 S'HebrewCalendar/check_hebcal.py' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'hebdate' p8 aS'hebcalevents' p9 asS'has_preferences' p10 I01 sS'name' p11 S'Hebrew Calendar' p12 s. data/wakeup/location.py000664 001750 001750 00000003772 12015212231 016241 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # get location for Weather # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 # Note this function can be imported, and gives a dictionary output of location data # as available from the source www.ip-address.org. Data available may depend on location, # but should include: 'City', 'State', 'Country', 'Continent', 'Time zone', 'City Lat/Lon', # 'Country Lat/Lon', 'Continent Lat/Lon', 'My IP Address', 'My IP Host', 'ISP', 'Postal', # and others. # Some data about the computer, such as Browser, is useless but left for completion. # Additionally, the dict keys 'longitude' and 'latitude' are added for ease of use; they # are just taken from key 'City Lat/Lon'. import urllib2 import re def get_location(): # Grab information about location based on IP url = 'http://www.ip-address.org' req = urllib2.Request(url) response = urllib2.urlopen(req,'',5) page = response.read() tables = re.findall("", page,flags=re.DOTALL) # find tables table = tables[1] # get the right table table = re.sub(r"([^<]*)\1 tags table = re.sub("
", ";", table) tableelements = re.findall(".*?", table, flags=re.DOTALL) properties = {} for el in tableelements: try: # Get rid of leading junk, which may contain a tag el = re.search('.*', el, re.DOTALL).group(0) except: continue prop = re.search("(.*):\s*", el, flags=re.DOTALL) val = re.search("(.*)", el, flags=re.DOTALL) if val and prop: # skip if el is just a header properties[prop.group(1).strip()] = re.sub("<.*>| ", "", val.group(1).strip()) # Add latitude and longitude keys for direct ease of use [properties['latitude'],properties['longitude']] = \ re.findall("[0-9\.\-]+", properties['City Lat/Lon']) return properties data/wakeup/plugin_settings/Weather.plugin000664 001750 001750 00000000525 11741113010 022105 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Get weather for your Gnome location' p2 sS'script' p3 S'Weather/get_weather.py' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'temperature' p8 aS'humidity' p9 aS'skyconditions' p10 aS'windconditions' p11 aS'high' p12 aS'low' p13 aS'todays_forecast' p14 asS'has_preferences' p15 I01 sS'name' p16 S'Weather' p17 s.data/wakeup/default_plugin_confs/EvolutionData/EvolutionData.config000664 001750 001750 00000000017 11741113010 026761 0ustar00dglassdglass000000 000000 ignore_cals=() data/wakeup/default_plugin_confs/MusicPlayer/MusicPlayer.config000664 001750 001750 00000000024 11741113010 026115 0ustar00dglassdglass000000 000000 music_file= time=30 data/wakeup/plugin_settings/Commands.plugin000664 001750 001750 00000000307 11741113010 022245 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Run arbitrary command' p2 sS'script' p3 S'Commands/run_commands.sh' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 sS'has_preferences' p8 I01 sS'name' p9 S'Commands' p10 s.data/wakeup/alarm.py000664 001750 001750 00000025431 12132661407 015536 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # alarm data type class used by wakeup-settings and setnextalarm. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import datetime, re, os, pickle, subprocess days_dict = dict(Sun=0, Mon=1, Tue=2, Wed=3, Thu=4, Fri=5, Sat=6) elevatescript = '/usr/share/wakeup/wakeupRootHelper' class alarm: def __init__(self): # Default values self.text = "" self.time = [8, 30] self.recurrs = False self.recurrence = "None" self.day_recurrences = dict(Sun=False, Mon=False, Tue=False, Wed=False, Thu=False, Fri=False, Sat=False) self.dom = 1 self.mon = "*" self.cronvalue = "0 0 0 0 0" self.volume = 70 self.voice = "none" self.otherspeechtool = "none" self.wakecomputer = True self.activeplugins = list() self.Commands_dataitems = list() # for dynamic dataitems from Commands plugin def set_property(self, property_name, value): exec("self." + property_name + " = value") def get_property(self, property_name): exec("prop = self." + property_name) return prop def save_playfile(self, filename, folder, isTmpFile, plugins): data_items = list() itemsToPlugin = dict() for key in plugins.keys(): data_items.extend(plugins[key]['data_items']) for item in plugins[key]['data_items']: itemsToPlugin[item] = key # Add in dynamic dataitems from Commands plugin if "Commands" in self.activeplugins: data_items.extend(self.Commands_dataitems) for item in self.Commands_dataitems: itemsToPlugin[item] = "Commands" usedDataByPlugin = dict() for name in self.activeplugins: usedDataByPlugin[name] = list() strings = re.split("\n{2,}", self.text) final_text = "" sudo = "" if self.wakecomputer and not isTmpFile: sudo = "sudo -E -u $usr " for i in strings: has_text_output = False items = re.findall("\$\w+", i) for j in range(len(items)): items[j] = items[j][1:] keys = {} for j in items: keys[j] = 1 data_used = keys.keys() init_string = "" for name in usedDataByPlugin.keys(): del usedDataByPlugin[name][:] for j in data_used: if j in data_items and itemsToPlugin[j] in self.activeplugins: usedDataByPlugin[itemsToPlugin[j]].append(j) else: i = re.sub('\$'+j,'\\\$'+j,i) del data_used[data_used.index(j)] for name in usedDataByPlugin.keys(): if plugins[name]['text_output'] and not len(usedDataByPlugin[name]) == 0: itemsstring = "".join([k + " " for k in usedDataByPlugin[name]]) init_string += "data=($(echo \"$(" + sudo + plugins[name]['script'] + \ " $usr " + itemsstring + \ ")\" | sed -r ':a;N;$!ba;s/\\n{2}/ \\n\\n/g'));\n" for k in range(len(usedDataByPlugin[name])): init_string += usedDataByPlugin[name][k] + "=${data[" + str(k) + "]}; " init_string += "\n" has_text_output = True else: for item in usedDataByPlugin[name]: #note there is no sudo for non-text items init_string += plugins[name]['script'] + " $usr\n" final_text += "\n" + init_string if has_text_output or len(data_used) == 0:\ final_text += "echo -e \"" + i + "\" | talk\n" top_text = "#!/bin/bash\nusr=$1\n" \ + "export ALARM=" + folder + "\nIFS=$'\\n\\n'\nshopt -s expand_aliases\n" if not self.otherspeechtool == "none": top_text = top_text + "alias talk='" + self.otherspeechtool + "'\n\n" else: top_text = top_text + "alias talk='festival_client --ttw | aplay'\n" \ + "festival --server " if self.voice != "none": top_text = top_text + "'(voice_" + self.voice + ")'" top_text = top_text + "&\nwhile [[ $(echo '()' | festival_client && echo $?) != 0 ]];" \ + " do echo -n ''; done\n\n" final_text = top_text + final_text if self.wakecomputer and not isTmpFile: createfilescript = '/usr/share/wakeup/createRootPlayfile.py' fileout = subprocess.Popen(['pkexec', elevatescript, createfilescript, filename], stdin=subprocess.PIPE) fileout.communicate(final_text) else: if os.path.exists(filename): subprocess.call(['rm', '-f', filename]) # necessary because may be owned by root file = open(filename, "w") file.write(final_text) file.close() subprocess.call(["chmod", "+x", filename]) def save_settings(self, filename): cronval = "" for i in self.get_cronvalues(): cronval += str(i) + " " self.cronvalue = cronval.strip() alarm_file = open(filename, "w") pickle.dump(self, alarm_file) alarm_file.close() def read_settings(self, filename): try: alarm_file = open(filename, "r") tmpalarm = pickle.load(alarm_file) alarm_file.close() self.text = tmpalarm.get_property("text") self.time = tmpalarm.get_property("time") self.recurrs = tmpalarm.get_property("recurrs") self.recurrence = tmpalarm.get_property("recurrence") self.day_recurrences = tmpalarm.get_property("day_recurrences") self.dom = tmpalarm.get_property("dom") self.mon = tmpalarm.get_property("mon") self.cronvalue = tmpalarm.get_property("cronvalue") self.volume = tmpalarm.get_property("volume") self.voice = tmpalarm.get_property("voice") self.otherspeechtool = tmpalarm.get_property("otherspeechtool") self.wakecomputer = tmpalarm.get_property("wakecomputer") self.activeplugins = tmpalarm.get_property("activeplugins") except: return "wakeup_settings file not found or improperly formatted" return "Loaded wakeup settings" def setalarm_command(self, folder, setalarm_script, wakeup_script): [minute, hour, dom, mon, dow] = self.get_cronvalues() alarmnum = re.search("alarm(\d+)$", folder).group(1) wakeup_script_meta = re.sub("/", "\\/", wakeup_script) if self.wakecomputer: if self.recurrs == False: # workaround for minute spinbutton having only 1 digit for minutes < 10 if minute < 10: minute = "0" + str(minute) command = setalarm_script + " " + str(hour) + ":" \ + str(minute) + " " + wakeup_script + " " + os.environ['USER'] + " " + alarmnum else: # Note, because shell=False in check_output, do not need to quote asterisks command = setalarm_script + ' -c ' + str(minute) + ' ' \ + str(hour) + ' ' + str(dom) + ' ' + str(mon) \ + ' ' + str(dow) + ' ' + wakeup_script + " " + os.environ['USER'] + " " + alarmnum command = ['pkexec', elevatescript] + re.split(" ", command) try: out = subprocess.check_output(command) return [0, out] except subprocess.CalledProcessError: return [1, ""] else: curcron = subprocess.check_output(['crontab', '-l']) curcron = re.sub("[^\n]*" + wakeup_script_meta + " " + os.environ['USER'] + " " \ + alarmnum + ".*\n", "", curcron) updatecron = subprocess.Popen(['crontab', '-'], stdin = subprocess.PIPE) newline = str(minute) + " " + str(hour) + " " + str(dom) + " " + str(mon) + " " + str(dow) + \ " " + wakeup_script + " " + os.environ['USER'] + " " + alarmnum + " >/dev/null 2>&1\n" updatecron.communicate(curcron + newline) return [0,""] def remove_command(self, folder, wakeup_script): alarmnum = re.search("alarm(\d+)$", folder).group(1) wakeup_script_meta = re.sub("/", "\\/", wakeup_script) sudo = [] if self.wakecomputer: sudo = ['pkexec', elevatescript] curcron = subprocess.check_output(sudo + ['crontab', '-l']) curcron = re.sub("[^\n]*" + wakeup_script_meta + " " + os.environ['USER'] + " " \ + alarmnum + ".*\n", "", curcron) updatecron = subprocess.Popen(sudo + ['crontab', '-'], stdin = subprocess.PIPE) updatecron.communicate(curcron) def get_cronvalues(self): if self.recurrence == "Cron": try: [minute, hour, dom, mon, dow] = re.split("\s+", self.cronvalue) except: print self.cronvalue + "\n Failed to set alarm. \nBad Cron setting" return [0, 0, 0, 0, 0] elif self.recurrence == "None": [minute, hour, dom, mon, dow] = [int(self.time[1]), int(self.time[0]), "-1", "-1", "-1"] now = datetime.datetime.now() if now.hour > hour or (now.hour == hour and now.minute >= minute): now = now + datetime.timedelta(days=1) (dom, mon) = (now.day, now.month) dow = "*" elif self.recurrence == "Month": [minute, hour, dom, mon, dow] = [int(self.time[1]), int(self.time[0]), int(self.dom), "*", "*"] elif self.recurrence == "Week": days = "" for i in self.day_recurrences.iterkeys(): if self.day_recurrences[i]: days += str(days_dict[i]) + "," days = days.rstrip(",") [minute, hour, dom, mon, dow] = [int(self.time[1]), int(self.time[0]), "*", "*", days] elif self.recurrence == "Day": [minute, hour, dom, mon, dow] = [int(self.time[1]), int(self.time[0]), "*", "*", "*"] elif self.recurrence == "Hour": [minute, hour, dom, mon, dow] = [int(self.time[1]), "*", "*", "*", "*"] elif self.recurrence == "Minute": [minute, hour, dom, mon, dow] = ["*", "*", "*", "*", "*"] return [minute, hour, dom, mon, dow] data/scripts/wakeup-settings000775 001750 001750 00000114362 12307140655 017346 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # Runs the GUI for user to set alarms and their preferences. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade from pango import SCALE import os import re import sys import copy import pickle import threading import subprocess import dbus # Global file variables wakeup_script = "/usr/bin/wakeup" setalarm_script = "/usr/bin/setalarm" wakeup_folder = "/usr/share/wakeup/" setnextalarmscript = os.path.join(wakeup_folder, "setnextalarm.py") script_folder = os.path.join(wakeup_folder, "plugin_scripts") pluginsettingsfolder = os.path.join(wakeup_folder, "plugin_settings") defaultpluginsfolder = os.path.join(wakeup_folder, "default_plugin_confs") home = os.environ['HOME'] homewakeupfolder = os.path.join(home, ".wakeup") dontshowintrofile = os.path.join(homewakeupfolder, "dontshowintro") tmpPlayfile = os.path.join(homewakeupfolder, "playable_tmp") voicelistscript = os.path.join(wakeup_folder, "voice_list.sh") elevatescript = os.path.join(wakeup_folder, 'wakeupRootHelper') # import alarm data type sys.path.append(wakeup_folder) from alarm import alarm # import plugin preferences GUI python scripts for root, dirs, files in os.walk(script_folder): for d in dirs: sys.path.append(os.path.join(root, d)) if os.path.exists(os.path.join(root, d, d + ".py")): exec("import " + d) class Wakeup: def __init__(self): # GUI Initialization # self.wTree = gtk.Builder() self.wTree.add_from_file(os.path.join(wakeup_folder, "wakeup.glade")) self.wTree.connect_signals(self) self.window = self.wTree.get_object("window") self.plugin_window = self.wTree.get_object("plugin_window") self.help = self.wTree.get_object("help_window") '''Main window objects''' self.treemodel = self.wTree.get_object("liststore1") self.treeview = self.wTree.get_object("treeview1") self.textbox = self.wTree.get_object("textbuffer1") self.textview = self.wTree.get_object("textview1") self.parentVbox = self.wTree.get_object("vbox10") self.alarmTreeView = self.wTree.get_object("treeview4") self.alarmlist = self.wTree.get_object("liststore5") self.TimeColumn = self.wTree.get_object("cellrenderertext7") self.RecurrenceColumn = self.wTree.get_object("cellrenderertext8") self.BootColumn = self.wTree.get_object("cellrenderertoggle3") self.prefsbutton = self.wTree.get_object("button7") self.playbutton = self.wTree.get_object("button2") self.removebutton = self.wTree.get_object("toolbutton2") '''Help window objects''' self.help_tabs = self.wTree.get_object("notebook2") '''Dialog box -- after applying alarm''' self.dialogWindow = self.wTree.get_object("dialog1") self.dialogMessage = self.wTree.get_object("label13") '''Intro Dialog Box''' self.introdialog = self.wTree.get_object("dialog2") self.showintro = self.wTree.get_object("checkbutton10") self.label = self.wTree.get_object("label1") '''Plugin preferences window objects''' self.treemodel2 = self.wTree.get_object("liststore2") self.voicelist = self.wTree.get_object("liststore4") self.voiceTreeView = self.wTree.get_object("treeview3") self.voicetogglerenderer = self.wTree.get_object("cellrenderertoggle2") self.voicetextrenderer = self.wTree.get_object("cellrenderertext5") self.useothervoice = self.wTree.get_object("checkbutton9") self.othervoicecommand = self.wTree.get_object("entry2") self.voicelabel = self.wTree.get_object("label17") self.startcomputer = self.wTree.get_object("checkbutton11") self.preferences_tabs = self.wTree.get_object("notebook1") self.time_frame = self.wTree.get_object("hbox6") self.hour_spin = self.wTree.get_object("spinbutton1") self.minute_spin = self.wTree.get_object("spinbutton2") self.hour_adj = self.wTree.get_object("adjustment2") self.minute_adj = self.wTree.get_object("adjustment3") self.recurrence_frame = self.wTree.get_object("vbox6") self.recurrence = self.wTree.get_object("checkbutton1") self.every_rec_list_box = self.wTree.get_object("combobox1") self.every_rec_list = self.wTree.get_object("liststore3") self.dom_label = self.wTree.get_object("label4") self.dom_spin = self.wTree.get_object("spinbutton3") self.volume_adj = self.wTree.get_object("adjustment1") self.cron_radio = self.wTree.get_object("radiobutton2") self.every_radio = self.wTree.get_object("radiobutton1") self.cron_entry = self.wTree.get_object("entry1") self.plugin_prefs_button = self.wTree.get_object("button12") self.pluginTreeView = self.wTree.get_object("treeview2") self.active_list = self.wTree.get_object("cellrenderertoggle1") self.days = list() # store the weekday checkbuttons in a list for i in range(2,9): self.days.append(eval("self.wTree.get_object(\"checkbutton" + str(i) + "\")")) '''Visual Tweaks''' # Set default window icon (applies to plugin preference window also) gtk.window_set_default_icon_name(self.window.get_icon_name()) # Set the preferences window as modal to the main window self.plugin_window.set_modal(True) self.plugin_window.set_transient_for(self.window) # Center the 'Active' checkbuttons in the plugins list self.active_list.set_property('width', 40) self.active_list.set_property('xalign', 0.5) # Center the Time, Recurrence, and Boot columns in the alarms list self.TimeColumn.set_property('xalign', 0.5) self.RecurrenceColumn.set_property('xalign', 0.5) self.RecurrenceColumn.set_property('width', 80) self.BootColumn.set_property('xalign', 0.5) self.BootColumn.set_property('width', 40) # allow for checking which plugin is selected (can't do through glade) self.plugin_selection = self.pluginTreeView.get_selection() self.plugin_selection.connect('changed', self.on_plugin_selected) # allow for checking which voice is selected (can't do through glade) self.voice_selection = self.voiceTreeView.get_selection() self.voice_selection.connect('changed', self.on_voice_selected) # allow for checking which alarm is selected (can't do through glade) self.alarm_selection = self.alarmTreeView.get_selection() self.alarm_selection.connect('changed', self.on_alarm_selected) self.old_alarm_selected = -1 # which list position is currently selected # tooltip text for voice list descriptions self.voiceTreeView.set_tooltip_column(2) # Make voice toggle look like radio buttons (can't do through glade) self.voicetogglerenderer.set_radio(True) self.voicetogglerenderer.set_property('width', 25) self.voicetogglerenderer.set_property('xalign', 0.5) # make stock buttons show images if possible try: gtk.settings_get_for_screen(gtk.gdk.Screen()).\ set_property("gtk-button-images", True) except: pass # Class Variables Initialization # self.currentalarm = -1 self.alarms = list() self.alarmfolders = list() self.alarmsjustcreated = list() self.voicedescriptions = {} self.plugins = dict() # Initialize Plugins # for pluginfile in os.listdir(pluginsettingsfolder): filename = os.path.join(pluginsettingsfolder, pluginfile) match = re.search(".*\.plugin$", filename) if match: plugin_file = open(filename) plugin = pickle.load(plugin_file) plugin_file.close() name = plugin['name'] del plugin['name'] plugin['script'] = os.path.join(script_folder, plugin['script']) self.plugins[name] = plugin myiter = self.treemodel2.insert_after(None, None) self.treemodel2.set_value(myiter, 0, name) self.treemodel2.set_value(myiter, 1, plugin['description']) self.treemodel2.set_value(myiter, 2, True) '''Create plugins folder if it doesn't exist''' # create main wakeup folder in home directory if it doesn't exist if not os.path.exists(homewakeupfolder): os.mkdir(homewakeupfolder) # Voice List Initialization # voicethread = self.voicelistThread(self) voicethread.start() # Alarms Settings Initialization # for foldername in os.listdir(homewakeupfolder): '''Create alarms''' folder = os.path.join(homewakeupfolder, foldername) if not re.search("alarm\d+$", folder) or not os.path.isdir(folder): continue self.add_alarm(None, foldername) '''Read alarm settings''' print foldername + ": " + self.alarms[-1].read_settings(os.path.join(folder, "wakeup_settings")) self.textbox.set_text(self.alarms[-1].get_property("text")) # Initialize Plugin Preferences # '''Create plugins folder if it doesn't exist''' pluginsfolder = os.path.join(folder, "plugins") if not os.path.exists(pluginsfolder): os.mkdir(pluginsfolder) for folder in os.listdir(defaultpluginsfolder): defaultpluginfolder = os.path.join(defaultpluginsfolder, folder) pluginfolder = os.path.join(pluginsfolder, folder) if os.path.isdir(defaultpluginfolder) and not os.path.exists(pluginfolder): subprocess.call(["cp", "-R", defaultpluginfolder, pluginfolder]) '''Setup the GUI alarm list''' myiter = self.alarmlist.get_iter_first() self.change_alarmlist_item(self.alarms[-1], myiter) self.alarm_selection.select_path(self.alarmlist.get_path(myiter)) # For reference when deleting removed alarms on clicking "Apply" self.oldalarmfolders = list(self.alarmfolders) self.oldalarms = copy.deepcopy(self.alarms) if len(self.alarms) == 0: self.add_alarm(None) '''Show intro dialog''' if not os.path.exists(dontshowintrofile): self.introdialog.show() # Thread so we don't have to wait for autolocation to be found class voicelistThread (threading.Thread): def __init__(self, mainSelf): self.window = mainSelf threading.Thread.__init__(self) def run(self): try: output = subprocess.check_output(voicelistscript) except subprocess.CalledProcessError as e: output = e.output voicesanddescripts = re.split("\n", output) for i in range(0, len(voicesanddescripts)-1): if i % 2 == 1: continue description = voicesanddescripts[i+1] voice = voicesanddescripts[i] myiter = self.window.voicelist.insert_after(None, None) if len(voicesanddescripts[i+1]) > 50: self.window.voicelist.set_value(myiter, 2, description) description = description[0:50] + "..." # Workaround for different voices with identical descriptions while description in self.window.voicedescriptions.keys(): description = description + ' ' self.window.voicelist.set_value(myiter, 0, description) self.window.voicedescriptions[description] = voice '''Workaround for auto-wrap glade labels not resizing''' def _label_size_allocate(self, widget, allocation, data=None): layout = widget.get_layout() lw_old, lh_old = layout.get_size() # fixed width labels if lw_old / SCALE == allocation.width: return # set wrap width to the pango.Layout of the labels # the - 2 is for breathing room for some fonts. layout.set_width((allocation.width - 2) * SCALE) lw, lh = layout.get_size() # lw is unused. if lh_old != lh: widget.set_size_request(-1, lh / SCALE) '''Add item to list of available data items (treeview in main window)''' def add_data_item(self, value): myiter = self.treemodel.append() self.treemodel.set_value(myiter,0,value) return myiter '''Exit''' def on_window_destroy (self, widget, data=None): if os.path.exists(tmpPlayfile): os.remove(tmpPlayfile) gtk.main_quit() gtk.main_quit() '''Callback for clicking Close in main window''' def cancel_clicked (self, widget, data=None): for i in range(0, len(self.alarmsjustcreated)): if self.alarmsjustcreated[i]: subprocess.call(["rm", "-R", self.alarmfolders[i]]) self.on_window_destroy(self, widget) '''Callback for clicking Apply in main window''' def apply_clicked (self, widget, data=None): # Make sure user's crontab is installed try: subprocess.check_output(['crontab', '-l']) except subprocess.CalledProcessError: newcron = subprocess.Popen(['crontab', '-'], stdin = subprocess.PIPE) newcron.communicate("") # Get elevated privileges if needed; every call to sudo in alarm.py and setnextalarm.py # will then be carried out. for alarm in self.oldalarms + self.alarms: if alarm.get_property("wakecomputer"): try: action_id='com.ubuntu.wakeup.exec' bus = dbus.SystemBus() service = bus.get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority') policy_kit=dbus.Interface(service, 'org.freedesktop.PolicyKit1.Authority') system_bus_name = bus.get_unique_name() result = policy_kit.CheckAuthorization(('system-bus-name', {'name' : system_bus_name}), action_id, {}, 1, '') if not result[0]: raise BaseException # Make sure root's crontab is installed try: subprocess.check_output(['pkexec', elevatescript, '/usr/bin/crontab', '-l']) except subprocess.CalledProcessError: newcron = subprocess.Popen(['pkexec', elevatescript, '/usr/bin/crontab', '-'], stdin = subprocess.PIPE) newcron.communicate("") except BaseException as e: print e.args outscript = 'Unable to set alarms. Root privileges needed if using boot option.' self.dialogMessage.set_text(outscript.strip()) self.dialogWindow.show() return break for i in range(0, len(self.alarmsjustcreated)): self.alarmsjustcreated[i] = False self.on_alarm_selected(None) # make sure current text is saved for i in range(0, len(self.alarms)): if not os.path.exists(self.alarmfolders[i]): os.mkdir(self.alarmfolders[i]) subprocess.call(["cp", "-R", defaultpluginsfolder, os.path.join(self.alarmfolders[i], "plugins")]) folder = re.search("alarm\d+", self.alarmfolders[i]).group(0) self.alarms[i].save_playfile(os.path.join(self.alarmfolders[i], "playable_text"), folder, False, self.plugins) self.alarms[i].save_settings(os.path.join(self.alarmfolders[i], "wakeup_settings")) # delete removed alarms for folder in self.oldalarmfolders: if not folder in self.alarmfolders: subprocess.call(["rm", "-rf", folder]) hadbootalarms = False for alarm in self.oldalarms: if alarm.get_property("wakecomputer") == True: hadbootalarms = True else: alarmfolder = self.oldalarmfolders[self.oldalarms.index(alarm)] foldernumber = re.search("\d+", alarmfolder).group(0) alarm.remove_command(self.oldalarmfolders[self.oldalarms.index(alarm)], wakeup_script) # Set the alarms and remove removed boot alarms hasbootalarms = False success = True outscript = "" for alarm in self.alarms: if not alarm.get_property("wakecomputer"): folder = self.alarmfolders[self.alarms.index(alarm)] [success, out] = alarm.setalarm_command(folder, setalarm_script, wakeup_script) success = (success == 0) else: hasbootalarms = True if hasbootalarms or hadbootalarms: #note also removes removed boot alarms. output = "" try: output = subprocess.check_output(['pkexec', elevatescript, setnextalarmscript, os.environ['USER']]) if not len(self.alarms) == 0 and not output == "": outscript += "Next computer wakeup at: " + output except subprocess.CalledProcessError as e: success = False outscript += e.output if success == False: outscript = "Unable to set all alarms. Check time preferences.\n" + outscript else: outscript = "All alarms set successfully.\n" + outscript # reset alarm list self.oldalarmfolders = list(self.alarmfolders) self.oldalarms = copy.deepcopy(self.alarms) self.dialogMessage.set_text(outscript.strip()) self.dialogWindow.show() '''Callback for clicking Okay in the dialog window''' def on_dialog_ok_clicked(self, widget, data=None): self.dialogWindow.hide() self.dialogWindow.resize(1,1) return True '''Callback for clicking Play in main window''' def on_play_clicked (self, widget, data=None): self.on_alarm_selected(None) alarm = self.alarms[self.currentalarm] folder = re.search("alarm\d+", self.alarmfolders[self.currentalarm]).group(0) alarm.save_playfile(tmpPlayfile, folder, True, self.plugins) subprocess.call([wakeup_script, os.environ['USER'], re.search("\d+",folder).group(0), "test", "&"]) '''Callback for clicking Help in main window''' def help_clicked (self, widget, data=None): if widget.get_label() == "gtk-about": self.help_tabs.set_current_page(1) else: self.help_tabs.set_current_page(0) self.help.show() '''Callback for clicking Preferences in main window''' def preferences_clicked (self, widget, data=None): if self.plugin_window.get_property('visible'): return alarm = self.alarms[self.currentalarm] time = alarm.get_property("time") self.hour_adj.set_value(time[0]) self.minute_adj.set_value(time[1]) recurrence = alarm.get_property("recurrence") if recurrence != "Cron" and recurrence != "None": recurrences = dict(Minute=0, Hour=1, Day=2, Week=3, Month=4) self.every_rec_list_box.set_active(recurrences[recurrence]) self.recurrence.set_active(recurrence != "None") self.cron_radio.set_active(recurrence == "Cron") self.every_radio.set_active(recurrence != "Cron") day_recurrences = alarm.get_property("day_recurrences") for day in self.days: day.set_active(day_recurrences[day.get_label()]) if alarm.get_property("recurrence") == "Month": self.dom_spin.set_value(float(alarm.get_property("dom"))) else: self.dom_spin.set_value(1) (minute, hour, dom, mon, dow) = alarm.get_cronvalues() self.cron_entry.set_text(str(minute) + " " + str(hour) + " " + str(dom) + " " + str(mon) + " " + str(dow)) self.startcomputer.set_active(alarm.get_property("wakecomputer")) self.othervoicecommand.set_text(alarm.get_property("otherspeechtool")) self.useothervoice.set_active(alarm.get_property("otherspeechtool") != "none") item = self.voicelist.get_iter_first() while item: self.voicelist.set_value(item, 1, False) if self.voicedescriptions[self.voicelist.get_value(item, 0)] == alarm.get_property("voice"): self.voicelist.set_value(item, 1, True) self.voice_selection.select_path(self.voicelist.get_path(item)) item = self.voicelist.iter_next(item) self.volume_adj.set_value(alarm.get_property("volume")) self._set_active_GUI_settings_elements() item = self.treemodel2.get_iter_first() plugins = alarm.get_property("activeplugins") if item: while item: name = self.treemodel2.get_value(item, 0) self.treemodel2.set_value(item, 2, name in plugins) item = self.treemodel2.iter_next(item) self.plugin_window.show() self.preferences_tabs.set_current_page(0) def on_preferences_esc_pressed(self, widget, data=None): if data.keyval == 65307: #ESC key self.on_plugins_cancel_clicked(widget) '''Callback for clicking Cancel in plugins window''' def on_plugins_cancel_clicked (self, widget, data=None): # Restore the backup of previously active plugins and remake plugin list self.plugin_window.hide() return False '''Callback for clicking Ok in plugins window''' def on_plugins_ok_clicked (self, widget, data=None): alarm = self.alarms[self.currentalarm] # Set all alarm properties alarm.set_property("time", [int(self.hour_spin.get_value()), int(self.minute_spin.get_value())]) alarm.set_property("recurrs", self.recurrence.get_active()) if not self.recurrence.get_active(): alarm.set_property("recurrence", "None") elif self.every_radio.get_active(): active = self.every_rec_list_box.get_active() rec_pos = self.every_rec_list.get_iter_from_string(str(active)) alarm.set_property("recurrence", self.every_rec_list.get_value(rec_pos, 0)) elif self.cron_radio.get_active(): alarm.set_property("recurrence", "Cron") alarm.set_property("cronvalue", self.cron_entry.get_text()) for checkbutton in self.days: day = checkbutton.get_property("label") active = checkbutton.get_property("active") alarm.set_property("day_recurrences['" + day + "']", active) alarm.set_property("dom", self.dom_spin.get_value()) for row in self.voicelist: if row[1]: alarm.set_property("voice", self.voicedescriptions[row[0]]) break if self.useothervoice.get_active(): alarm.set_property("otherspeechtool", self.othervoicecommand.get_text()) else: alarm.set_property("otherspeechtool", "none") alarm.set_property("wakecomputer", self.startcomputer.get_active()) alarm.set_property("volume", self.volume_adj.get_value()) # set active plugins activeplugins = list() item = self.treemodel2.get_iter_first() if item: while item: name = self.treemodel2.get_value(item, 0) if self.treemodel2.get_value(item, 2): activeplugins.append(name) item = self.treemodel2.iter_next(item) alarm.set_property("activeplugins", activeplugins) if "Commands" in activeplugins: alarmfolder = self.alarmfolders[self.currentalarm] command_pref_file = os.path.join(alarmfolder, 'plugins/Commands/Commands.config') c_pref_file = open(command_pref_file, "r") self.lines = ''.join(c_pref_file.readlines()) c_pref_file.close() old_items = re.search("dataitems=(.*)", self.lines).group(1).split(",") if old_items == ['']: old_items = [] alarm.set_property("Commands_dataitems", old_items) myiter = self.alarmlist.get_iter_from_string(str(self.currentalarm)) self.change_alarmlist_item(alarm, myiter) self.on_alarm_selected(None) self.plugin_window.hide() '''Callback on selecting a plugin from the plugins list''' def on_plugin_selected(self, widget, data=None): model, paths = widget.get_selected_rows() position_selected = self.treemodel2.get_iter_from_string(str(paths[0][0])) plugin = self.treemodel2.get_value(position_selected, 0) self.plugin_prefs_button.set_sensitive(self.plugins[plugin]['has_preferences']) '''Callback for clicking preferences in the plugins window''' def on_plugin_preferences_clicked(self, widget, data=None): model, paths = self.plugin_selection.get_selected_rows() position_selected = self.treemodel2.get_iter_from_string(str(paths[0][0])) plugin = self.treemodel2.get_value(position_selected, 0) # run the plugin's preferences python script. Plugin script must # be named the same as its folder and the object must also have that # same name. Only allow a script to be run if no other plugin script is # running try: self.prefsOpen except: self.prefsOpen = False #if first time clicking preferences if not self.prefsOpen: plugin = re.search("/([^/]*)/[^/]*$", self.plugins[plugin]['script']).group(1) os.chdir(os.path.join(script_folder, plugin)) self.prefsOpen = True pluginfolder = os.path.join(self.alarmfolders[self.currentalarm], "plugins", plugin) exec("pluginPref = " + plugin + "." + plugin + "('" + pluginfolder + "')") pluginPref.window.set_modal(True) # This next line actually makes it impossible to close plugin preferences more than once #pluginPref.window.set_transient_for(self.plugin_window) # TODO: This doesn't seem to work at the moment, so all plugin # glade files have the hint set to dialog individually. # pluginPref.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) pluginPref.main() self.prefsOpen = False return False '''Callback for toggling availability of a plugin by checking a box''' def on_plugin_toggled (self, widget, data=None): position_toggled = self.treemodel2.get_iter_from_string(data) new_value = not self.treemodel2.get_value(position_toggled, 2) plugin = self.treemodel2.get_value(position_toggled, 0) self.treemodel2.set(position_toggled, 2, new_value) '''Callback for toggling availability of a plugin by double-clicking name''' def on_pluginlist_clicked (self, widget, data=None, treeviewcolumn=None): # redirect to on_plugin_toggled self.on_plugin_toggled (widget, str(data[0])) '''Callback for double-clicking a data item (from treeview in main window)''' def on_datalist_clicked (self, widget, data=None, treeviewcolumn=None): # insert the doubled-clicked data item into the text position_clicked = self.treemodel.get_iter_from_string(str(data[0])) value = self.treemodel.get_value(position_clicked, 0) bounds = self.textbox.get_selection_bounds() if (bounds): self.textbox.delete(bounds[0], bounds[1]) self.textbox.insert_at_cursor(value) '''Callback for checking "Recurrs" in the preferences window''' def on_recurrence_toggled (self, widget, data=None): self.recurrence_frame.set_sensitive(widget.get_active()) self._set_active_GUI_settings_elements() '''Callback for changing recurrence combobox''' def on_every_recurrence_changed (self, widget, data=None): self._set_active_GUI_settings_elements() '''Callback for selecting cron format''' def cron_radio_toggled (self, widget, data=None): self._set_active_GUI_settings_elements() '''Callback for selecting non-cron format''' def every_radio_toggled (self, widget, data=None): self._set_active_GUI_settings_elements() '''Set up the alarm General GUI settings properly (what's sensitive)''' def _set_active_GUI_settings_elements (self): cron_active = self.cron_radio.get_active() recurrs = self.recurrence.get_active() self.cron_entry.set_sensitive(cron_active) self.every_rec_list_box.set_sensitive(not cron_active) active = self.every_rec_list_box.get_active() position = self.every_rec_list.get_iter_from_string(str(active)) value = self.every_rec_list.get_value(position, 0) for day in self.days: day.set_sensitive(value == "Week" and not cron_active) self.dom_label.set_sensitive(value == "Month" and not cron_active) self.dom_spin.set_sensitive(value == "Month" and not cron_active) self.hour_spin.set_sensitive(not (recurrs and (value == "Hour" or value == "Minute" or cron_active))) self.minute_spin.set_sensitive(not (recurrs and (value == "Minute" or cron_active))) '''Callback for selecting a voice in the Voices tab of Preferences window''' def on_voice_selected(self, widget, data=None): model, paths = self.voice_selection.get_selected_rows() position_selected = self.voicelist.get_iter_from_string(str(paths[0][0])) self._set_voice(position_selected) '''Callback for selecting the radiobutton off a voice in the Voices tab''' def on_voice_toggled(self, widget, data=None): position_toggled = self.voicelist.get_iter_from_string(data) self._set_voice(position_toggled) '''Set voice''' def _set_voice(self, position): description = self.voicelist.get_value(position, 0) voice = self.voicedescriptions[description] item = self.voicelist.get_iter_first() while item: if self.voicelist.get_value(item, 1): self.voicelist.set_value(item, 1, False) item = self.voicelist.iter_next(item) self.voicelist.set_value(position, 1, True) '''Callback for toggling "use other speech tool" in Voices tab''' def on_nonfestival_toggled(self, widget, data=None): active = widget.get_active() self.othervoicecommand.set_sensitive(active) self.voiceTreeView.set_sensitive(not active) self.voicelabel.set_sensitive(not active) def on_help_esc_pressed (self, widget, data=None): if data.keyval == 65307: #ESC key self.on_help_ok_clicked(widget) def on_help_ok_clicked (self, widget, data=None): self.help.hide() return True '''Callback for clicking ok in the introduction dialog''' def on_introdialog_ok_clicked(self, widget, data=None): if not self.showintro.get_active(): file = open(dontshowintrofile, "w") file.close() self.introdialog.hide() '''Callback for clicking the multiple alarms expander''' def on_expander_clicked(self, widget, data=None): if widget.get_expanded(): widget.set_label("Edit multiple alarms...") self.parentVbox.set_child_packing(widget, False, False, 0, "start") else: widget.set_label("Hide multiple alarms...") self.parentVbox.set_child_packing(widget, True, True, 0, "start") '''Callback for clicking to add an alarm''' def add_alarm(self, widget, data=None): self.alarms.append(alarm()) folderspresent = list() for i in self.alarmfolders: folderspresent.append(int(re.search("\d+", i).group(0))) for foldername in os.listdir(homewakeupfolder): folder = os.path.join(homewakeupfolder, foldername) match = re.search("alarm(\d+)$", folder) if not match or not os.path.isdir(folder): continue if not int(match.group(1)) in folderspresent: folderspresent.append(int(match.group(1))) old_num_alarmfolders = len(self.alarmfolders) newalarmfolder = "" if data != None: newalarmfolder = os.path.join(homewakeupfolder, data) elif len(folderspresent) != 0: for i in range(0, max(folderspresent)): if not i in folderspresent: newalarmfolder = os.path.join(homewakeupfolder, "alarm" + str(i)) break if len(self.alarmfolders) == old_num_alarmfolders and newalarmfolder == "": newalarmfolder = os.path.join(homewakeupfolder, "alarm" + str(max(folderspresent) + 1)) else: newalarmfolder = os.path.join(homewakeupfolder, "alarm0") self.alarmfolders.append(newalarmfolder) if len(self.alarms[-1].get_property("activeplugins")) == 0: plugins = list() for pluginname in self.plugins: plugins.append(pluginname) self.alarms[-1].set_property("activeplugins", plugins) myiter = self.alarmlist.append() if len(folderspresent) == 0: startiter, enditer = self.textbox.get_bounds() self.alarms[-1].set_property("text", self.textbox.get_text(startiter, enditer)) self.change_alarmlist_item(self.alarms[-1], myiter) self.alarm_selection.select_path(self.alarmlist.get_path(myiter)) self.alarmsjustcreated.append(not os.path.exists(self.alarmfolders[-1])) if self.alarmsjustcreated[-1]: os.mkdir(self.alarmfolders[-1]) subprocess.call(["cp", "-R", defaultpluginsfolder, os.path.join(self.alarmfolders[-1], "plugins")]) '''Update alarm list entry''' def change_alarmlist_item(self, alarm, treeiter): text = re.sub("\s+", " ", alarm.get_property("text")) if len(text) > 50: text = text[0:50] + "..." else: text = text[0:50] time = alarm.get_property("time") time_text = "" recurrence = alarm.get_property("recurrence") if recurrence == "Hour" or recurrence == "Minute": time_text += "*:" else: time_text += str(time[0]) + ":" if recurrence == "Minute": time_text += "*" else: if time[1] < 10: time_text += "0" + str(time[1]) else: time_text += str(time[1]) self.alarmlist.set_value(treeiter, 0, text) if not recurrence == "Cron": self.alarmlist.set_value(treeiter, 1, time_text) else: cron_values = re.split(" ", alarm.get_property("cronvalue")) self.alarmlist.set_value(treeiter, 1, cron_values[1] + ":" + cron_values[0]) self.alarmlist.set_value(treeiter, 2, alarm.get_property("recurrence")) self.alarmlist.set_value(treeiter, 3, alarm.get_property("wakecomputer")) '''Callback for clicking to remove an alarm''' def remove_alarm(self, widget, data=None): pos = int(self.currentalarm) if self.alarmsjustcreated[pos]: subprocess.call(["rm", "-R", self.alarmfolders[pos]]) del self.alarmsjustcreated[pos] position_selected = self.alarmlist.get_iter_from_string(str(pos)) if pos != 0: myiter = self.alarmlist.get_iter_from_string(str(pos - 1)) self.alarm_selection.select_path(self.alarmlist.get_path(myiter)) elif len(self.alarmlist) != 1: myiter = self.alarmlist.get_iter_from_string(str(pos + 1)) self.alarm_selection.select_path(self.alarmlist.get_path(myiter)) self.old_alarm_selected = 0 self.currentalarm = 0 else: self.textbox.set_text("") self.textview.set_sensitive(False) self.old_alarm_selected = -1 self.treemodel.clear() self.treeview.set_sensitive(False) self.prefsbutton.set_sensitive(False) self.playbutton.set_sensitive(False) self.removebutton.set_sensitive(False) del self.alarmlist[pos] del self.alarms[pos] del self.alarmfolders[pos] '''Callback for selecting an alarm from the list''' def on_alarm_selected(self, widget, data=None): model, paths = self.alarm_selection.get_selected_rows() if len(paths) == 0: return self.textview.set_sensitive(True) self.treeview.set_sensitive(True) self.prefsbutton.set_sensitive(True) self.playbutton.set_sensitive(True) self.removebutton.set_sensitive(True) self.currentalarm = paths[0][0] position_selected = self.alarmlist.get_iter_from_string(str(self.currentalarm)) alarm = self.alarms[self.currentalarm] if self.old_alarm_selected != -1: oldpos = self.alarmlist.get_iter_from_string(str(self.old_alarm_selected)) oldalarm = self.alarms[self.old_alarm_selected] startiter, enditer = self.textbox.get_bounds() oldalarm.set_property("text", self.textbox.get_text(startiter, enditer)) self.change_alarmlist_item(oldalarm, oldpos) self.textbox.set_text(alarm.get_property("text")) self.change_alarmlist_item(alarm, position_selected) self.old_alarm_selected = self.currentalarm # load data item list self.treemodel.clear() for pluginname in self.plugins.keys(): if pluginname in alarm.get_property("activeplugins"): for item in self.plugins[pluginname]['data_items']: self.add_data_item("$" + item) # Add in dynamic dataitems from Command plugin if "Commands" in alarm.get_property("activeplugins"): for item in alarm.get_property("Commands_dataitems"): self.add_data_item("$" + item) def on_introdialog_destroy(self, widget, data=None): self.introdialog.hide() '''Run the GUI''' def main(self): gtk.gdk.threads_init() gtk.main() '''Run the program''' if __name__ == "__main__": wake = Wakeup() wake.main() data/wakeup/default_plugin_confs/News/000770 001750 001750 00000000000 11741113010 021147 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/News/read_news.py000775 001750 001750 00000001330 11741113010 022350 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin script for News outputting news items from an rss feed # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import feedparser import re import sys import os plugin_file = '/home/' + sys.argv[1] + '/.wakeup/' + os.environ['ALARM'] + \ '/plugins/News/News.config' rs_file = open(plugin_file, "r") lines = ''.join(rs_file.readlines()) rss_url = re.search("rss_feed\s*=\s*(.*)\s*", lines).group(1) max_feeds = int(float(re.search("max_feeds\s*=\s*(.*)\s*", lines).group(1))) feed = feedparser.parse(rss_url) j = 1; for i in feed.entries: print i.title + ". ", if j >= max_feeds: break j = j + 1 data/wakeup/plugin_scripts/Weather/get_weather.py000775 001750 001750 00000006002 12233751456 023406 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # get weather for Weather # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import re import pywapi, urllib2 import sys, os # Get unit preferences plugin_file = open('/home/' + sys.argv[1] + '/.wakeup/' + os.environ['ALARM'] + '/plugins/Weather/Weather.config', 'r') plugin_text = ''.join(plugin_file.readlines()) plugin_file.close() temp_unit = re.search("temperature_units=(.*)", plugin_text).group(1) wind_unit = re.search("wind_units=(.*)", plugin_text).group(1) if (wind_unit == "mph"): wind_unit = "miles per hour" manual_location = re.search("location=(.*)", plugin_text).group(1) if (manual_location != 'none'): # Using manual location place = manual_location #weather = pywapi.get_weather_from_yahoo(manual_location) else: # Get location sys.path.append('/usr/share/wakeup') import location loc = location.get_location() place = place = loc['City'] + ',' + loc['State'] + ',' + re.search('(.*?)\(',loc['Country']).group(1) url = 'http://xoap.weather.com/search/search?where=' + place req = urllib2.Request(url) response = urllib2.urlopen(req,'',5) page = response.read() yahooid=re.search('loc id="(.*?)"',page).group(1) # Get weather weather = pywapi.get_weather_from_yahoo(yahooid,units='') # Output the weather for out in sys.argv[2:len(sys.argv)]: if (out == "temperature"): temperature = weather['condition']['temp'] if temp_unit == "C": print '%g \n' %round(5.0/9*(float(temperature)-32)) else: print temperature + '\n' if (out == "skyconditions"): print weather['condition']['text'] + '\n' if (out == "humidity"): humidity = weather['atmosphere']['humidity'] if humidity == "": humidity = 'unknown' print humidity + '\n' if (out == "windconditions"): magnitude = weather['wind']['speed'] direction = weather['wind']['direction'] directions = ['north', 'north east', 'east', 'south east', 'south', 'south west', 'west', 'north west'] maxdirs = [22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5] directiontext='north' for i in range(1,len(directions)): if int(direction) > maxdirs[i-1] and int(direction) <= maxdirs[i]: directiontext=directions[i] if wind_unit == "knots": magnitude = int(round(float(magnitude) * 0.868976242)) print directiontext + " at " + str(magnitude) + " " + wind_unit + '\n' if (out == "high"): high = int(weather['forecasts'][0]['high']) if temp_unit == "C": print str(int(round((high - 32)*5/9))) + '\n' else: print str(high) + '\n' if (out == "low"): low = int(weather['forecasts'][0]['low']) if temp_unit == "C": print str(int(round((low - 32)*5/9))) + '\n' else: print str(low) + '\n' if (out == "todays_forecast"): print weather['forecasts'][0]['text'] + '\n' data/wakeup/plugin_scripts/Commands/run_commands.sh000775 001750 001750 00000001233 11741113010 023677 0ustar00dglassdglass000000 000000 #!/bin/bash # Run user-defined commands # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 IFS=, plugin_file=/home/$1/.wakeup/$ALARM/plugins/Commands/Commands.config dataitems=($(sed -rn 's/dataitems\s*=\s*(.*)\s*$/\1/p' $plugin_file)) scripts=($(sed -rn 's/scripts\s*=\s*(.*)\s*$/\1/p' $plugin_file)) # Make hash of dataitems->scripts declare -A itemscripts for (( i = 0; i < ${#dataitems[@]}; i++ )); do itemscripts[${dataitems[$i]}]=${scripts[$i]} done # Execute scripts and output any text output properly for item in ${*:2}; do eval ${itemscripts[$item]} 2>/dev/null; echo "" done data/wakeup/createRootPlayfile.py000775 001750 001750 00000001201 11741113010 020212 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # A separate file is needed to create the boot alarms playfile with root permissions pre-writing. # This script provides that file. Should be run as root. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import sys, os, stat text = ''.join(sys.stdin.readlines()) filename = sys.argv[1] # opens as 644 (group and others can only read, owner can't execute) f = open(filename, 'w') f.write(text) f.close() # changes permissions to 700 (add execute to owner, remove read from all others) os.chmod(filename, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR) data/wakeup/default_plugin_confs/GmailCounter/GmailCounter.config000664 001750 001750 00000000034 11741113010 026406 0ustar00dglassdglass000000 000000 username=yourname password= data/wakeup/plugin_settings/LastfmPlayer.plugin000664 001750 001750 00000000334 11741113010 023107 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Play music off of Last.fm' p2 sS'script' p3 S'LastfmPlayer/play_lastfm.sh' p4 sS'text_output' p5 I00 sS'data_items' p6 (lp7 S'lastfm' p8 asS'has_preferences' p9 I01 sS'name' p10 S'Last.fm' p11 s.doc/000770 001750 001750 00000000000 12015212231 012401 5ustar00dglassdglass000000 000000 doc/setalarm.1000664 001750 001750 00000004367 12315673767 014346 0ustar00dglassdglass000000 000000 .TH setalarm 1 "Version 1.4" "Mar 2014" .SH NAME setalarm \- sets the system to start and run a script at specified times. .SH SYNOPSIS .B setalarm [ \-p ] [ [h]h:mm ] [ \-o offset ] [ command ] .B setalarm [ \-p ] [ \-c m h dom mon dow ] [ \-o offset ] [ command ] .B setalarm [ \-p ] [ \-u utc ] [ \-o offset ] [ command ] .B setalarm \-d .SH DESCRIPTION This should be run as root, unless using the .B \-p option. The time to wake the computer can be given in three possible formats. The simplest is just a time, written hh:mm or h:mm. This time is interpreted as the earliest time in the future when that time occurs. If the .B \-c option is provided, a cron\-formatted recurrence (minute hour day_of_month month day_of_week) may follow. Special times such as "@hourly" are not accepted. With the .B \-u option, the time to wake the computer should be provided in UTC format. .P .B command is run at the closest time in the future that matches the recurrence rules or at the time specified using an exact hh:mm or UTC time. For this to occur, the computer is woken up several minutes in advance to allow for boot time. By default, this "offset" is 5 minutes, but can be changed with the .B \-o option, in which case the computer is woken up .B offset minutes in advance. To ensure that the computer will wake given the .B \-c option, crontab entries are made in root's crontab to rerun .B setalarm as necessary. .P With the .B \-p option, .B setalarm will not make any changes to the system wake time or to root's crontab. Instead, .B setalarm just prints the time, in UTC, at which the computer would be set to wake up with the given input. .P Given the .B \-d option, .B setalarm removes all alarms. .SH "NOTES" .B setalarm was created for use with \fBwakeup\fR, a fully customizable and extensible talking alarm clock. However, it is generally usable as a convenient wrapper for setting the system wakeup (see http://www.mythtv.org/wiki/ACPI_Wakeup for details about ACPI wakeup) .SH "SEE ALSO" \fBwakeup\fR(1), \fBwakeup\-settings\fR(1), \fBcron\fR, \fBcrontab\fR .SH AUTHOR The program and its documentation are copyrighted (C) 2012 by David Glass . All rights reserved. They are distributed under the terms of the GNU General Public License version 3 or later. data/wakeup/default_plugin_confs/Weather/000770 001750 001750 00000000000 11741113010 021632 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/MusicPlayer/MusicPlayer.py000664 001750 001750 00000006016 11741113010 024162 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for MusicPlayer # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class MusicPlayer: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("MusicPlayer.glade") self.window = self.wTree.get_object("window1") self.time = self.wTree.get_object("entry2") self.entry = self.wTree.get_object("entry1") self.plugin_file = os.path.join(pluginfolder, 'MusicPlayer.config') pl_file = open(self.plugin_file, "r") self.lines = ''.join(pl_file.readlines()) pl_file.close() old_music_file = re.search("music_file\s*=[ \t]*([^\n]*)\s*", self.lines).group(1) self.entry.set_text(old_music_file) old_time = re.search("time\s*=\s*(.*)\s", self.lines).group(1) self.time.set_text(old_time) self.wTree.connect_signals(self) self.chooser = gtk.FileChooserDialog(title=None, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) self.chooser.set_current_folder(os.environ['HOME']) if self.entry.get_text() != "": directory = re.search("(.*)/[^/]*", self.entry.get_text()).group(1) self.chooser.set_current_folder(directory) filter = gtk.FileFilter() filter.set_name("Audio files") filter.add_mime_type("audio/*") self.chooser.add_filter(filter) filter = gtk.FileFilter() filter.set_name("All files") filter.add_pattern("*") self.chooser.add_filter(filter) '''On Clicking Open''' def on_open_clicked(self, widget, data=None): response = self.chooser.run() if response == gtk.RESPONSE_OK: self.entry.set_text(self.chooser.get_filename()) self.chooser.hide() '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): if os.path.exists(self.entry.get_text()): self.lines = re.sub("music_file\s*=[ \t]*[^\n]*\s*", "music_file=" \ + self.entry.get_text() + "\n", self.lines) t = self.time.get_text() match = re.search("(.*):(.*)", t) if t.isdigit() or (match and match.group(1).isdigit() and match.group(2).isdigit()): self.lines = re.sub("time\s*=\s*.*\s*", "time=" \ + t + "\n", self.lines) pl_file = open(self.plugin_file, "w") pl_file.write(self.lines) pl_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy (self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/com.ubuntu.wakeup.policy000664 001750 001750 00000001434 11741113010 017367 0ustar00dglassdglass000000 000000 Wakeup https://launchpad.net/wakeup Authentication is required to modify Wakeup boot alarms Change boot alarms appointment-new no no auth_admin_keep /usr/share/wakeup/wakeupRootHelper data/wakeup.desktop000664 001750 001750 00000000346 11741113010 015444 0ustar00dglassdglass000000 000000 [Desktop Entry] Name=Wakeup Exec=wakeup-settings Icon=appointment-new Type=Application Categories=GNOME;GTK;Utility; Comment=A talking and fully customizable alarm clock that will operate from poweroff X-AppInstall-Package=wakeup data/wakeup/plugin_scripts/News/News.py000664 001750 001750 00000003645 11741113010 021325 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for News # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class News: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("News.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.rss_feed = self.wTree.get_object("entry1") self.num_max_feeds = self.wTree.get_object("spinbutton1") self.plugin_file = os.path.join(pluginfolder, 'News.config') rs_file = open(self.plugin_file, "r") self.lines = ''.join(rs_file.readlines()) rs_file.close() try: old_rss_feed = re.search("rss_feed\s*=\s*(.*)\s*", self.lines).group(1) old_max_feeds = re.search("max_feeds\s*=\s*(.*)\s*", self.lines).group(1) except: old_rss_feed = "" old_max_feeds = 1 self.rss_feed.set_text(old_rss_feed) self.num_max_feeds.set_value(float(old_max_feeds)) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): self.lines = re.sub("rss_feed\s*=( \t)*[^\n]*\n", "rss_feed=" \ + self.rss_feed.get_text() + "\n", self.lines) self.lines = re.sub("max_feeds\s*=\s*.*\s*", "max_feeds=" \ + str(self.num_max_feeds.get_value()) + "\n", self.lines) rs_file = open(self.plugin_file, "w") rs_file.write(self.lines) rs_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/wakeup/plugin_scripts/EvolutionData/EvolutionData.glade000664 001750 001750 00000012534 11741113010 025452 0ustar00dglassdglass000000 000000 250 250 True 6 Schedule Preferences False center dialog True 5 True 3 True True automatic automatic True True liststore1 False 0 List of calendars to ignore: 0 0 0 True True False False 1 True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 False 2 data/wakeup/plugin_settings/DateTime.plugin000664 001750 001750 00000000345 11741113010 022202 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Give the date and time' p2 sS'script' p3 S'DateTime/date_time.sh' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'date' p8 aS'time' p9 asS'has_preferences' p10 I01 sS'name' p11 S'Date and Time' p12 s. data/wakeup/default_plugin_confs/News/News.config000664 001750 001750 00000000077 11741113010 023263 0ustar00dglassdglass000000 000000 rss_feed=http://rss.cnn.com/rss/cnn_topstories.rss max_feeds=5 data/wakeup/000770 001750 001750 00000000000 12306400553 014052 5ustar00dglassdglass000000 000000 doc/wakeup-settings.1000664 001750 001750 00000002447 12315674024 015650 0ustar00dglassdglass000000 000000 .TH wakeup\-settings 1 "Version 1.4" "Mar 2014" .SH NAME wakeup\-settings \- GUI frontend to configure \fBwakeup\fR, a talking and fully customizable alarm clock .SH SYNOPSIS .B wakeup\-settings .SH DESCRIPTION This runs a graphical setting in which to edit the alarms run by .B wakeup. The time, volume, plugin settings, etc. for all alarms can be set through this GUI. Given the "set computer to wake up for alarm" option, .B wakeup is set by .B wakeup\-settings to run from root's cron, and the alarms will run in this case even if no user is logged in. One must log in or be logged in to stop the alarm. Settings only pertain to the user who is running .B wakeup\-settings. .P Note that for any part of the alarm which depends on information from the web to work when you are not logged in, you will need to set the wireless network(s) you connect to so that they connect before you log in. This can be done through NetworkManager, by selecting a connection, clicking "Edit..." and checking "Available to all users." .SH "SEE ALSO" \fBsetalarm\fR(1), \fBwakeup\fR(1), \fBcron\fR, \fBcrontab\fR .SH AUTHOR The program and its documentation are copyrighted (C) 2012 by David Glass . All rights reserved. They are distributed under the terms of the GNU General Public License version 3 or later. data/wakeup/plugin_scripts/GmailCounter/GmailCounter.py000664 001750 001750 00000003567 11741113010 024462 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for GmailCounter # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re import base64 class GmailCounter: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("GmailCounter.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.username = self.wTree.get_object("entry1") self.password = self.wTree.get_object("entry2") self.password_file = os.path.join(pluginfolder, 'GmailCounter.config') gs_file = open(self.password_file, "r") self.lines = ''.join(gs_file.readlines()) old_username = re.search("username\s*=\s*(.*)\s*password", self.lines).group(1) old_password = re.search("password\s*=\s*(.*)\s*", self.lines).group(1) self.username.set_text(old_username) self.password.set_text(base64.b64decode(old_password)) gs_file.close() '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): self.lines = re.sub("username\s*=\s*.*\s*", "username=" \ + self.username.get_text() + "\n", self.lines) self.lines = re.sub("password\s*=\s*.*\s*", "password=" \ + base64.b64encode(self.password.get_text()) + "\n", self.lines) gs_file = open(self.password_file, "w") gs_file.write(self.lines) gs_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/wakeup/plugin_scripts/EvolutionData/EvolutionData.py000664 001750 001750 00000005231 11741113010 025022 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for EvolutionData # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class EvolutionData: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("EvolutionData.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.add_cal = self.wTree.get_object("entry1") self.cals_view = self.wTree.get_object("treeview1") self.cals_list = self.wTree.get_object("liststore1") self.plugin_file = os.path.join(pluginfolder, "EvolutionData.config") ed_file = open(self.plugin_file, "r") self.lines = ''.join(ed_file.readlines()) exec("old_cals_list = [" + re.search("ignore_cals\s*=\s*\((.*)\)\s*", self.lines).group(1) + "]") for cal in old_cals_list: myiter = self.cals_list.append() self.cals_list.set_value(myiter, 0, cal) ed_file.close() '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): new_cals_list = '(' item = self.cals_list.get_iter_first() if item: while item: if new_cals_list != "(": new_cals_list += ", " new_cals_list += '"' + self.cals_list.get_value(item, 0) + '"' item = self.cals_list.iter_next(item) new_cals_list += ')' self.lines = re.sub("ignore_cals\\s*=\\s*.*\\s*", "ignore_cals=" \ + new_cals_list + "\n", self.lines) ed_file = open(self.plugin_file, "w") ed_file.write(self.lines) ed_file.close() self.on_window_destroy(self) '''On Pressing Enter in the entry box''' def on_calendar_add(self, widget, data=None): if data.keyval == 65293: #if enter is pressed in the entry myiter = self.cals_list.append() self.cals_list.set_value(myiter, 0, widget.get_text()) widget.set_text("") '''On pressing delete in the list''' def on_calendar_delete(self, widget, data=None): if data.keyval == 65535: # if delete is pressed entry1, entry2 = self.cals_view.get_selection().get_selected() self.cals_list.remove(entry2) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/000770 001750 001750 00000000000 12306406367 012567 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/Commands/000770 001750 001750 00000000000 11741113010 020647 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/News/News.glade000664 001750 001750 00000035426 11741113010 021753 0ustar00dglassdglass000000 000000 True 6 Rss Settings False center dialog True True 5 True rss feed url: False False 0 True True 1 0 True True Number of feed items to read: 0 True True False adjustment1 1 1 1 True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 2 True True For possible formats, see 'man date' 0 True 5 True Date format: False False 0 True True 1 1 True 5 True Time format: False False 0 True True 1 2 True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 3 True 5 True Date format: False False 0 True True 1 True Date format: True True True 5 True Time format: False False 0 True True 1 True Time format: True True True For possible formats, see 'man date' True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 gtk-ok True True True True gtk-cancel True True True True 1 100 1 10 data/wakeup/default_plugin_confs/Commands/Commands.config000664 001750 001750 00000000024 11741113010 024725 0ustar00dglassdglass000000 000000 dataitems= scripts= data/wakeup/plugin_settings/EvolutionData.plugin000664 001750 001750 00000000377 12027742445 023313 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Read Evolution schedule and tasks' p2 sS'script' p3 S'EvolutionData/read_evolution.py' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'todo' p8 aS'schedule' p9 asS'has_preferences' p10 I01 sS'name' p11 S'Evolution Data' p12 s. data/wakeup/default_plugin_confs/Commands/000770 001750 001750 00000000000 11741113010 021774 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/HebrewCalendar/000770 001750 001750 00000000000 11741113010 021754 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/LastfmPlayer/000770 001750 001750 00000000000 12306400553 021522 5ustar00dglassdglass000000 000000 data/wakeup/default_plugin_confs/HebrewCalendar/HebrewCalendar.config000664 001750 001750 00000000053 11741113010 027141 0ustar00dglassdglass000000 000000 longitude= latitude= manual_location=false setup.py000664 001750 001750 00000002227 12315673721 013400 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 from distutils.core import setup import os data_files=[ ('share/applications', ['data/wakeup.desktop']), ('share/man/man1', ['doc/wakeup.1']), ('share/man/man1', ['doc/setalarm.1']), ('share/man/man1', ['doc/wakeup-settings.1']), ('share/polkit-1/actions', ['data/com.ubuntu.wakeup.policy']) ] for root, dirs, files in os.walk('data/wakeup'): for f in files: dest = os.path.join('share', root.replace('data/', '')) filename = os.path.join(root, f) if os.path.isfile(filename): data_files.append((dest, [filename])) setup(name='wakeup', version='1.4', description='Fully customizable and extensible talking alarm clock', author='David Glass', author_email='dsglass@gmail.com', url='https://launchpad.net/wakeup', license='GPL v3', scripts=['data/scripts/wakeup-settings', 'data/scripts/wakeup', 'data/scripts/setalarm'], data_files=data_files ) data/wakeup/plugin_scripts/HebrewCalendar/HebrewCalendar.py000664 001750 001750 00000006444 11741113010 025211 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for Hebrew Calendar # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re import commands import threading class HebrewCalendar: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("HebrewCalendar.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.set_manual_location = self.wTree.get_object("checkbutton1") self.longitude = self.wTree.get_object("entry1") self.latitude = self.wTree.get_object("entry2") self.plugin_file = os.path.join(pluginfolder, 'HebrewCalendar.config') hc_file = open(self.plugin_file, "r") self.lines = ''.join(hc_file.readlines()) hc_file.close() old_manual_location = re.search("manual_location\s*=\s*(.*)\s*", self.lines).group(1) if old_manual_location == "true": old_longitude = re.search("longitude\s*=\s*(.*)\s*\n", self.lines).group(1) old_latitude = re.search("latitude\s*=\s*(.*)\s*", self.lines).group(1) else: old_longitude = "" old_latitude = "" self.set_manual_location.set_active(old_manual_location == "true") self.longitude.set_sensitive(old_manual_location == "true") self.latitude.set_sensitive(old_manual_location == "true") if old_manual_location == "false": thread = self.LonLatThread(self) thread.start() else: self.longitude.set_text(old_longitude) self.latitude.set_text(old_latitude) # Thread so we don't have to wait for autolocation to be found class LonLatThread (threading.Thread): def __init__(self, parent): self.window = parent threading.Thread.__init__(self) def run(self): import location loc = location.get_location() self.window.longitude.set_text(loc['longitude']) self.window.latitude.set_text(loc['latitude']) '''On Checking to set weather ID manually''' def on_manualLonLat_toggled(self, widget, data=None): self.longitude.set_sensitive(widget.get_active()) self.latitude.set_sensitive(widget.get_active()) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): if self.set_manual_location.get_active(): lon = self.longitude.get_text() lat = self.latitude.get_text() manual_location = "true" else: lon="" lat="" manual_location = "false" hc_file = open(self.plugin_file, "w") hc_file.write("longitude=" + lon + "\n") hc_file.write("latitude=" + lat + "\n") hc_file.write("manual_location=" + manual_location) hc_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.gdk.threads_init() gtk.main() data/wakeup/plugin_scripts/DateTime/date_time.sh000775 001750 001750 00000001121 11741113010 023074 0ustar00dglassdglass000000 000000 #!/bin/bash # plugin script for DateTime outputting current date and/or time # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 plugin_file=/home/$1/.wakeup/$ALARM/plugins/DateTime/DateTime.config date_format=$(sed -rn 's/date_format\s*=\s*(.*)\s*$/\1/p' $plugin_file) time_format=$(sed -rn 's/time_format\s*=\s*(.*)\s*$/\1/p' $plugin_file) for i in ${*:2}; do if [[ $i == date ]]; then echo $(date +"$date_format"); echo "" elif [[ $i == time ]]; then echo $(date +"$time_format"); echo "" fi done data/wakeup/wakeup.glade000664 001750 001750 00000312402 12315674052 016362 0ustar00dglassdglass000000 000000 110 5 10 10 23 8 1 5 59 30 1 10 1 31 1 1 10 100 1 10 10 False 5 Wakeup True center-on-parent dialog True True False immediate 2 True False center gtk-ok True True True False True False False 0 False True end 0 True False label13 True center False True 1 button13 False 5 Wakeup Introduction center-on-parent True dialog True True False 2 True False end gtk-ok True True True False True False False 0 False True end 0 True False True False 0 0 Welcome to Wakeup! Wakeup is a talking alarm clock which will set your computer to wake itself up - from shutdown if your bios allows. The alarm is spoken from the text in the text box on the left. A list of available data items, which allow the alarm to tell you useful information, is available from installed plugins in the list on the right. Simply type them into the alarm text or double click them. To set the alarm or plugin settings, click "Preferences." For more detailed instruction, click "Help." Note that for any part of the alarm which depends on information from the web to work when you are not logged in, you will need to set the wireless network(s) you connect to so that they connect before you log in. This can be done through NetworkManager, by selecting a connection, clicking "Edit..." and checking "Available to all users." fill True 54 False True 0 Always show this message at startup True True False False True True False False 4 1 False True 1 button16 450 400 False GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK Help False mouse True appointment-new dialog window True True True False 6 True True True False queue adjustment6 True False 10 <b>Alarm Text</b> In the main text window, simply type the text that you want to have spoken when the alarm runs. <b>Hot Text</b> Available hot-text items are listed in the list at the right in the main window. These can be inserted into the text by double-clicking on them or simply typing them into your alarm text. A blank line signifies a new paragraph. Each paragraph's hot-text items are updated immediately before the text is spoken, so if you want the $time, for instance, to reflect the current time somewhere in the middle of your text, leave a blank line before the sentence in which it occurs. <b>Note</b> that for hot-text items dependent on data from the web to work when not logged in (see Computer Wakeup below), you need to set the wireless network(s) you connect to so that they also connect before you log in. This can be done through NetworkManager, by selecting a connection, clicking "Edit..." and checking "Available to all users." <b>Plugins</b> Available plugins are listed in the "Plugins" tab under "Preferences." Each plugin adds hot-text items to the list in the main window. A plugin's hot-text items are only interpreted if the plugin is active. <b>Alarm Settings</b> The alarm time and recurrence settings can be set under the "General" tab of "Preferences." The volume of the alarm and preferences for all hot-text items can be set as well. <b>Computer Wakeup</b> In the general preferences, there is a default option to wake the computer for alarms. With this checked, your computer will be set to wake up - from shutdown if your computer allows - five minutes prior to the set alarm time. The alarm will run even if you are not logged in. Note that this option requires administrative (root) permission. <b>Multiple Alarms</b> Each alarm's settings are completely independent. Click "Edit multiple alarms..." to create and delete alarms. True fill True True True 0 True False gtk-ok True True True False True False False 3 end 0 False False 3 1 True False Usage False True False True False 1 1 <big><big><big><b>Wakeup 1.4</b></big></big></big> Copyright (c) David Glass 2012 &lt;dsglass@gmail.com&gt; Copyright is GPLv3 or later (/usr/share/common-licenses/GPL-3) True center True True 0 True False gtk-ok True True True False True False False 3 end 0 False False 3 1 1 True False About 1 False Minute Hour Day Week Month False 5 Preferences mouse 500 300 appointment-new dialog True True True False 5 True False 8 True False True False 0.059999998658895493 True False 12 True False 6 True False Time: False False 0 True True 2 0 adjustment2 1 False False 1 True False : False False 2 True True 2 0 adjustment3 1 False False 3 True False 0 0 6 6 Alarm time True False True 0 True False 0.070000000298023224 True False 12 True False False True True False Every: True True False False True True False False 0 True False liststore3 1 0 False False 1 True False False Day of month: False False 2 True False True adjustment4 False False 3 True True 0 True False Sun True False True False False True True True 0 Mon True False True False False True True True 1 Tue True False True False False True True True 2 Wed True False True False False True True True 3 Thu True False True False False True True True 4 Fri True False True False False True True True 5 Sat True False True False False True True True 6 True True 1 True False Cron format (m h dom mon dow): True True False False True True radiobutton1 True True 0 True False True True True 3 1 True True 2 Recurrs True True False False True True True 1 True True 3 0 True False True False 3 Volume center False False 0 True True adjustment1 True 0 True True 1 False True 6 1 True True 0 True False 6 gtk-cancel True True True False True False False 4 end 0 gtk-ok True True True False True False False end 1 False False 6 end 1 True False Set computer to wake up for alarm (requires root permission) True True False False True True True True 10 0 True True 2 True False General False True False True False True False 0 9 5 Choose voice (using festival speech tool): False False 0 True True etched-in True True liststore4 False False 0 fixed 1 0 column 40 column 1 400 column 0 True True 1 True False Use other speech tool: True True False False True False False 5 0 True False True True True 5 1 False False 4 2 True True 0 True False 6 gtk-cancel True True True False True False False 4 end 0 More Voices... True True True False none http://ubuntuforums.org/showthread.php?t=751169 False False end 1 gtk-ok True True True False True False False end 2 False False 6 end 1 1 True False Voices 1 False True False 4 True False True False 9 5 Available Plugins: False True 0 False False 0 True True etched-in True True liststore2 False 0 Active 1 2 Plugin True 0 Description True 1 True True 1 True False 6 gtk-cancel True True True False True False False 4 end 0 gtk-preferences True False True True False True False False end 1 gtk-ok True True True False True False False end 2 False False 6 end 2 2 True False Plugins 2 False True Type your alarm text here, inserting hot text items from the list at the right as desired. For example: Good morning. Today is $date. The time is $time. It is $temperature degrees outside with $skyconditions skies, and winds $windconditions. Expect $todays_forecast, with a high of $high and low of $low. Be sure to modify individual plug-in preferences under the "plugins" tab in the Preferences window. This allows you to specify which mp3 file you will hear from the music item, whether to present weather in Farenheit or Celsius, and so on. Note that hot text items are loaded at the beginning of each paragraph (a new paragraph is specified by leaving one or more blank lines). Hence the time is now $time, whereas in the previous paragraph it might have been a minute earlier. Alarm Text In the main text window, simply type the text that you want to have spoken when the alarm runs. Hot Text Available hot-text items are listed in the list at the right in the main window. These can be inserted into the text by double-clicking on them or simply typing them into your alarm text. A blank line signifies a new paragraph. Each paragraph's hot-text items are updated immediately before the text is spoken, so if you want the $time, for instance, to reflect the current time somewhere in the middle of your text, leave a blank line before the sentence in which it occurs. Note that for hot-text items dependent on data from the web to work when not logged in (see Computer Wakeup below), you need to set the wireless network(s) you connect to so that they also connect before you log in. This can be done through NetworkManager, by selecting a connection, clicking "Edit..." and checking "Available to all users." Plugins Available plugins are listed in the "Plugins" tab under "Preferences." Each plugin adds hot-text items to the list in the main window. A plugin's hot-text items are only interpreted if the plugin is active. Alarm Settings The alarm time and recurrence settings can be set under the "General" tab of "Preferences." The volume of the alarm and preferences for all hot-text items can be set as well. Computer Wakeup In the general preferences, there is a default option to wake the computer for alarms. With this checked, your computer will be set to wake up - from shutdown if your computer allows - five minutes prior to the set alarm time. The alarm will run even if you are not logged in. Note that this option requires administrative (root) permission. True False Wakeup Settings Configuration center 605 440 appointment-new True False True False True False False _File True True False gtk-new True False False True True gtk-apply True False False True True True False gtk-quit True False False True True True False False _Edit True True False gtk-preferences True False False True True gtk-media-play True False False True True gtk-remove True False False True True True False False _Help True True False True False False _Usage True gtk-about True False False True True False False 0 True False 7 5 True False 3 6 True True True etched-in True True liststore1 False False 0 dataitems 0 2 3 True True etched-in True True immediate word-char 6 6 textbuffer1 2 True True 0 True True True False True True etched-in True True liststore5 False 0 Text True 7 0 Time 0.5 1 Recurrence 0.5 2 Boot 0.5 3 True True 0 True False vertical icons False True False Add alarm False toolbutton1 True gtk-add False True True False Remove alarm False toolbutton2 True gtk-remove False True False False end 1 True False Edit multiple alarms... False False 1 True False 5 True start gtk-preferences True True True False True False False 1 True gtk-media-play True True True False True False False 3 True gtk-help True True True False True False False 4 gtk-apply True True True False True False False 4 True gtk-close True True True False True False False 5 True False False end 2 True True 1 data/wakeup/plugin_scripts/HebrewCalendar/check_hebcal.py000775 001750 001750 00000003527 11741113010 024720 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # get hebcal data # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import re import sys, os import subprocess # Get preferences plugin_file = open('/home/' + sys.argv[1] + '/.wakeup/' + os.environ['ALARM'] + '/plugins/HebrewCalendar/HebrewCalendar.config', 'r') plugin_text = ''.join(plugin_file.readlines()) plugin_file.close() latitude = re.search("latitude=(.*)", plugin_text).group(1) longitude = re.search("longitude=(.*)", plugin_text).group(1) manual_location = re.search("manual_location=(.*)", plugin_text).group(1) # Output for out in sys.argv[2:len(sys.argv)]: if (out == "hebdate"): date = subprocess.check_output(['hebcal', '-Th']) print date + '\n' if (out == "hebcalevents"): if (manual_location == "false"): # Get location sys.path.append('/usr/share/wakeup') import location loc = location.get_location() latitude = float(loc['latitude']) longitude = float(loc['longitude']) else: latitude = float(latitude) longitude = float(longitude) # Convert to hebcal +/-deg,min lat_deg = int(abs(latitude)) lat_min = int(60 * (abs(latitude) - lat_deg)) lat_deg = int(latitude/abs(latitude)) * lat_deg lon_deg = int(abs(longitude)) lon_min = int(60 * (abs(longitude) - lon_deg)) lon_deg = -1 * int(longitude/abs(longitude)) * lon_deg latitude = str(lat_deg) + ',' + str(lat_min) longitude = str(lon_deg) + ',' + str(lon_min) zone = subprocess.check_output(['date','+%:::z']) events = subprocess.check_output(['hebcal', '-Toc', '-l', latitude, '-L', longitude, '-z', zone]) events = re.sub("^[0-9].*\n", "", events) print events + '\n' data/wakeup/default_plugin_confs/Weather/Weather.config000664 001750 001750 00000000061 11741113010 024422 0ustar00dglassdglass000000 000000 temperature_units=F wind_units=mph location=none data/wakeup/plugin_scripts/GmailCounter/check_gmail.sh000775 001750 001750 00000002216 12015212231 024272 0ustar00dglassdglass000000 000000 #!/bin/bash # plugin script for GmailCounter outputting number of new emails on a gmail account. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 eval $(cat /home/$1/.wakeup/$ALARM/plugins/GmailCounter/GmailCounter.config); password=$(echo $password | base64 -d) IFS=$'\n' times=($(curl -u $username:$password --silent "https://mail.google.com/mail/feed/atom" \ | grep -P ".*" | sed -r 's/(.*)T24:(.*)/\1T0:\2/' \ | sed -r 's/(.*)T(.*)Z<\/issued>/date +%s --date "\1 \2"/')) for (( i = 0; i < ${#times[@]}; i++ )); do times[$i]=$(eval ${times[$i]}) done last_checked=$(curl -u $username:$password --silent \ "https://mail.google.com/mail/feed/atom" | grep -m 1 "" \ | sed -r 's/(.*)T24:(.*)/\1T0:\2/' \ | sed -r 's/(.*)T(.*)Z<\/modified>/\1 \2/') last_checked=$(date +%s --date "$last_checked -1 hour") num_new_emails=0; for i in ${times[@]}; do if [[ $i > $last_checked ]]; then num_new_emails=$(( $num_new_emails + 1 )); fi done plural="s"; if [[ $num_new_emails == 1 ]]; then plural=""; fi echo "$num_new_emails new e-mail$plural" data/wakeup/voice_list.sh000775 001750 001750 00000002105 11741113010 016543 0ustar00dglassdglass000000 000000 #!/bin/bash # Output a list of "voicename\ndescription" for each voice available to # festival. Uses voice name as description if no description found. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 out1=$(mktemp) out2=$(mktemp) out3=$(mktemp) echo "" > $out1; echo "" > $out2; echo "" > $out3 festival --server >/dev/null 2>&1 & festival_id=$! while [[ $(echo '()' | festival_client && echo $?) != 0 ]]; do echo -n '' done >/dev/null 2>&1 echo "(pprintf (voice.list) (fopen \"$out1\" \"w\"))" | festival_client voices=($(cat $out1 | sed 's/[()]//g')) for voice in ${voices[@]}; do echo "(pprintf (voice.description '$voice) (fopen \"$out2\" \"w\"))" | festival_client echo $voice >> $out3 description=$(echo $(cat $out2) | grep -oP '(description "[^)(]*")') if [[ $description == "" ]]; then echo $voice >> $out3 else echo $description | sed -e 's/description //' -e 's/"//g' >> $out3 fi done cat $out3 | sed '/^$/d' rm $out1 $out2 $out3 kill $festival_id >/dev/null 2>&1 data/wakeup/plugin_scripts/Commands/Commands.glade000664 001750 001750 00000026467 11741113010 023432 0ustar00dglassdglass000000 000000 True False 6 User Commands center dialog False 400 200 True False True False 2 3 2 3 True True True 1 2 True True True 1 3 1 2 True False 1 Data item: $ True False 1 Command: 1 2 42 True False 2 3 False True 0 True False True True in True True liststore1 False 0 Data item True 0 Command True 1 True True 0 True False vertical icons False True False False True gtk-add False True True False False True gtk-remove False True False False end 1 True True 1 True False 3 gtk-ok True True True False True True True 0 gtk-cancel True True True False True True True 1 False True 2 2 data/wakeup/plugin_scripts/LastfmPlayer/play_lastfm.sh000775 001750 001750 00000001400 11741113010 024363 0ustar00dglassdglass000000 000000 #!/bin/bash # plugin script for LastfmPlayer, a wrapper for shell-fm # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 trap "killall shell-fm; exit" SIGHUP SIGINT SIGTERM export HOME=/home/$1 plugin_file=~/.shell-fm/shell-fm.rc duration=$(sed -rn 's/#duration\s*=\s*(.*)\s*/\1/p' $plugin_file) if [[ $duration == 0 ]]; then shell-fm else ip=$(ifconfig -a | grep -oP "inet addr:[0-9\.]+" -m 1 | sed -r 's/inet addr://') shell-fm -i $ip -d if [[ $duration =~ [0-9]+:[0-9]{2} ]]; then mins=$(echo $duration | grep -oP "^[0-9]+") secs=$(echo $duration | grep -oP "[0-9]+$") duration=$(( 60 * mins + secs )) fi sleep $duration killall shell-fm fi data/wakeup/plugin_scripts/LastfmPlayer/LastfmPlayer.glade000664 001750 001750 00000026042 11741113010 025123 0ustar00dglassdglass000000 000000 True False 6 Last.fm Preferences False center dialog True False True False Please enter your Last.fm account settings False False 0 True False 3 3 3 True False password: 1 2 True True False True False False True True 1 3 1 2 True True False False True True 1 3 True False username: True False station: 2 3 True False lastfm:// 1 2 2 3 True True False False True True 2 3 2 3 False False 3 1 True False 7 True False Play for (seconds, or mm:ss, 0=entire song): True True 0 True True 6 True False False True True False False 1 True True 2 True False True False 8 True gtk-ok True True True False True True True 0 gtk-cancel True True True False True True True 1 True True 20 0 False True 3 data/wakeup/plugin_scripts/LastfmPlayer/LastfmPlayer.py000664 001750 001750 00000006611 12103436570 024513 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for LastfmPlayer # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class LastfmPlayer: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("LastfmPlayer.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.username = self.wTree.get_object("entry1") self.password = self.wTree.get_object("entry2") self.station = self.wTree.get_object("entry3") self.duration = self.wTree.get_object("entry4") self.password_file = os.path.join(os.environ['HOME'], '.shell-fm/shell-fm.rc') self.settingsblank = False if not os.path.exists(self.password_file): shell_fm_path = os.path.join(os.environ['HOME'], '.shell-fm') if not os.path.exists(shell_fm_path): os.mkdir(shell_fm_path) lfs_file = open(self.password_file, "w") lfs_file.close() lfs_file = open(self.password_file, "r") self.lines = ''.join(lfs_file.readlines()) try: old_username = re.search("username\s*=\s*(.*)\s*password", self.lines).group(1) old_password = re.search("password\s*=\s*(.*)\s*", self.lines).group(1) old_station = re.search("default-radio=lastfm://(.*)\s*", self.lines).group(1) old_duration = re.search("#duration\s*=\s*(.*)\s*", self.lines).group(1) except: old_password = "" old_username = "" old_station = "" old_duration = "" self.settingsblank = True lfs_file.close() self.username.set_text(old_username) self.password.set_text(old_password) self.station.set_text(old_station) self.duration.set_text(old_duration) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): if not self.settingsblank: self.lines = re.sub("username\s*=\s*.*\s*", "username=" \ + self.username.get_text() + "\n", self.lines) self.lines = re.sub("password\s*=\s*.*\s*", "password=" \ + self.password.get_text() + "\n", self.lines) self.lines = re.sub("default-radio=lastfm://(.*)\s*", \ "default-radio=lastfm://" + self.station.get_text() + "\n", self.lines) self.lines = re.sub("#duration\s*=\s*.*\s*", "#duration=" \ + self.duration.get_text() + "\n", self.lines) else: self.lines = "username=" + self.username.get_text() + "\n" \ + "password=" + self.password.get_text() + "\n" \ + "default-radio=lastfm://" + self.station.get_text() + "\n" \ + "#duration=" + self.duration.get_text() lfs_file = open(self.password_file, "w") lfs_file.write(self.lines) lfs_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/wakeup/default_plugin_confs/EvolutionData/000770 001750 001750 00000000000 11741113010 023011 5ustar00dglassdglass000000 000000 data/wakeup/default_plugin_confs/HebrewCalendar/000770 001750 001750 00000000000 11741113010 023101 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/DateTime/000770 001750 001750 00000000000 11741113010 020602 5ustar00dglassdglass000000 000000 data/wakeup/plugin_settings/News.plugin000664 001750 001750 00000000315 11741113010 021417 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Read news from an rss feed' p2 sS'script' p3 S'News/read_news.py' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'rss' p8 asS'has_preferences' p9 I01 sS'name' p10 S'News' p11 s.data/wakeup/stopalarm.glade000664 001750 001750 00000023031 11741113010 017045 0ustar00dglassdglass000000 000000 100 1 5 59 5 1 10 False 5 Stop Alarm False center appointment-new normal True False 2 True False end Snooze True True True False False False 0 gtk-stop True True True True False True False False 1 False True 5 end 0 True False True False True False 49 appointment-new True True 0 True False Wakeup: press "stop" to end alarm or "snooze" to postpone. True False False 11 1 False False 0 True False True False 1 Snooze time: True True 5 0 True True adjustment1 True False False 1 True False hours False False 5 2 True True adjustment2 True False False 3 True False minutes False False 5 4 False False 5 1 False False 1 button2 button1 data/wakeup/plugin_scripts/000770 001750 001750 00000000000 11741113010 017106 5ustar00dglassdglass000000 000000 data/scripts/setalarm000755 001750 001750 00000017041 12312350051 016003 0ustar00dglassdglass000000 000000 #!/bin/bash # This script sets your computer to wake at a given time (h)h:mm nearest in the # future or recurrently for some general cron-formatted times. The computer is # actually woken up 5 minutes earlier than specified, and a given script is set # to run at the exact time given via crontab. This script must be run as root. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 # For only print next wakeup time if [[ $1 == "-p" ]]; then only_print=true shift fi if [[ ! $only_print ]]; then if [[ `whoami` != "root" ]]; then echo "setalarm must be run as root" exit 1 fi # Clear the system wakeup alarm. echo 0 > /sys/class/rtc/rtc0/wakealarm; # For delete alarms if [[ $1 == "-d" ]]; then (crontab -l | sed /^.*setalarm.*$/d) | crontab - exit 0 fi fi # Check if correct number of arguments given if [[ $1 == "-c" && $# -lt 6 && ! $only_print || $1 == "-u" && ! $2 =~ [0-9]+ || $1 != "-c" && $1 != "-u" && ! $1 =~ [0-9]{1,2}\:[0-9]{2} ]]; then echo "Usage: setalarm [-p] [hh:mm] [-u utc] [-c m h dom mon dow] [-o offset] [command]" echo "Asterisks may need to be surrounded by quotes" exit 1 fi if [[ $1 != "-c" && $2 == "-o" || $1 == "-c" && $7 == "-o" || $1 == "-u" && $3 == "-o" ]]; then if [[ $1 != "-c" && ! $3 =~ [0-9]+ || $1 == "-c" && ! $8 =~ [0-9]+ ]]; then if [[ $1 == "-u" && ! $4 =~ [0-9]+ ]]; then echo "Invalid offset value" exit 1 fi fi if [[ $1 == "-c" ]]; then offset=$8 elif [[ $1 == "-u" ]]; then offset=$4 else offset=$3 fi offset_set=true else offset=5 #minutes (default) fi # Get wakeup script if [[ ! $only_print ]]; then script_start=$(if [[ $1 == "-u" ]]; then echo 3; elif [[ $1 != "-c" ]]; then echo 2; else echo 7; fi) if [[ $offset_set ]]; then script_start=$(( script_start + 2 )); fi wakeup_script=${*:$script_start} fi # Check if an element exists in an array function check_element { for i in ${*:2}; do if [[ $i == $1 ]]; then echo 1; return; fi done echo 0 return } # Read in cron input function read_cron_input { if [[ $4 == "Months" ]]; then input=$(echo "$1" | sed -e 's/Sat/6/ig' \ -e 's/Jan/1/ig' -e 's/Feb/2/ig' -e 's/Mar/3/ig' -e 's/Apr/4/ig' \ -e 's/May/5/ig' -e 's/Jun/6/ig' -e 's/Jul/7/ig' -e 's/Aug/8/ig' \ -e 's/Sep/9/ig' -e 's/Oct/10/ig' -e 's/Nov/11/ig' -e 's/Dec/12/ig') elif [[ $4 == "Days" ]]; then input=$(echo "$1" | sed -e 's/Sun/0/ig' -e 's/Mon/1/ig' \ -e 's/Tue/2/ig' -e 's/Wed/3/ig' -e 's/Thu/4/ig' -e 's/Fri/5/ig' ) else input=$1 fi # Check for bad input: exit only exits function, need to check for "" output if [[ $input =~ [^\-\,0-9\*] ]]; then exit 1; fi if [[ $input == "*" ]]; then seq $2 $3 elif [[ $input =~ .*-.* ]]; then seq ${input/-/ } else echo $input | sed 's/,/\n/g' | sort -g fi } # for utc times if [[ $1 == "-u" ]]; then wake_time=$2 if [[ $only_print ]]; then echo $(( $wake_time - $offset * 60 )) exit fi crontab_time=`date -d @$wake_time "+%M %H %d %m %w"` newline="$crontab_time $wakeup_script >/dev/null 2>&1 #entered by setalarm" if [[ $wakeup_script != "" ]]; then (crontab -l | sed /^.*setalarm.*$/d; echo $newline) | crontab - fi # for recurrent alarms elif [[ $1 == "-c" ]]; then # Grab current date now_dom=$(date +%-d); now_mon=$(date +%-m); now_dow=$(date +%w) now_hr=$(date +%-H); now_min=$(date +%-M) # Read cron input mins=($(read_cron_input "$2" 0 59)) hrs=($(read_cron_input "$3" 0 23)) doms=($(read_cron_input "$4" $now_dom 31)) mons=($(read_cron_input "$5" $now_mon 12 "Months")) dows=($(read_cron_input "$6" 0 6 "Days")) # check if all values are valid if [[ $mins == "" || $hrs == "" || $doms == "" || $mons == "" || $dows == "" ]]; then echo "bad cron time entries" >&2; exit 1; fi last_hr=${hrs[$(( ${#hrs[@]} - 1 ))]} last_min=${mins[$(( ${#mins[@]} - 1 ))]} # Get the alarm month/day function chkw # check if date occurs on an acceptable day of week { check_element $(date --date @$wake_time +%w) ${dows[@]} } years=($(date +%Y) $(( $(date +%Y) + 1 ))) for y in ${years[@]}; do for i in ${mons[@]}; do for j in ${doms[@]}; do if [[ $(date -d $i/$j/$y +%s) -ge $(date -d $now_mon/$now_dom/${years[1]} +%s) ]]; then break; fi wake_time=$(date --date "$i/$j/$y $last_hr:$last_min:00" +%s); if [[ `chkw` != 1 ]]; then continue; fi date="$i/$j/$y" if [[ $wake_time > `date +%s` ]]; then break 3; fi done if [[ $4 == "*" ]]; then doms=$(seq 1 31); fi done if [[ $5 == "*" ]]; then mons=$(seq 1 $now_mon); fi done 2>/dev/null if [[ $date == "" || $wake_time < `date +%s` || `chkw` != 1 ]]; then echo "The specified cron time does not occur within a year" exit 1 fi # Get the hour:minute if [[ $date == $(date +%-m/%-d/%Y) ]]; then mins=($(read_cron_input "$2" $now_min 59)) hrs=($(read_cron_input "$3" $now_hr 23)) fi for k in ${hrs[@]}; do for l in ${mins[@]}; do wake_time=$(date --date "$date $k:$l:00" +%s); if [[ $wake_time > `date +%s` ]]; then break 2; fi done if [[ $2 == "*" ]]; then mins=$(seq 0 59); fi done 2>/dev/null if [[ $only_print ]]; then echo $(( $wake_time - $offset * 60 )) exit fi # add cron for setlarm that runs wtih the $wakeup_script and @reboot newline1="$2 $3 $4 $5 $6 $0 ${*/\*/\"*\"} >/dev/null 2>&1\n" newline2="@reboot $0 ${*/\*/\"*\"} >/dev/null 2>&1" if [[ $wakeup_script != "" ]]; then newline3="\n$2 $3 $4 $5 $6 $wakeup_script >/dev/null 2>&1 #entered by setalarm" fi (crontab -l | sed /^.*setalarm.*$/d; echo -e "$newline1$newline2$newline3") | crontab - # for non-recurring alarms else # determine a wakeup time. add a day if time has already passed for today wake_time=$(date --date "$(date +%D) $1:00" +%s) if [[ $wake_time < `date +%s` ]]; then wake_time=$(( $wake_time + 86400 )); fi if [[ $only_print ]]; then echo $(( $wake_time - $offset * 60 )) exit fi # format $wakeup_time in crontab format. crontab_time=`date -d @$wake_time "+%M %H %d %m %w"` if [[ $wakeup_script != "" ]]; then newline="$crontab_time $wakeup_script >/dev/null 2>&1 #entered by setalarm" (crontab -l | sed /^.*setalarm.*$/d; echo $newline) | crontab - fi fi # Account for hardware clock vs UTC mismatch hwc=$(cat /sys/class/rtc/rtc0/time) # hwclock time hwc=${hwc:0:5} # (ignoring seconds) tim=$(date -u +%H:%M) # utc time if [[ $hwc == $tim ]]; then # hardware clock is in utc. Do not adjust for time zone tz_offset=0 else # hardware clock is in local time, not utc. Adjust for tzoffset tz_offset=$(date +%z) tz_hr=${tz_offset:0:3} tz_mn=${tz_offset:0:1}${tz_offset:3:2} tz_offset=$(( $tz_hr * 3600 + $tz_mn * 60 )) fi # Actually set alarm # echo $(( $wake_time - $offset * 60 + $tz_offset)) > /sys/class/rtc/rtc0/wakealarm; echo -e "Alarm set to: $(date -d @$wake_time)" # Remind user about offset if [[ $offset_set ]]; then echo "Computer will wake $offset minutes earlier"; fi data/wakeup/default_plugin_confs/DateTime/DateTime.config000664 001750 001750 00000000051 11741113010 024613 0ustar00dglassdglass000000 000000 date_format=%A %B %e time_format=%l:%M%p data/wakeup/plugin_scripts/HebrewCalendar/HebrewCalendar.glade000664 001750 001750 00000014627 11741113010 025637 0ustar00dglassdglass000000 000000 True False 6 Hebrew Calendar Preferences False center dialog True False Manually set decimal longitude, latitude: True True False False True True True 0 True False True True False False True True 0 True False , True True 1 True True False False True True 2 True True 1 True False True False 8 True gtk-ok True True True False True True True 0 gtk-cancel True True True False True True True 1 True True 20 0 False True 2 data/wakeup/default_plugin_confs/DateTime/000770 001750 001750 00000000000 11741113010 021727 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/DateTime/DateTime.glade000664 001750 001750 00000012353 11741113010 023305 0ustar00dglassdglass000000 000000 True 6 Date Format False center dialog True True For possible formats, see 'man date' 0 True 5 True Date format: False False 0 True True 1 1 True 5 True Time format: False False 0 True True 1 2 True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 3 data/wakeup/plugin_scripts/GmailCounter/GmailCounter.glade000664 001750 001750 00000013172 11741113010 025077 0ustar00dglassdglass000000 000000 True 6 Gmail Preferences False center dialog True True Please enter your Gmail account settings False False 0 True 2 2 3 True password: 1 2 True True False True 1 2 1 2 True True 1 2 True username: False False 3 1 True True 8 True gtk-ok True True True True 0 gtk-cancel True True True True 1 20 0 False 2 data/wakeup/stopalarm.py000775 001750 001750 00000002461 11741113010 016430 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # Display GUI dialog from which the user can stop or snooze an alarm. # Output of the script is snooze time in minutes (0=stop). Output is # read by wakeup. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os wakeup_folder = "/usr/share/wakeup/" class StopAlarm: def __init__(self): self.wTree = gtk.Builder() self.wTree.add_from_file(os.path.join(wakeup_folder, "stopalarm.glade")) self.wTree.connect_signals(self) self.window = self.wTree.get_object("dialog1") self.minutes = self.wTree.get_object("adjustment2") self.hours = self.wTree.get_object("adjustment1") self.minutes.set_value(5.0) self.window.show_all() def on_alarm_stopped(self, widget, data=None): print 0 gtk.main_quit() def on_alarm_snoozed(self, widget, data=None): hrs = self.hours.get_value() mins = self.minutes.get_value() print str(int(hrs*60 + mins)) gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() '''Run the program''' if __name__ == "__main__": stopalarm = StopAlarm() stopalarm.main() data/scripts/wakeup000775 001750 001750 00000005153 12314231731 015477 0ustar00dglassdglass000000 000000 #!/bin/bash # Runs a given alarm set by wakeup-settings for a given user. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 # initialize environment variables pid=$$ usr=$1 home=$(/bin/grep $usr /etc/passwd | /bin/sed -r 's/.*:\/(.+):[^:]*/\/\1/') PATH=/sbin:/bin:/usr/sbin:/usr/bin:$home/bin/ # allow running as both root and non-root if [[ `whoami` == "root" ]]; then dosudo="sudo -u $usr" fi # start dbus (necessary for running alarm while not logged in) eval `eval "$dosudo dbus-launch --sh-syntax"` # set volume # see http://ubuntuforums.org/showthread.php?t=1796713 volume=$(grep -A 2 "volume" $home/.wakeup/alarm$2/wakeup_settings | awk "NR==3" | grep -oP "[0-9\.]+") if [[ $volume == "" ]]; then volume=50 fi oldvol=$(/usr/bin/amixer get Master playback | grep -oP "[0-9]+%") /usr/bin/amixer set Master playback $volume% unmute /usr/bin/amixer set Headphone unmute /usr/bin/amixer set Speaker unmute /usr/bin/amixer set PCM 100% unmute # function to get pid of child processes function get_ids { a=($(ps -o pid,ppid ax | awk "{ if ( \$2 == $1) { print \$1 }}")) echo -n "${a[@]} " for i in ${a[@]}; do get_ids $i; done } function stop { /usr/bin/amixer set Master playback $oldvol y=($(get_ids $pid) $DBUS_SESSION_BUS_PID) kill ${y[@]} & exit 0 } trap "stop; exit" SIGHUP SIGINT SIGTERM # allow the user to end it all while [ ! ]; do eval export $(grep --text -oP "DISPLAY=:[0-9\.]*" /proc/$(pgrep -n gnome-session)/environ) if [[ $DISPLAY != "" ]]; then sleep 2 eval "snooze=$($dosudo /usr/share/wakeup/stopalarm.py)" if [[ $snooze == 0 ]]; then if [[ $dosudo != "" ]]; then /usr/share/wakeup/setnextalarm.py $usr fi stop else if [[ $dosudo != "" ]]; then if [[ $snooze -le 5 ]]; then offset="-o 1"; fi /usr/bin/setalarm -u $(date -d "+$snooze min" "+%s") $offset dosudo="sudo" fi snoozetime=$(date -d "+$snooze min" "+%M %H %d %m %w") newcronline="$snoozetime /usr/bin/wakeup $1 $2 $3 >/dev/null 2>&1 #entered by setnextalarm" (eval $dosudo crontab -l; echo $newcronline) | eval $dosudo crontab - stop fi else continue fi done & # play the alarm export DBUS_SESSION_BUS_ADDRESS PATH filename="$home/.wakeup/alarm$2/playable_text" if [[ $3 == "test" ]]; then filename="$home/.wakeup/playable_tmp"; fi chmod +x $filename echo "About to play the text..." $filename $usr # Finish everything if alarm finishes stop data/scripts/000770 001750 001750 00000000000 12314231731 014244 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/Weather/Weather.py000664 001750 001750 00000006706 11741113010 022474 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for Weather # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re import subprocess, threading class Weather: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("Weather.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.manual_id = self.wTree.get_object("entry1") self.set_manual = self.wTree.get_object("checkbutton1") self.temp_units = self.wTree.get_object("combobox1") self.wind_units = self.wTree.get_object("combobox2") self.plugin_file = os.path.join(pluginfolder, 'Weather.config') ws_file = open(self.plugin_file, "r") self.lines = ''.join(ws_file.readlines()) ws_file.close() old_temp_units = re.search("temperature_units\s*=\s*(.*)\s*", self.lines).group(1) != "F" old_wind_units = re.search("wind_units\s*=\s*(.*)\s*", self.lines).group(1) != "mph" old_location = re.search("location\s*=\s*(.*)\s*", self.lines).group(1) self.temp_units.set_active(old_temp_units) self.wind_units.set_active(old_wind_units) if old_location == "none": thread = self.ipThread(self.manual_id) thread.start() else: self.manual_id.set_text(old_location) if not old_location == "none": self.manual_id.set_sensitive(False) self.set_manual.set_active(True) # Thread so we don't have to wait for autolocation to be found class ipThread (threading.Thread): def __init__(self, manual_id): self.location = manual_id threading.Thread.__init__(self) def run(self): import location loc = location.get_location() self.location.set_text(loc['City']+','+loc['State']+','+loc['Country']) '''On Checking to set weather ID manually''' def on_manualID_toggled(self, widget, data=None): self.manual_id.set_sensitive(widget.get_active()) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): if self.temp_units.get_active() == 0: temp_units = "F" else: temp_units = "C" if self.wind_units.get_active() == 0: wind_units = "mph" else: wind_units = "knots" if self.set_manual.get_active(): location = self.manual_id.get_text() else: location = "none" #self.auto_location self.lines = re.sub("temperature_units\s*=\s*.*\s*", "temperature_units=" \ + temp_units + "\n", self.lines) self.lines = re.sub("wind_units\s*=\s*.*\s*", "wind_units=" \ + wind_units + "\n", self.lines) self.lines = re.sub("location\s*=\s*.*\s*", "location=" \ + location + "\n", self.lines) ws_file = open(self.plugin_file, "w") ws_file.write(self.lines) ws_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.gdk.threads_init() gtk.main() data/wakeup/plugin_settings/GmailCounter.plugin000664 001750 001750 00000000365 11741113010 023101 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Count number of new emails on a gmail account' p2 sS'script' p3 S'GmailCounter/check_gmail.sh' p4 sS'text_output' p5 I01 sS'data_items' p6 (lp7 S'gmail' p8 asS'has_preferences' p9 I01 sS'name' p10 S'Gmail Counter' p11 s.data/wakeup/plugin_scripts/EvolutionData/read_evolution.py000775 001750 001750 00000010453 12027742056 025310 0ustar00dglassdglass000000 000000 #!/usr/bin/python # plugin script for EvolutionData outputting schedule and/or tasks # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import urllib, vobject, datetime, dateutil import sys, os import re # What we should output (todo and/or schedule) to_output = sys.argv[2:] # Calendars not to read (from command line arguments) plugin = "/home/" + sys.argv[1] + "/.wakeup/" + os.environ['ALARM'] + \ "/plugins/EvolutionData/EvolutionData.config" plugin_file = open(plugin, "r") lines = ''.join(plugin_file.readlines()) plugin_file.close() skip_cals = re.search("ignore_cals\s*=\s*(.*)\s*", lines).group(1) calendarsfolder = '/home/' + sys.argv[1] + '/.local/share/evolution/calendar' tasksfolder = '/home/' + sys.argv[1] + '/.local/share/evolution/tasks' # initialization today = datetime.date.today() todays_events = list() all_day_events = list() todo_list = list() # list of calendars from evolution calendars = [] for root, dirs, files in os.walk(calendarsfolder): for _file in files: if _file.endswith('.ics'): calendars.append(os.path.join(root,_file)) # list of tasks tasklists = [] for root, dirs, files in os.walk(tasksfolder): for _file in files: if _file.endswith('.ics'): tasklists.append(os.path.join(root,_file)) for cal in calendars: if not re.search('^webcal://', cal[1]): f = open(cal) calstring = ''.join(f.readlines()) f.close() try: event_list = vobject.readOne(calstring).vevent_list except AttributeError: continue else: # evolution library does not support webcal ics webcal = urllib.urlopen('http://' + cal[1][9:]) webcalstring = ''.join(webcal.readlines()) webcal.close() event_list = vobject.readOne(webcalstring).vevent_list if cal[0] in skip_cals: continue # loop through events for ev in event_list: if type(ev) != vobject.icalendar.RecurringComponent: parsedEvent = vobject.readOne(ev.get_as_string()) else: parsedEvent = ev start = parsedEvent.dtstart.value if hasattr(parsedEvent, "rrule"): try: rrule = parsedEvent.rrule.value rrule_until = re.search("UNTIL=[A-Za-z0-9]+",rrule) if rrule_until and rrule_until.group(0)[-1] == "Z": # some weird dateutil error in time zones rrule = re.sub(rrule_until.group(0), rrule_until.group(0)[:-1], rrule) recurrences = dateutil.rrule.rrulestr(rrule, dtstart=start) for day in recurrences: if day.date() == today: todays_events.append(parsedEvent) if day.date() > today: break except TypeError: pass # some weird dateutil error in time zones, just in case it's still missed elif type(start) == datetime.date and start == today: d=parsedEvent.dtstart.value parsedEvent.dtstart.value = datetime.datetime.combine(d, datetime.time(0,0,0,0)) todays_events.append(parsedEvent) all_day_events.append(parsedEvent) elif type(start) == datetime.datetime and start.date() == today: todays_events.append(parsedEvent) for tasklist in tasklists: f = open(tasklist) taskliststring = ''.join(f.readlines()) f.close() try: todos = vobject.readOne(taskliststring).vtodo_list for td in todos: if not (hasattr(td, "percent_complete") and td.percent_complete == "100"): todo_list.append(td) except AttributeError: pass for out in to_output: if out == "schedule": for ev in sorted(todays_events,key=lambda e: e.dtstart.value): print ev.summary.value, if not ev in all_day_events: print u'at ' + ev.dtstart.value.strftime("%l:%M %p"), if hasattr(ev, "location"): print u'in ' + ev.location.value, print ", ", if not todays_events: print "Nothing listed" print "" if out == "todo": for td in todo_list: print td.summary.value + u',', if not todo_list: print "Nothing listed" print "" data/wakeup/wakeupRootHelper000775 001750 001750 00000001141 11741113010 017271 0ustar00dglassdglass000000 000000 #!/bin/bash # Helper program to allow elevated privaleges for wakeup-settings (and alarm.py) # using pkexec without giving away privaleges to other scripts # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 commands=(/usr/bin/setalarm /usr/bin/crontab /usr/share/wakeup/setnextalarm.py /usr/share/wakeup/createRootPlayfile.py) allowed=false for i in ${commands[@]}; do if [[ $1 = $i ]]; then allowed=true fi done if [[ $allowed != true ]]; then echo "$1: Elevated command not allowed." exit 1 else eval $* fi data/wakeup/plugin_scripts/GmailCounter/000770 001750 001750 00000000000 12015212231 021477 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/Weather/000770 001750 001750 00000000000 12027744377 020535 5ustar00dglassdglass000000 000000 data/wakeup/default_plugin_confs/GmailCounter/000770 001750 001750 00000000000 11741113010 022624 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/EvolutionData/000770 001750 001750 00000000000 12027742420 021677 5ustar00dglassdglass000000 000000 data/wakeup/setnextalarm.py000775 001750 001750 00000007010 11747671201 017151 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # Using setalarm, finds the earliest alarm in the future which requires # a computer wakeup and sets the computer to wake up and run that alarm. # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import sys import os import re wakeup_script = "/usr/bin/wakeup" wakeup_folder = "/usr/share/wakeup/" sys.path.append(wakeup_folder) from alarm import alarm import subprocess thisscript = os.path.join(wakeup_folder, "setnextalarm.py") + " " + sys.argv[1] setalarm_script = "/usr/bin/setalarm" home = os.path.join('/home', sys.argv[1]) homewakeupfolder = os.path.join(home, ".wakeup") alarms = list() alarmfolders = list() # Load alarms, and specifically their times (don't need text, plugins, etc.) for foldername in os.listdir(homewakeupfolder): folder = os.path.join(homewakeupfolder, foldername) if not re.search("alarm\d+$", folder) or not os.path.isdir(folder): continue alarms.append(alarm()) alarmfolders.append(folder) alarms[-1].read_settings(os.path.join(folder, "wakeup_settings")) if not alarms[-1].get_property("wakecomputer"): del alarms[-1] del alarmfolders[-1] # Get alarm cron times and find the time to wake the computer for each alarmtimes = list() crontimes = list() for alarm in alarms: cronstring = alarm.get_property("cronvalue") crontimes.append(cronstring) try: output = subprocess.check_output([setalarm_script, '-p', '-c'] + re.split(' ', cronstring) + ['-o', '0']) alarmtimes.append(output) except subprocess.CalledProcessError as e: if e.output == "The specified cron time does not occur within a year\n": print "A specified cron time does not occur within a year; please check preferences." else: print "Unable to set alarms. Some crontimes are invalid." exit(1) # If no alarms in list, clear root's cron file and unset computer wakeup if len(alarms) == 0: curcron = subprocess.check_output(['sudo', 'crontab', '-l']) curcron = re.sub('[^\n]*setnextalarm.*\n', '', curcron) updatecron = subprocess.Popen(['crontab', '-'], stdin = subprocess.PIPE) updatecron.communicate(curcron) subprocess.call(['sudo', setalarm_script, '-d']) exit() minalarm = min(alarmtimes) minindex = alarmtimes.index(minalarm) mincron = crontimes[minindex] # make sure the wakeup is preserved through shutdowns and at alarm times. Set alarms. curcron = subprocess.check_output(['sudo', 'crontab', '-l']) curcron = re.sub('[^\n]*setnextalarm.*\n', '', curcron) updatecron = subprocess.Popen(['crontab', '-'], stdin = subprocess.PIPE) newline1 = mincron + ' ' + thisscript + ' >/dev/null 2>&1\n' newline2 = '@reboot ' + thisscript + ' >/dev/null 2>&1\n' newcron = curcron + newline1 + newline2 for i in range(0, len(alarmtimes)): if alarmtimes[i] == minalarm: alarmnum = re.search("\d+$", alarmfolders[i]).group(0) newline = mincron + ' ' + wakeup_script + ' ' + sys.argv[1] + ' ' + alarmnum + \ ' >/dev/null 2>&1 #entered by setnextalarm\n' newcron = newcron + newline updatecron.communicate(newcron) success = True try: subprocess.check_output(['sudo', setalarm_script, '-u', minalarm]) except subprocess.CalledProcessError: success = False try: output = subprocess.check_output(['date', '-d', '@' + minalarm]) print output except subprocess.CalledProcessError: success = False if not success: print "Unable to set alarms. Check alarm time preferences." exit(1) data/COPYING000664 001750 001750 00000077217 11741113010 013623 0ustar00dglassdglass000000 000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS data/wakeup/plugin_scripts/News/000770 001750 001750 00000000000 11741113010 020022 5ustar00dglassdglass000000 000000 data/wakeup/plugin_scripts/Commands/Commands.py000664 001750 001750 00000013205 11741113010 022770 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for Commands # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class Commands: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("Commands.glade") self.wTree.connect_signals(self) self.window = self.wTree.get_object("window1") self.item_entry = self.wTree.get_object("entry1") self.command_entry = self.wTree.get_object("entry2") self.command_list = self.wTree.get_object("liststore1") self.selection = self.wTree.get_object("treeview-selection1") self.remove_button = self.wTree.get_object("toolbutton2") self.plugin_file = os.path.join(pluginfolder, "Commands.config") c_file = open(self.plugin_file, "r") self.lines = ''.join(c_file.readlines()) c_file.close() old_items = re.search("dataitems=(.*)", self.lines).group(1).split(",") old_commands = re.search("scripts=(.*)", self.lines).group(1).split(",") for i in xrange(len(old_items)): myiter = self.command_list.insert_after(None, None) self.command_list.set_value(myiter, 0, '$'+old_items[i]) self.command_list.set_value(myiter, 1, old_commands[i]) # Select first item in list self.selection.select_path(self.command_list.get_path(self.command_list.get_iter_first())) if old_items == ['']: old_items = [] old_command = [] self.on_remove_clicked(self.remove_button) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): new_item_list = '' new_command_list = '' item = self.command_list.get_iter_first() dataitems = {} if item: while item: if self.command_list.get_value(item, 0)[1:] in dataitems: self.selection.select_path(self.command_list.get_path(item)) self.item_entry.set_text(self.item_entry.get_text() + 'NamesMustBeUnique') return else: dataitems[self.command_list.get_value(item, 0)[1:]]=True comma = ',' if new_item_list == '': comma = '' new_item_list = self.command_list.get_value(item, 0)[1:] + comma + new_item_list new_command_list = self.command_list.get_value(item, 1) + comma + new_command_list item = self.command_list.iter_next(item) self.lines = "dataitems=" + new_item_list + "\nscripts=" + new_command_list c_file = open(self.plugin_file, "w") c_file.write(self.lines) c_file.close() self.on_window_destroy(self) '''On Clicking Add''' def on_add_clicked(self, widget, data=None): myiter = self.command_list.append() self.command_list.set_value(myiter, 0, '$newitem') self.command_list.set_value(myiter, 1, 'echo "newitem"') self.selection.select_path(self.command_list.get_path(myiter)) self.item_entry.set_sensitive(True) self.command_entry.set_sensitive(True) self.remove_button.set_sensitive(True) '''On pressing delete in the list''' def on_remove_clicked(self, widget, data=None): model, paths = self.selection.get_selected_rows() position_selected = self.command_list.get_iter_from_string(str(paths[0][0])) pos = self.command_list.get_path(position_selected)[0] if pos == 0: newpos = (1,) else: newpos = (pos-1,) self.selection.select_path(newpos) self.command_list.remove(position_selected) '''On Changing the item entry''' def on_itementry_changed(self, widget, data=None): model, paths = self.selection.get_selected_rows() try: position_selected = self.command_list.get_iter_from_string(str(paths[0][0])) except: # setting to blank in exception in on_selection_changed return self.command_list.set_value(position_selected, 0, '$'+widget.get_text()) '''On Changing the command entry''' def on_commandentry_changed(self, widget, data=None): model, paths = self.selection.get_selected_rows() try: position_selected = self.command_list.get_iter_from_string(str(paths[0][0])) except: # setting to blank in exception in on_selection_changed return self.command_list.set_value(position_selected, 1, widget.get_text()) '''On changing selection in command list''' def on_selection_changed(self, widget, data=None): model, paths = self.selection.get_selected_rows() try: position_selected = self.command_list.get_iter_from_string(str(paths[0][0])) except: # empty list self.item_entry.set_text("") self.command_entry.set_text("") self.item_entry.set_sensitive(False) self.command_entry.set_sensitive(False) self.remove_button.set_sensitive(False) return dataitem = self.command_list.get_value(position_selected, 0) command = self.command_list.get_value(position_selected, 1) self.item_entry.set_text(dataitem[1:]) self.command_entry.set_text(command) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/wakeup/plugin_scripts/DateTime/DateTime.py000664 001750 001750 00000003447 11741113010 022665 0ustar00dglassdglass000000 000000 #!/usr/bin/env python # plugin GUI preferences class for DateTime # Copyright (C) 2012 David Glass # Copyright is GPLv3 or later, see /usr/share/common-licenses/GPL-3 import pygtk pygtk.require('2.0') import gtk import gtk.glade import os import re class DateTime: def __init__(self, pluginfolder): self.wTree = gtk.Builder() self.wTree.add_from_file("DateTime.glade") self.window = self.wTree.get_object("window1") self.wTree.connect_signals(self) self.date = self.wTree.get_object("entry1") self.time = self.wTree.get_object("entry2") self.plugin_file = os.path.join(pluginfolder, "DateTime.config") dt_file = open(self.plugin_file, "r") self.lines = ''.join(dt_file.readlines()) old_date_format = re.search("date_format\s*=\s*(.*)\s*", self.lines).group(1) old_time_format = re.search("time_format\s*=\s*(.*)\s*", self.lines).group(1) self.date.set_text(old_date_format) self.time.set_text(old_time_format) '''On Clicking Ok''' def on_ok_clicked(self, widget, data=None): self.lines = re.sub("date_format\s*=\s*.*\s*", "date_format=" \ + self.date.get_text() + "\n", self.lines) self.lines = re.sub("time_format\s*=\s*.*\s*", "time_format=" \ + self.time.get_text() + "\n", self.lines) dt_file = open(self.plugin_file, "w") dt_file.write(self.lines) dt_file.close() self.on_window_destroy(self) '''On Clicking Cancel''' def on_cancel_clicked(self, widget, data=None): self.on_window_destroy(self) '''Exit''' def on_window_destroy(self, widget, data=None): self.window.destroy() gtk.main_quit() '''Run the GUI''' def main(self): gtk.main() data/wakeup/plugin_settings/MusicPlayer.plugin000664 001750 001750 00000000340 11741113010 022736 0ustar00dglassdglass000000 000000 (dp0 S'description' p1 S'Play a song on your computer' p2 sS'script' p3 S'MusicPlayer/play_music.sh' p4 sS'text_output' p5 I00 sS'data_items' p6 (lp7 S'music' p8 asS'has_preferences' p9 I01 sS'name' p10 S'MP3 Player' p11 s. data/wakeup/plugin_scripts/MusicPlayer/000770 001750 001750 00000000000 11741113010 021343 5ustar00dglassdglass000000 000000