Hi there,
I thought that some kind of calendar, or birthdays or todo plugin
would be nice. So I hacked this one. I´m sending to the list with the
hopes that someone could help me improve it. I need help with the
graphics (for now, just using the "blue" and "red" buttons), and with
the output (how to do a scroll box?). BTW it is using the "headlines"
skin maybe a better one should be made.
Well, about the plugins. The file remindicon.py should be put in
freevo/plugins/idlebar, and once active with
plugin.activate('idlebar.remindicon') will show a bluebutton on
idlebar if you have no reminders for today, or a redbutton if you have
at least one.
The file remind.py should be put in freevo/plugins and made active
with plugin.activate('remind', level=45). So you will now have a
"reminds" item on main menu. Once selected you will have the option to
see today reminds or the next 7 days reminds (it is easy to add more
options, like month reminds).
Of course, you will have to have the "remind" command installed,
either from source[1] or from your distro package.
both plugins can use the follow 3 variables:
REMIND_CMD (defaults to /usr/bin/remind)
REMIND_ARGS (use the default)
REMIND_FILE (if it´s not defined remind will try to read ~/.reminders)
[1] http://www.roaringpenguin.com/en/penguin/openSourceProducts/remind
I guess my poor english will need some fixes too. I know... I will
submit the files with the right svn diff command, but I´m looking for
some feedback first.
--
Christian Lyra
PoP-PR/RNP
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# remind.py - IdleBarplugin for monitoring the remind command output
# Author: Christian Lyra
# -----------------------------------------------------------------------
#
# python modules
import os
import popen2
import time
# freevo modules
from plugins.idlebar import IdleBarPlugin
import plugin, config
class PluginInterface(IdleBarPlugin):
"""
Show the status based on remind command output.
Activate with:
plugin.activate('idlebar.remindicon')
You can define where´s the remind command, the args and the remind file with:
REMIND_CMD (defaults to /usr/bin/remind)
REMIND_ARGS
REMIND_FILE (if it´s not defined remind will try to read ~/.reminders)
obs: remind will be called only once per minute.
"""
def __init__(self):
IdleBarPlugin.__init__(self)
self.plugin_name = 'idlebar.remindicon'
self.time = 0
icondir = config.ICON_DIR
self.images = {}
self.images['alert'] = os.path.join(icondir, 'misc/redbutton.png')
self.images['nothing'] = os.path.join(icondir, 'misc/bluebutton.png')
self.status = self.images['nothing']
if hasattr(config, 'REMIND_CMD'):
self.remind_cmd = config.REMIND_CMD
else:
self.remind_cmd = '/usr/bin/remind'
if hasattr(config, 'REMIND_ARGS'):
self.remind_args = '-h %s' % config.REMIND_ARGS
else:
self.remind_args = '-h'
if hasattr(config, 'REMIND_FILE'):
self.remind_file = config.REMIND_FILE
else:
self.remind_file = ''
self.cmd = '%s %s %s' % (self.remind_cmd, self.remind_args, self.remind_file)
def getStatus(self):
if (time.time()-self.time)>60:
self.time = time.time()
try:
inst = popen2.Popen4(self.cmd)
(r, w) = (inst.fromchild, inst.tochild)
f = r.readlines()
r.close()
w.close()
inst.wait()
except:
pass
if f:
self.status = self.images['alert']
if config.DEBUG:
print "Remind: ", f
else:
self.status = self.images['nothing']
def draw(self, (type, object), x, osd):
self.getStatus()
width = 0
width += osd.draw_image(self.status, (x+width, osd.y + 10, -1, -1))[0] + 10
return width
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# remind.py - a simple plugin to show the output of a remind cmd
# -----------------------------------------------------------------------
#
# Notes:
# Todo:
# activate:
# plugin.activate('remind', level=45)
# REMIND_CMD = '/path/to/remind_cmd'
# REMIND_ARGS = 'remind args'
# REMIND_FILE = '/path/remind_file'
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2003 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------
#python modules
import os, time, popen2
#freevo modules
import config, menu, rc, plugin, skin, osd, util
from gui.PopupBox import PopupBox
from item import Item
#get the singletons so we get skin info and access the osd
skin = skin.get_singleton()
osd = osd.get_singleton()
skin.register('remind', ('screen', 'title', 'info', 'plugin'))
class PluginInterface(plugin.MainMenuPlugin):
"""
A plugin to show the output of remind cmd.
To activate, put the following lines in local_conf.py:
plugin.activate('remind', level=45)
"""
def __init__(self):
plugin.MainMenuPlugin.__init__(self)
def items(self, parent):
return [ RemindMainMenuItem(parent) ]
class ShowRemindDetails:
"""
Screen to show the details of the remind items
"""
def __init__(self, (item, menuw)):
self.menuw = menuw
self.menuw.hide(clear=False)
rc.app(self)
skin.draw('headlines', item)
def eventhandler(self, event, menuw=None):
"""
eventhandler
"""
if event in ('MENU_SELECT', 'MENU_BACK_ONE_MENU'):
rc.app(None)
self.menuw.show()
return True
return False
class RemindMainMenuItem(Item):
"""
this is the item for the main menu and creates the list
of remind outputs in a submenu.
"""
def __init__(self, parent):
Item.__init__(self, parent, skin_type='headlines')
self.name = _('Reminds')
if hasattr(config, 'REMIND_CMD'):
self.remind_cmd = config.REMIND_CMD
else:
self.remind_cmd = '/usr/bin/remind'
if hasattr(config, 'REMIND_ARGS'):
self.remind_args = config.REMIND_ARGS
else:
self.remind_args = ' '
if hasattr(config, 'REMIND_FILE'):
self.remind_file = config.REMIND_FILE
else:
self.remind_file = ''
def actions(self):
"""
return a list of actions for this item
"""
items = [ ( self.create_remind_menu , _('Reminds Menu' )) ]
return items
def create_remind_menu(self, arg=None, menuw=None):
remind_types = []
title = _("Today Reminds")
cmd = "%s %s %s" % (self.remind_cmd, self.remind_args, self.remind_file)
mi = menu.MenuItem('%s' % title, self.show_details, 0)
mi.arg = (mi, menuw)
mi.description = self.run_remind(cmd)
remind_types.append(mi)
title = _("Next 7 days")
cmd = "%s -h %s %s *7" % (self.remind_cmd, self.remind_args, self.remind_file)
mi = menu.MenuItem('%s' % title, self.show_details, 0)
mi.arg = (mi, menuw)
mi.description = self.run_remind(cmd)
remind_types.append(mi)
remind_menu = menu.Menu(_('Remind type'), remind_types)
rc.app(None)
menuw.pushmenu(remind_menu)
menuw.refresh()
def show_details(self, arg=None, menuw=None):
ShowRemindDetails(arg)
def run_remind(self, cmd):
"""execute the remind command and pretify the output"""
output = ''
try:
inst = popen2.Popen4(cmd)
(r, w) = (inst.fromchild, inst.tochild)
f = r.readlines()
r.close()
w.close()
inst.wait()
#pretify the output
for line in f:
output += line
except:
pass
return output
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-users mailing list
Freevo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-users