年纪大了,就越来越倚重一些工具辅助记忆了,比如一些日常要进行的工作。使用的ubunut,一直感觉conky不错,幸而conky也支持类似todo list的功能,只需在.conky.rc中添加

${color FF0000}${font WenQuanYi ZenHei:size=18}${execpi 120 cat ~/.todo.txt}${font}

其中todo.txt为存放todo项目文件。为了日常管理方便,又增加了python小程序处理todo list的增添删除等

'''Created on Jul 31, 2013@author: yisi'''import  sysclass todoManager:    __TODOFILE = ''    __fd = -1    __buf = []                    def __init__(self, name=None):        self.setFileName(name)        try:            self.__fd = open(self.__TODOFILE, 'r+w')            self.initBuf()        except IOError as e:            print "Can't open {0},error({1}):{2}".format(self.__TODOFILE, e.errno, e.strerror)    def getFileName(self):        return self.__TODOFILE    def setFileName(self, name):        if name == None:            self.__TODOFILE = "todo.txt"        else:            self.__TODOFILE = name                    def initBuf(self):        self.__fd.seek(0)        self.__buf = []        for i in self.__fd:            self.__buf.append(i.strip())        self.__fd.seek(0)                        def readBuf(self):        print self.__buf                                def readTodo(self):        if len(self.__buf) != 0:            lineNums = 1            for i in self.__buf:                print "{0}: {1}".format(lineNums, i)                lineNums += 1        else:            print "Nothing to do ~"                                def addItems(self, item):        for i in item:            self.__buf.append(i)                        def delItems(self, index):        list.sort(index)        counter = 1        for i in index:            intI = int(i) - counter            self.__buf.remove(self.__buf[intI])            counter += 1    def writeToFile(self):        try:            self.__fd.truncate()        except IOError as e:            print "Truncate error({0}): {1}".format(e.errno, e.strerror)        except :            print sys.exc_info()[0]            raise        for i in self.__buf:            try:                self.__fd.write(i + '\n')            except IOError as e:                print "Write error({0}): {1}".format(e.errno, e.strerror)                                    self.initBuf()                    def closeFile(self):        self.__fd.close()

以上为管理类,下为具体操作

#!/usr/bin/env python# coding=utf-8'''Created on Jul 31, 2013@author: yisi'''import todoManagerFILE = "/home/yisi/.todo.txt"t = todoManager.todoManager(FILE)flag = 1def printHelp(t=None):  # @UnusedVariable    print "-" * 10 + "todo_tools" + "-" * 10    print "\t" + "1. 显示当前todo list"    print "\t" + "2. 删除todo项目"    print "\t" + "3. 增加todo项目"    print "\t" + "4. 保存todo项目"    print "\t" + "5. 显示帮助信息"    print "\t" + "6. 退出todo_tools"    print "-" * 10 + "todo_tools" + "-" * 10            def printCurTodo(t):    t.readTodo()def insertItem(t):    itemS = raw_input("Please input something to do:")    item = itemS.split(' ')    while '' in item:        item.remove('')    t.addItems(item)def delItem(t):    indexS = raw_input("Please input index to delete:")    index = indexS.split(' ')    while '' in index:        index.remove()    t.delItems(index)            def saveItem(t):    t.writeToFile()def exitProg(t):    t.closeFile()    global flag    flag = 0         SW = {            '1':printCurTodo,            '2':delItem,            '3':insertItem,            '4':saveItem,            '5':printHelp,            '6':exitProg}  def mainProg():    global  flag    while  flag:        numProg = raw_input("Please input num(1-6):")        SW[numProg](t)                           if __name__ == "__main__":    printHelp()    mainProg()

哈哈,最后,上图