You are not logged in.
Hello,
i tried to make an openbox-pipemenu for firefox 3 bookmarks with a program called "obm-moz" from the author of obmenu.
Unfortunately it is not working. The pipemenu itself works and it shows some of my bookmarks.
My bookmarks in FF are sorted into subfolders, but obm-moz only shows the content of the first subfolder. I already tried to get some help in the german arch forums, a user there told me that firefox 3 is not storing its bookmarks in bookmarks.html anymore. Therefore i exported my bookmarks to a html-file but still only the first subfolder of bookmarks is shown in openbox - maybe obm-moz is outdated for new firefox-versions?
Any ideas how to get my FF-bookmarks into an openbox-pipemenu?
Thanks for your help
Christian
PS: sry for bad english^^
Last edited by cl10k (2009-08-03 10:54:18)
Offline
Hi Christian,
I've written a small python script that should work, haven't really tested it yet as i don't use openbox
here you go:
/e this is the tested and working revision
#!/usr/bin/env python
import sqlite3
from xml.sax.saxutils import quoteattr
import shutil
import tempfile
browser = 'firefox'
ffsqlite= '/home/user/.mozilla/firefox/profilename/places.sqlite'
def print_label(title, url):
print '<item label=%s>' % (quoteattr(title.encode('utf-8')))
print '<action name="Execute">'
print '<command>%s %s</command>' % (browser, quoteattr(url.encode('utf-8')))
print '</action>'
print '</item>'
def rbuild_tree(id, title, conn, first_run=False):
if first_run:
print '<openbox_pipe_menu>'
else:
print '<menu id="%s" label=%s>' % (id, quoteattr(title.encode('utf-8')))
c2 = conn.cursor()
c2.execute('select id, title, type from moz_bookmarks b where parent=? and type=2;', (id, ))
for sid, stitle, type in c2:
rbuild_tree(sid, stitle, conn)
c2.execute('select b.title, p.title, p.url from moz_bookmarks b, moz_places p where b.fk = p.id and b.type=1 and parent=?;', (id, ))
for btitle, ptitle, url in c2:
if url == None or url.startswith('place'):
continue
if btitle != None:
print_label(btitle, url)
else:
print_label(btitle, url)
if first_run:
print '</openbox_pipe_menu>'
else:
print '</menu>'
def main():
tf = tempfile.NamedTemporaryFile('r', suffix='.sqlite')
shutil.copyfile(ffsqlite, tf.name)
conn = sqlite3.connect(tf.name)
rbuild_tree(2, '', conn, True)
conn.close()
tf.close()
if __name__ == '__main__':
main()
Save it as somefile.py, change ffsqlite to match your username and profile, set it executable and use it as command in your pipe menu.
Regards,
raf
Last edited by raf_kig (2009-08-05 00:55:33)
Offline
Wow! Very kind! I will try it asap.
Thank You!
Offline
I just realized that you maybe wanted to have folders as submenus while this implementation is flat
If so leave me a note, I might have the time to add folder support later.
Regards,
raf
Offline
here is a version that uses subfolders, it's hacked together quite ugly but it should work, uses only bookmarks from the bookmark menu right now
see above
Last edited by raf_kig (2009-08-05 00:54:40)
Offline
Hi raf_kig, i tried your script but it doesn't work. If i run it from the shell the openbox-menu-tree looks good - i can't find any errors, but from the openbox-menu it doesn't "unfold" into a menu structure.
This is how i start the script from the openbox-menu:
<menu execute="python ~/.config/openbox/scripte/ffpipe.py" id="ffbooks" label="Bookmarks"/>
Openbox pipemenus are very new to me, maybe i made a mistake. The topic has 120 views now and i think more people are interested in your script. Maybe the error is with me. let's see what others think about the script.
In the meantime, thank you so much for your work - this is really appreciated!!
kind regards
christian
Last edited by cl10k (2009-08-04 19:45:30)
Offline
You are welcome :-)
I've just installed ob and tested it with the following menu.xml
<openbox_menu>
<menu id="root-menu" label="root">
<menu id="ff-menu" label="ff bookmarks" execute="/home/raphael/test.py" />
</menu>
</openbox_menu>
This way I have a root menu containing one submenu with the label 'ff bookmarks' and everything seems to work fine.
If you still have troubles maybe post your complete menu file here.
Regards,
raf
/edit : Try running openbox from the commandline, it might tell you about syntax errors in the xml output (if there are any, works for me ;-))
Last edited by raf_kig (2009-08-04 20:07:57)
Offline
Hmm still not working. I double-checked the path in the python-script and replaced my own menu.xml with yours - same situation...
the xml-code seems to be without errors, otherwise "openbox --reconfigure" would tell me...
Like i said before, when i run your script from the shell it seems to work - atleast i can't find any mistake in the code.
Just an idea, i don't know anything about scripting or python but does your script use any variables from "places.sqlite" which could be named differently in a german firefox? just as an example: in german "menu" is called "menü"
ps: if you don't mind, i will post your script, with full credit to you, in the german arch forums. i want to know if other users have the same problem...
Last edited by cl10k (2009-08-04 20:52:28)
Offline
Hmm still not working. I double-checked the path in the python-script and replaced my own menu.xml with yours - same situation...
the xml-code seems to be without errors, otherwise "openbox --reconfigure" would tell me...
I mean the generated xml code, reconfigure will only parse the static xml from your config, but it won't tell you if it doesn't like the runtime-generated xml
Just an idea, i don't know anything about scripting or python but does your script use any variables from "places.sqlite" which could be named differently in a german firefox? just as an example: in german "menu" is called "menü"
I didn't test it with umlauts, will do that now (I'm from germany ;-)), but the sql structure won't be touched by that.
ps: if you don't mind, i will post your script, with full credit to you, in the german arch forums. i want to know if other users have the same problem...
Go ahead :-)
Regards,
raf
Last edited by raf_kig (2009-08-04 21:01:18)
Offline
I cleaned it up a bit and fixed some errors, works with umlauts in menunames etc
See above
Regards,
raf
Last edited by raf_kig (2009-08-05 00:55:10)
Offline
It works like a charm now! Thank you so much!
If you ever visit Stuttgart i buy you a beer or two ;-)
I will update my thread about this topic in the german archforum. I believe more users are interested in your script!
here is the link to the topic: http://forum.archlinux.de/?page=Posting … st=-1#last
Vielen Dank,
Mit freundlichen Grüßen
Christian
Last edited by cl10k (2009-08-04 21:35:23)
Offline
It works like a charm now! Thank you so much!
If you ever visit Stuttgart i buy you a beer or two ;-)
[...]
Vielen Dank,Mit freundlichen Grüßen
Christian
Sollte ich mal in Stuttgart sein (ist nicht so weit weg) komm' ich darauf zurueck :-)
Regards,
raf
Offline