You are not logged in.
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
Adding a task
List with items
Conky View
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
Very nice! I'm surprised at how simple it is!
Offline
I'm trying to test it for you 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
Scott
Offline
I'm trying to test it for you
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
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
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
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
[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
Scott
Offline
wow this looks cool going to test it on my box.....not working here atm.....post your working script.... please
Mr Green I like Landuke!
Offline
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
Ok, it's in the menu now 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
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 I like Landuke!
Offline
@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... 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
That looks so cool
Thanks for sharing
MrG
Mr Green I like Landuke!
Offline
Cool
It's all good now. And now for the challenge......Remember The Milk integration would be superb
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
What is Milk?
nifty python script, btw!
Offline
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
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
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
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
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?
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
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
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
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
Cool .
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