I wanted something like pandoraman in linux, so I wrote a simple python script that would give me that functionality.
You can download it here: http://code.google.com/p/pypandora/
Aside from the weird LD hack I had to do to get it to stop segfaulting, I was rather impressed by how easy this was to do.
The hack is kind of interesting (don't read on unless you are a geek):
When you try to embed mozilla in a pygtk program on ubuntu, it will segfault. It turns out this is because /usr/lib/firefox is not in LD_LIBRARY_PATH by default. My trick was to write a script that is both a python and shell script at the same time.
At the top of most unix scripts, you see a line like "#!/bin/sh". This line tells the OS what program can run the script. The top of my script looks like this:
#!/bin/sh
"""echo"
exec env LD_LIBRARY_PATH=/usr/lib/firefox python $0
"""
This gets executed by /bin/sh. First it will echo an empty line, then it will execute the command after "exec", which sets the LD path, and calls python on $0, which holds the name of the currently executing script. Since python uses three quotes to open a multi-line string, python never interperates the shell script at the top, and keeps on executing. Tricky, huh?
8.31.2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment