View Full Version : Get Tomboy Notes into Conky
pt123
May 23rd, 2008, 07:20 PM
I know all of most of you use Conky to remind yourself, about your cpu specs ;)
Anyway here is simple tutorial on getting your Tomboy notes into Conky.
Tomboy is great for jotting down notes, but I don't like to have it open when I am not using. While Conky is perfect for displaying information in a subtle manner.
This Tutorial attempts to take advantage of this, using the awesome D-Bus interface.
This neat tutorial on Arstechnica was of great help.
http://arstechnica.com/journals/linux.ars/2007/09/26/using-the-tomboy-d-bus-interface
Step One Tomboy
I have a note in Tomboy called "Tasks" where I will note down tasks and important reminders. You can use any note in Tomboy for this tutorial.
I was able to write a simple python script (my first python script ) to extract this Tomboy note to a text file. In the script you need to set 2 variables, the name of theTomboy note and the file path to the export text file.
#!/usr/bin/env python
import sys, dbus, gobject, dbus.glib
#Varibale you need to assign values to
noteName = "Tasks" #enter the name of your tomboy note
exportFileName = '/home/myhomefolder/journal/tasks.txt' # the export file
#Read the tomboy note
bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
note = tomboy.GetNoteContents(tomboy.FindNote(noteName))
#export the note
file = open(exportFileName, 'w')
file.write(note) # write the file
file.close() # close it
You need to cut and past the above code into a file called exportTomboyNote.py in a folder.
Then you can run the script in a terminal by
python /pathtoFolder/ exportTomboyNote.py
If you want you can get the script to run every X minutes by editing your cron. I don't want to go into this . This thread deals Cron comprehensively
http://ubuntuforums.org/showthread.php?t=102626
Step Two Conky
To get the note in your Conky, edit your config file.
gedit .conkyrc
Then find the word "TEXT" in it, below it you can add the following line
${head /pathToexportFile/tasks.txt 30 20}
Note. 30 is the number of lines from the top of text file. You also need to increase your text buffer if you planning to read many lines by editing the following lines.
# Maximum size of buffer for user text, i.e. below TEXT line.default is 16384 bytes
max_user_text 32768
That's it.
This was tested on the Tomboy & Conky that came with Hardy 8.04
pt123
June 2nd, 2008, 10:55 PM
Wow, didn't realise this got approved.
Sadly no one found it useful :(
Mandrake12
June 4th, 2008, 02:18 AM
This is great, thanks! Now I'm trying to get todays appointments from evolution calendar / google ical into conky.
pt123
June 4th, 2008, 04:35 AM
This is great, thanks! Now I'm trying to get todays appointments from evolution calendar / google ical into conky.
Thanks
I will post a Tutorial in getting you calendar items from Google Calendar into Conky using gcalcli (it's in the repos) soon.
http://code.google.com/p/gcalcli/
I have submitted the thread I will msg you when it gets approved.
sweetthdevil
June 5th, 2008, 06:54 PM
Well, thanks for the tomboy script, but please let me know for the Google Calendar I am more than interested!
sweetthdevil
June 6th, 2008, 10:03 AM
Well, while we are talking about Tomboy in Conky, It will be nice for the scripts to fetch the layout and also the font (bold/underline/etc etc)
Thanks,
edmondt
June 6th, 2008, 10:09 AM
Wow this is really cool :) Do you have time to post any screenshots and files? :D
sweetthdevil
June 6th, 2008, 01:07 PM
Well, to update the note automatically I placed the following option in my conky:
${execi 900 ~/.scripts/exportTomboyNote.py}
(900 secondes => 15minutes!)
However, every times it does update, tomboy is lunch, and when already lunch the log file become empty.
Is there a way, for the script to be fetching the information without lunching tomboy, and to fetch the information, when tomboy is open?
pt123
June 6th, 2008, 03:56 PM
Well, while we are talking about Tomboy in Conky, It will be nice for the scripts to fetch the layout and also the font (bold/underline/etc etc)
Thanks,
I wanted to be able to do strike through but Conky doesn't seem to be able to handle different changes italics, bold or strike through in fonts.
Conky can do colour and a complete change in font, so I was planning to do a script will show the finished tasks in a different color
so in the above code rather calling GetNoteContents you need to call GetNoteContentsXml
You get an output like this:
<note-content version="0.1">Tasks
Clean Fridge
Clear Dust from Computer
<strikethrough>Clean Bathroom
Hair cut</strikethrough>
<strikethrough>
</strikethrough>
<bold><size:large>Reoccuring</size:large></bold>
.
So you will need to then write a script that will replace <strikethrough> to ${color lightgrey}.
pt123
June 6th, 2008, 04:05 PM
Wow this is really cool :) Do you have time to post any screenshots and files? :D
Not sure what you mean by files the small changes you need to make to your conky are listed in my first post.
Attached is a screenshot which has conky listing my tasks.
pt123
June 6th, 2008, 04:20 PM
Well, to update the note automatically I placed the following option in my conky:
${execi 900 ~/.scripts/exportTomboyNote.py}
(900 secondes => 15minutes!)
However, every times it does update, tomboy is lunch, and when already lunch the log file become empty.
Is there a way, for the script to be fetching the information without lunching tomboy, and to fetch the information, when tomboy is open?
One way to get around this is have Tomboy running in the panel as an applet, which I wind is useful. It neatly hides away as shown in the above screenshot.
Or you can encase the above script in a bash script which will test if Tomboy is running.
#!/bin/sh
if ps ax | grep -v grep | grep "tomboy" > /dev/null
then
#tomboy is running run the script
python exportTomboyNote.py
else
#not running just cat the exported tasks text file
cat exported_tasks.txt
exit
fi
uzi09
June 8th, 2008, 01:01 AM
i just decided to have a nice little text file which conky just displays:
${color slate grey}To Do:
${color}${head /home/uzair/.tasks 30 20}
and if i ever need to add a task, it's as simiple as:
echo "1) Save the world" >> .tasks
to remove, just edit the file and delete the line :)
i guess i never got into using tomboy cuz it required too much. i think note taking should be super quick :)
pt123
June 8th, 2008, 02:19 AM
But then it is cumbersome to delete, I use Tomboy for other stuff so managing tasks through it is effective for me.
I have also wrote a small python script that take completed tasks and place it in another text file so Conky can distinguish the complete & incomplete tasks.
Here is the other tutorial about getting your Google Calendar into Conky
http://ubuntuforums.org/showthread.php?t=818053
sweetthdevil
June 8th, 2008, 07:18 PM
One way to get around this is have Tomboy running in the panel as an applet, which I wind is useful. It neatly hides away as shown in the above screenshot.
Or you can encase the above script in a bash script which will test if Tomboy is running.
#!/bin/sh
if ps ax | grep -v grep | grep "tomboy" > /dev/null
then
#tomboy is running run the script
python exportTomboyNote.py
else
#not running just cat the exported tasks text file
cat exported_tasks.txt
exit
fi
Thanks, but could you please be a little bit specific on how to integrate the code?
pt123
June 8th, 2008, 08:17 PM
Thanks, but could you please be a little bit specific on how to integrate the code?
rather than running this
${execi 900 ~/.scripts/exportTomboyNote.py}
in conky like you wanted to (in your earlier post
run this
${execi 900 ~/.scripts/checkIfTomboyOpenThenExportTomboyNote.sh}
That checkIfTomboyOpenThenExportTomboyNote.sh is the above script I wrote, which checks if Tomboy is open before calling the export python script.
sweetthdevil
June 8th, 2008, 08:50 PM
Alright, sorry to be such an idiot, but I do not know understand the code, so I am asking,
I create the file, in my folder ~./scripts gave it the right to execute, close tomboy to check if working; and obviously something is wrong
"cat: exported_tasks.txt: Aucun fichier ou dossier de ce type"
What should I do?
pt123
June 8th, 2008, 09:00 PM
"cat: exported_tasks.txt: Aucun fichier ou dossier de ce type"
What should I do?
Is looking for the file called exported_tasks.txt in the directory where this script is.
You need to change that line to
cat /path/to/exported_tasks.txt
it is where the initial script saves your tomboy tasks to,
Here is the script more tailored to what you are after
#!/bin/sh
if ps ax | grep -v grep | grep "tomboy" > /dev/null
then
#tomboy is running run the script
python exportTomboyNote.py
else
#not running just cat the exported tasks text file
# do nothing
fi
cat /path/to/exported_tasks.txt
sweetthdevil
June 8th, 2008, 09:05 PM
Many thanks, works great now, but just to make sure I understand.
Now when Conky is going to start, the "checkIfTomboyOpenThenExportTomboyNote.sh"is going to run, if tomeboy is running then the other script is going to fetch the information, but if tomboy is not running, are the information going to be fetch?
pt123
June 8th, 2008, 09:17 PM
but if tomboy is not running, are the information going to be fetch?
yep it will fetch the notes from the last successful fetch by "cat-ing" (reading it) that saved file.
sweetthdevil
June 8th, 2008, 09:37 PM
Little trouble though, when I do like that, both tomboy note and GoogleCalendar got double information.
See attach picture.
http://images0.hiboox.com/vignettes/2408/9179dc520ee6b8709796dec4a6c9c6a8.png (http://www.hiboox.fr/go/images/informatique/capture,9179dc520ee6b8709796dec4a6c9c6a8.png.html)
pt123
June 9th, 2008, 02:02 AM
Post your conky file, and run the sh file in a terminal and post the output here. This should tell which is causing the double up.
sweetthdevil
June 9th, 2008, 04:13 AM
Well, the double information only occurs when tomboy is not running, I checked tasks.txt and gcal.txt and they're ok.
Starting Conky Output:
'/home/sweetth/.scripts/conky_start.sh'
sweetth@ubuntu:~$ Conky: one or more $endif's are missing
Conky: forked to background, pid is 9239
Conky: desktop window (10000b8) is subwindow of root window (13b)
Conky: window type - override
Conky: drawing to created window (3200001)
Conky: drawing to double buffer
Conky: desktop window (10000b8) is subwindow of root window (13b)
Conky: drawing to desktop window
Conky: drawing to double buffer
Conky: desktop window (10000b8) is subwindow of root window (13b)
Conky: window type - override
Conky: drawing to created window (3800001)
Conky: drawing to double buffer
conkyrc2 (tomboy)
use_xft yes
xftfont verdana:size=8
xftalpha 0.8
background no
update_interval 2.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type override
double_buffer yes
cpu_avg_samples 2
net_avg_samples 2
use_spacer right
alignment top_right
gap_x 1110
TEXT
${execi 900 ~/.scripts/checkIfTomboyOpenThenExportTomboyNote.sh}
${font tintin:size=12}${color #d0d3e4}${head /home/sweetth/.scripts/tasks.txt 30 20}${font}${color}
conkyrc3 (Gcalcli)
use_xft yes
xftfont verdana:size=8
xftalpha 0.8
background no
update_interval 2.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_type override
double_buffer yes
cpu_avg_samples 2
net_avg_samples 2
use_spacer right
alignment top_right
gap_x 550
TEXT
${execi 900 ~/.scripts/gcal.sh}
${font tintin:size=12}${color #d0d3e4}${head /home/sweetth/.scripts/gcal.txt 10 20}${color}${font}
Thanks for your help
pt123
June 9th, 2008, 04:22 AM
conkyrc2 (tomboy)
${execi 900 ~/.scripts/checkIfTomboyOpenThenExportTomboyNote.sh}
${font tintin:size=12}${color #d0d3e4}${head /home/sweetth/.scripts/tasks.txt 30 20}${font}${color}
There is the problem, you are reading it twice. When you run execi it outputs the info to conky and then head is reading that same output which was saved to the text file.
So you might want to change it to
${font tintin:size=12}${color #d0d3e4}${execi 900 ~/.scripts/checkIfTomboyOpenThenExportTomboyNote.sh}
and likewise for Gcal
sweetthdevil
June 9th, 2008, 04:49 AM
Many thanks for the quick reply, day and night :lolflag:
Change both like you said, but both conky do not show any result now?
pt123
June 9th, 2008, 05:09 AM
Many thanks for the quick reply, day and night :lolflag:
Change both like you said, but both conky do not show any result now?
I tried to run that script and if was giving an error because the "Else" statement was empty.
So replace that sh with this:
#!/bin/sh
if ps ax | grep -v grep | grep "tomboy" > /dev/null
then
#tomboy is running run the script
python exportTomboyNote.py
fi
cat /path/to/exported_tasks.txt
sweetthdevil
June 9th, 2008, 05:19 AM
Great!! Work fantasticly!!!
Many thanks
sweetthdevil
June 9th, 2008, 08:04 AM
a quick question, my notes are not display completly, you've seen my conkyrc and I had as you suggest in the first topic, "max_user_text 32768" but it didn't change anything, any idea?
pt123
June 9th, 2008, 11:00 PM
rather than
cat /path/to/exported_tasks.txt
try
head /path/to/exported_tasks.txt -n 30
where 30 is the number of lines.
If that doesn't work then you might not be able to execi.
sweetthdevil
June 10th, 2008, 12:50 PM
Well, I found a solution:
I remove the head function from the checkIfTomboyOpenThenExportTomboyNote.sh and had it in the conkyrc
Many thanks for your help!!
apokkalyps
July 15th, 2008, 09:05 PM
If you can do this, in your opinion, how hard would it be to write software that would directly read and write your tomboy notes through an (php?) interface on the web? Making a wiki, so that your tomboy notes can be accessed and modified anywhere...
This would be extremely useful for alot of people and I can't find where anyone has done it yet.
pt123
July 16th, 2008, 04:46 AM
It shouldn't be hard because php has a function that can execute shell functions like the ones used in the my scripts.
If you are look for a wiki you can try zim wiki.
apokkalyps
July 16th, 2008, 03:16 PM
thanks actually I just left mediawiki and started using tomboy, in fact I am desperatly trying to get the content out of my old mediawiki that i stupidly didnt export. Zim seems like tomboy with a few extra features like tree organization of notes and formulaes. Tomboy works fine for me. But neither of them from what I can tell have the ability to host your notebooks through a webserver, which is what I am looking for. Basicly I want read/write access to my tomboy notes from anywhere on the internet. But I dont want anything as bulky and complicated as mediawiki. I want the simplicity of tomboy brought into an online wiki interface.
It surprises me that no one has written a script to host your tomboy files directly as an online wiki. Even the makers of tomboy, it seems like such an obvious way to improve the software. They currently have webdav and ways to synchronize files. But IMO synchronizing is a pain and doesnt really work well in two directions. Plus theres just no need to keep two copies of the files if tomboy is on the same machine as your webserver.
Maybe I am just a small demographic, being someone with my own domain and webserver.
Anyway I didnt mean to threadjack, I just thought you might know something about it.
kmaster228
July 9th, 2009, 01:33 PM
hello this tutorial seems interesting but when i made the python script and ran it i would get and error saying
python exporttom.py
Traceback (most recent call last):
File "exporttom.py", line 17, in <module>
file.write(note) # write the file
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022' in position 6: ordinal not in range(128)
and this is my python script
#!/usr/bin/env python
import sys, dbus, gobject, dbus.glib
#Varibale you need to assign values to
noteName = "Tasks" #enter the name of your tomboy note
exportFileName = '/home/kmaster/Documents/tasks.txt' # the export file
#Read the tomboy note
bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
note = tomboy.GetNoteContents(tomboy.FindNote(noteName))
#export the note
file = open(exportFileName, 'w')
file.write(note) # write the file
file.close() # close it
pt123
July 9th, 2009, 04:14 PM
what sort encoding (UTF, ASCII) is your text file using?
more info
http://www.pyzine.com/Issue008/Section_Articles/article_Encodings.html
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.