Edit /usr/lib/firefox-3.5.2/firefox.sh (or equivalent)
Put this line after #!/bin/sh :
python /home/$USER/clipwrap.py &
# Save this (for example) to /home/$USER/clipwrap.py
#Copy from the clipboard:
import os
import time
s = ''
while True:
curs = os.popen('xclip -selection c -o').read()
if len(curs)>0:
s=curs
else:
wcl = os.popen('ps ax|grep firefox|grep -v grep|wc -l').read()
if wcl[0]=='0':
break
time.sleep(.15)
os.popen('echo \"%s\" | xclip -selection c' % s)
#EOF
#Limitations are that it only works with firefox, and if anything else in ps ax matches firefox, it won't detect when firefox ends. Yeah, this could be better, but it's a proof of concept right now. This wrapper also only starts if something is on the clipboard to begin with. And you can adjust the sleep. Right now it wakes up every 150ms. That's bad for laptops or low-power machines. This needs to be fixed higher up on the "source chain". I'll try to make a better workaround too.
Here's a workaround for firefox:
sudo apt-get install xclip
Edit /usr/lib/ firefox- 3.5.2/firefox. sh (or equivalent)
Put this line after #!/bin/sh :
python /home/$ USER/clipwrap. py &
# Save this (for example) to /home/$ USER/clipwrap. py
#Copy from the clipboard:
import os
import time
s = ''
while True:
curs = os.popen('xclip -selection c -o').read()
if len(curs)>0:
s=curs
else:
wcl = os.popen('ps ax|grep firefox|grep -v grep|wc -l').read()
if wcl[0]=='0':
break
time.sleep(.15)
os.popen('echo \"%s\" | xclip -selection c' % s)
#EOF
#Limitations are that it only works with firefox, and if anything else in ps ax matches firefox, it won't detect when firefox ends. Yeah, this could be better, but it's a proof of concept right now. This wrapper also only starts if something is on the clipboard to begin with. And you can adjust the sleep. Right now it wakes up every 150ms. That's bad for laptops or low-power machines. This needs to be fixed higher up on the "source chain". I'll try to make a better workaround too.