You are not logged in.

#1 2009-04-07 22:46:55

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Simple task list. (Openbox Pipe Menu)

Hey all.

Thanks to my new found love for openbox and needing a simple project to get my feet wet in python, I hacked together a simple Task List as a pipe menu.

At the moment, functionality is rather simple. Adding tasks and deleting completed tasks is supported.
Given enough time I will look into adding tags and showing items in a submenu acording to the tags. That is of course if anybody is interested because as is this suites my needs.

Another possible feature could be to look into an available API, say maybe Remember the Milk.

Now I'm not much of a GTD kind of guy, but with proper tag implementation this could be a simple and efficient system.

All data is stored in a file (defined in the script). One could easily place the file in a folder that is synced with other PCs and have your task list follow you around.

Please keep in mind that I'm learning python so this script should be far from "pretty". Any and all suggestions, advice or constructive criticism is very welcome.

Hope you all enjoy it and find it useful.


The mandatory screenshots
Empty List
emptylist.png

Adding a task
addtask.png

List with items
fulllist.png

Conky View
200904090230551280x800scrot.png

The code
Get it here.

Update:
Corrected bugs (Thanks to firecat53 for testing) and added the possibility te see tasks via conky as requested by Mr Green

Update 2:
Finally set up a public repository with wiki and issue tracking. That way it's easier to track the progress of SimpleTasks. Check it out here

Cheers,
P.

Last edited by palobo (2009-04-11 11:46:46)


" If it aint broke... Then you're not trying hard enough! "

Offline

#2 2009-04-08 03:14:29

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Simple task list. (Openbox Pipe Menu)

Very nice! I'm surprised at how simple it is!


neutral

Offline

#3 2009-04-08 05:29:15

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Simple task list. (Openbox Pipe Menu)

I'm trying to test it for you smile I've got the entry in the menu, but there's no 'New Task' button, just a tiny empty black box. I set the tasklistfile = '/home/firecat53/.tasklist' and did a 'touch .tasklist'. I also tried a chmod +x on tasklist.py, but it doesn't seem to be operating correctly. My menu.xml:

<openbox_menu>
<menu id="pipe-tasklist" label="Task List" execute="~/.config/openbox/scripts/tasklist.py menu" />
    <menu id="root-menu" label="OpenBox 3">
    ............
            </menu>
        <separator/>
        <menu id="pipe-tasklist" />
        <menu id="40" label="OpenBox">
            <menu id="client-list-menu"/>
       ...............

What am I missing? I'm sure it's just me smile

Scott

Offline

#4 2009-04-08 08:42:26

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

firecat53 wrote:

I'm trying to test it for you smile I've got the entry in the menu, but there's no 'New Task' button, just a tiny empty black box. I set the tasklistfile = '/home/firecat53/.tasklist' and did a 'touch .tasklist'. I also tried a chmod +x on tasklist.py, but it doesn't seem to be operating correctly. My menu.xml:

<openbox_menu>
<menu id="pipe-tasklist" label="Task List" execute="~/.config/openbox/scripts/tasklist.py menu" />
    <menu id="root-menu" label="OpenBox 3">
    ............
            </menu>
        <separator/>
        <menu id="pipe-tasklist" />
        <menu id="40" label="OpenBox">
            <menu id="client-list-menu"/>
       ...............

What am I missing? I'm sure it's just me smile

Scott

Hi.

Is tasklist.py executable?

Please try this:
<menu id="pipe-tasklist" label="Task List" execute="python ~/.config/openbox/scripts/tasklist.py menu" />.
If that still doesn't work then please open a terminal and try python ~/.config/openbox/scripts/tasklist.py menu. What output do you get?

Cheers,
P.

Last edited by palobo (2009-04-08 08:45:05)


" If it aint broke... Then you're not trying hard enough! "

Offline

#5 2009-04-08 14:43:32

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Simple task list. (Openbox Pipe Menu)

python ~/.config/openbox/scripts/tasklist.py menu gives:

 File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 88, in <module>
    print_menu()
  File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 60, in print_menu
    open_file()
  File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 37, in open_file
    tasklist = pickle.load(f)
  File "/usr/lib/python2.6/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.6/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.6/pickle.py", line 880, in load_eof
    raise EOFError
EOFError

Thanks, Scott

Offline

#6 2009-04-08 16:00:19

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

firecat53 wrote:

python ~/.config/openbox/scripts/tasklist.py menu gives:

 File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 88, in <module>
    print_menu()
  File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 60, in print_menu
    open_file()
  File "/home/firecat53/.config/openbox/scripts/tasklist.py", line 37, in open_file
    tasklist = pickle.load(f)
  File "/usr/lib/python2.6/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.6/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.6/pickle.py", line 880, in load_eof
    raise EOFError
EOFError

Thanks, Scott

Sorry Scott for the inconvenience. It was an error on my part (Being newbie at python that is to be expected ;-) ) I forgot to close the file at the end of open_file().

Please try this corrected version.

#!/usr/bin/env python
#coding: UTF-8

#
# Author: Pedro Lobo <palobo@archlinux.us>
# License: GPL 2.0
#
# A simple Tasklist for Openbox. Displays tasks in Tasklist. Clicking on a task
# renders it complete and therefore removes it from the list.
#
# Usage:
# Create file to store your tasks and set location below.
#
# Put an entry in ~/.config/openbox/menu.xml:
# <menu id="pipe-tasklist" label="Task List" execute="python ~/.config/openbox/scripts/tasklist.py menu" />
#
# Then put the following wherever you'd like it to be displayed in your menu:
# <menu id="pipe-tasklist" />

import sys
import pickle

#
# Set some needed variables in order for the script to function
#
tasklistfile = '/home/pedro/.config/openbox/scripts/tasklist.data'  # File where tasks are to be stored. Use complete path
# tags = ['Important', 'Normal', 'Low']  # Array with possible tags to apply. Future feature maybe...
# params = ()   # Tuple to store optional params for xterm. Used to maybe set geometry, colors etc.


# Start working now
tasklist = []

def open_file():
    # Read back from the storage
    global tasklist
    f = open(tasklistfile, 'rb')
    tasklist = pickle.load(f)
    f.close()
    
def save_file():
    # Write to the file
    global tasklist
    f = open(tasklistfile, 'wb')
    pickle.dump(tasklist, f)
    f.close()

def add_task():
    global tasklist
    open_file()                     #Read current tasklist file
    task = raw_input('New Task: ')
    tasklist.append(task)           #Append new task to tasklist
    save_file()                     # Save tasklist to file

def del_task(task):
    global tasklist
    open_file()
    del tasklist[task]
    save_file()

def print_menu():
    open_file()
    print '<openbox_pipe_menu>'
    print '<item label="New Task">'
    print '<action name="Execute">'
    print '<command>%s</command>' % ('xterm -geometry 100x5+100+100 -e "python ~/.config/openbox/scripts/tasklist.py new"')
    print '</action>'
    print '</item>'
    print '<separator />'
    i = 0   # Var for tasklist index needed for del_task()
    for t in tasklist:
        print '<item label="' + t + '">'
        print '<action name="Execute">'
        print '<command>%s</command>' % ('python ~/.config/openbox/scripts/tasklist.py del ' + str(i))
        print '</action>'
        print '</item>'
        i += 1
    print '</openbox_pipe_menu>'


try:
    if (sys.argv[1] == "new"):
        add_task()

    if (sys.argv[1] == "del"):
        t = int(sys.argv[2])
        del_task(t)

    if (sys.argv[1] == "menu"):
        print_menu()
except IndexError:
    print '<openbox_pipe_menu>'
    print '<item label="Error! Please call pipe menu with menu paramater.">'
    print '</openbox_pipe_menu>'

Cheers,
P.

Last edited by palobo (2009-04-08 16:03:39)


" If it aint broke... Then you're not trying hard enough! "

Offline

#7 2009-04-08 16:21:26

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Simple task list. (Openbox Pipe Menu)

[firecat53@scotty ~]$ python .config/openbox/scripts/tasklist.py new
Traceback (most recent call last):
  File ".config/openbox/scripts/tasklist.py", line 83, in <module>
    add_task()
  File ".config/openbox/scripts/tasklist.py", line 50, in add_task
    open_file()                     #Read current tasklist file
  File ".config/openbox/scripts/tasklist.py", line 38, in open_file
    tasklist = pickle.load(f)
  File "/usr/lib/python2.6/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.6/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.6/pickle.py", line 880, in load_eof
    raise EOFError
EOFError

Still getting errors smile

Scott

Offline

#8 2009-04-08 16:36:13

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: Simple task list. (Openbox Pipe Menu)

wow this looks cool going to test it on my box.....not working here atm.....post your working script.... please


Mr Green

Offline

#9 2009-04-08 16:58:58

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

This should fix the problem. It was an issue with try to pickle.load() an empty file.

#!/usr/bin/env python
#coding: UTF-8

#
# Author: Pedro Lobo <palobo@archlinux.us>
# License: GPL 2.0
#
# A simple Tasklist for Openbox. Displays tasks in Tasklist. Clicking on a task
# renders it complete and therefore removes it from the list.
#
# Usage:
# Create file to store your tasks and set location below.
#
# Put an entry in ~/.config/openbox/menu.xml:
# <menu id="pipe-tasklist" label="Task List" execute="python ~/.config/openbox/scripts/tasklist.py menu" />
#
# Then put the following wherever you'd like it to be displayed in your menu:
# <menu id="pipe-tasklist" />

import sys
import pickle

#
# Set some needed variables in order for the script to function
#
tasklistfile = '/home/pedro/.data'  # File where tasks are to be stored. Use complete path
# tags = ['Important', 'Normal', 'Low']  # Array with possible tags to apply. Future feature maybe...
# params = ()   # Tuple to store optional params for xterm. Used to maybe set geometry, colors etc.


# Start working now
tasklist = []

def open_file():
    # Read back from the storage
    global tasklist
    f = open(tasklistfile, 'rb')
    if f-readline() == '':
        tasklist = []
    else:
        tasklist = pickle.load(f)
    f.close()
    
def save_file():
    # Write to the file
    global tasklist
    f = open(tasklistfile, 'wb')
    pickle.dump(tasklist, f)
    f.close()

def add_task():
    global tasklist
    open_file()                     #Read current tasklist file
    task = raw_input('New Task: ')
    tasklist.append(task)           #Append new task to tasklist
    save_file()                     # Save tasklist to file

def del_task(task):
    global tasklist
    open_file()
    del tasklist[task]
    save_file()

def print_menu():
#    open_file()
    print '<openbox_pipe_menu>'
    print '<item label="New Task">'
    print '<action name="Execute">'
    print '<command>%s</command>' % ('xterm -geometry 100x5+100+100 -e "python ~/.config/openbox/scripts/tasklist.py new"')
    print '</action>'
    print '</item>'
    print '<separator />'
    i = 0   # Var for tasklist index needed for del_task()
    for t in tasklist:
        print '<item label="' + t + '">'
        print '<action name="Execute">'
        print '<command>%s</command>' % ('python ~/.config/openbox/scripts/tasklist.py del ' + str(i))
        print '</action>'
        print '</item>'
        i += 1
    print '</openbox_pipe_menu>'


try:
    if (sys.argv[1] == "new"):
        add_task()

    if (sys.argv[1] == "del"):
        t = int(sys.argv[2])
        del_task(t)

    if (sys.argv[1] == "menu"):
        print_menu()
except IndexError:
    print '<openbox_pipe_menu>'
    print '<item label="Error! Please call pipe menu with menu paramater.">'
    print '</openbox_pipe_menu>'

Thanks for testing this Scott.

Cheers,
P.

Last edited by palobo (2009-04-08 16:59:30)


" If it aint broke... Then you're not trying hard enough! "

Offline

#10 2009-04-08 18:42:53

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Simple task list. (Openbox Pipe Menu)

Ok, it's in the menu now smile But:

[firecat53@scotty ~]$ .config/openbox/scripts/tasklist.py new
Traceback (most recent call last):
  File ".config/openbox/scripts/tasklist.py", line 86, in <module>
    add_task()
  File ".config/openbox/scripts/tasklist.py", line 53, in add_task
    open_file()                     #Read current tasklist file
  File ".config/openbox/scripts/tasklist.py", line 38, in open_file
    if f-readline() == '':
NameError: global name 'readline' is not defined

You can see the xterm window flash up for just a second, and then it disappears.

Scott

Last edited by firecat53 (2009-04-08 20:38:17)

Offline

#11 2009-04-08 19:10:39

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: Simple task list. (Openbox Pipe Menu)

I use conky at the moment to display tasks on desktop

TEXT
To Do
${hr}
${head /home/mrgreen/.stuffigottado.txt 30 20}

I am sure you could work in a way to edit .stuffigottado.txt from menu


Mr Green

Offline

#12 2009-04-09 01:19:46

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

@firecat53: OK, I think that I finally got all the kinks sorted out. It should work fine now.

@My Green: Your wish is my command... big_smile You may use the pipe menu to add and remove tasks. Call the script with conky param and voilá. Details can be found in the script.

Please get the updated and corrected script in the first post. As always, more ideas and sugestions welcome...

Cheers and thanks for testing.
P.


" If it aint broke... Then you're not trying hard enough! "

Offline

#13 2009-04-09 03:03:41

firecat53
Member
From: Sammamish, Wa
Registered: 2007-05-14
Posts: 1,448
Website

Re: Simple task list. (Openbox Pipe Menu)

Cool smile It's all good now. And  now for the challenge......Remember The Milk integration would be superb smile Good work!

Scott

Offline

#14 2009-04-09 05:18:47

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,751

Re: Simple task list. (Openbox Pipe Menu)

That looks so cool cool

Thanks for sharing

MrG


Mr Green

Offline

#15 2009-04-09 08:37:58

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

firecat53 wrote:

Cool smile It's all good now. And  now for the challenge......Remember The Milk integration would be superb smile Good work!

Scott

I'll start looking into that soon. Must first figure out the best way to get tags working because that's going to be needed for RTM.

Cheers,
P.


" If it aint broke... Then you're not trying hard enough! "

Offline

#16 2009-04-10 06:58:10

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: Simple task list. (Openbox Pipe Menu)

What is Milk?

nifty python script, btw!

Offline

#17 2009-04-10 14:29:17

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

Heller_Barde wrote:

What is Milk?

nifty python script, btw!

It's an online Tasklist. Have a look here


" If it aint broke... Then you're not trying hard enough! "

Offline

#18 2009-04-10 22:26:46

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: Simple task list. (Openbox Pipe Menu)

I am getting the following error with the python code palobo:

[stijn@hermes ~]$ python ~/.config/openbox/scripts/tasklist.py menu
Traceback (most recent call last):
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 90, in <module>
    print_menu()
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 62, in print_menu
    open_file()
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 38, in open_file
    tasklist = pickle.load(f)
  File "/usr/lib/python2.6/pickle.py", line 1370, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.6/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.6/pickle.py", line 880, in load_eof
    raise EOFError
EOFError

~/.config/openbox/scripts/tasklist.data is there (had to create it manually though). Maybe you could have the script check by which user it's called and have it create the file automatically if it does not exist yet? Some kind of 'whoami' equivalent for python.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#19 2009-04-11 08:07:00

NeoXP
Member
From: MS Matrix
Registered: 2009-01-09
Posts: 206
Website

Re: Simple task list. (Openbox Pipe Menu)

Amazing script, loving it, using it on multiple pc's for multiple users.

But might I suggest to leave the customization of the output in conky, in the users .conkyrc file? This way it is easier to use the same script for different users with there own desktop/conky look.

Being a noob regarding programming,  I made,  per user based, modification for now. But it would be nice if you could update the script.

edit: typos

Last edited by NeoXP (2009-04-11 08:18:21)


Arch x86_64 on HP 6820s and on HP nx9420. Registered Linux User 350155, since 24-03-2004
"Everyone said that it could not be done, until someone came along who didn't know that."

Offline

#20 2009-04-11 10:45:38

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: Simple task list. (Openbox Pipe Menu)

Sorry, I copied the old code, with the last revision I also get this stuff:

[stijn@hermes ~]$ python ~/.config/openbox/scripts/tasklist.py new
Traceback (most recent call last):
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 86, in <module>
    add_task()
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 53, in add_task
    open_file()                     #Read current tasklist file
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 38, in open_file
    if f-readline() == '':
NameError: global name 'readline' is not defined

Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#21 2009-04-11 10:53:47

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

B wrote:

Maybe you could have the script check by which user it's called and have it create the file automatically if it does not exist yet? Some kind of 'whoami' equivalent for python.

That's a good idea. I'll look into that and try and implement checking/creating the tasklist file. Have you managed to get it to work yet?

NeoXP wrote:

Amazing script, loving it, using it on multiple pc's for multiple users.

But might I suggest to leave the customization of the output in conky, in the users .conkyrc file? This way it is easier to use the same script for different users with there own desktop/conky look.

Glad you like the script. I'll also look into a better way of separating out the conky config. Will have to try and find out if conky can cycle through a result set. Don't know enough conky yet but it's also a great sugestion.


Thanks all for testing/using and your great feedback.

Cheers,
P.

Last edited by palobo (2009-04-11 12:52:30)


" If it aint broke... Then you're not trying hard enough! "

Offline

#22 2009-04-11 10:56:24

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

B wrote:

Sorry, I copied the old code, with the last revision I also get this stuff:

[stijn@hermes ~]$ python ~/.config/openbox/scripts/tasklist.py new
Traceback (most recent call last):
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 86, in <module>
    add_task()
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 53, in add_task
    open_file()                     #Read current tasklist file
  File "/home/stijn/.config/openbox/scripts/tasklist.py", line 38, in open_file
    if f-readline() == '':
NameError: global name 'readline' is not defined

You are using the old code. Revised code and corrections is in a link in the first post. YOu can find it here

edit: I set up a public repository on bitbucket. Find it here. That way it'll be easier to track changes and sugestions.

Cheers,
P.

Last edited by palobo (2009-04-11 11:47:30)


" If it aint broke... Then you're not trying hard enough! "

Offline

#23 2009-04-11 12:38:36

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: Simple task list. (Openbox Pipe Menu)

I copied one of your more recent posts... I'll check the stuff on bitbucket when i'm back home, thanks.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#24 2009-04-11 22:05:57

palobo
Member
From: Leiria, Portugal
Registered: 2009-03-21
Posts: 68

Re: Simple task list. (Openbox Pipe Menu)

OK guys, small update. I've been looking into moving as much conky related stuuf out of the script but unfortunately I found no way of iterating over infonatively in Conky. If anybody knows of a whay please let me know.

Therefore, the best I can manage to acomodate NeoXP's sugestion is to seperate the conky personalization into a separate file but I'll leave that for later.

For now I find it more important to get tags support and later RTM integration and implement B's sugestion of creating the file should it not exist.


" If it aint broke... Then you're not trying hard enough! "

Offline

#25 2009-04-18 13:00:23

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819

Re: Simple task list. (Openbox Pipe Menu)

Cool smile.

I was wondering if it would be possible to have the script called with two arguments (e.g. menu $file) so one can use the script to edit multiple files (and maintain multiple lists)? E.g. a to-do list, a grocery list, a list of books you want, etc. Now it's hardcoded in the script (well one can change it of course) but I suspect it's just more than changing one line.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

Board footer

Powered by FluxBB