Link shortening on hotkey

Install keyboard-shortcuts. Also install CSSU, so as to get keyboard-shortcuts work.

Tune /apps/osso/hildon-desktop/key-actions/dbus_shortcuts_use_fn to press Ctrl-Fn-<letter> instead of Ctrl-Shift-<letter> (if you prefer).

/home/user/.bin/clck.py:

#!/usr/bin/python
import os
import pygtk
pygtk.require('2.0')
import gtk

clipboard = gtk.clipboard_get()
text = clipboard.wait_for_text()

import urllib2
fetcher = urllib2.urlopen('http://clck.ru/--?url=' + text)
text = fetcher.read()

os.system("phone-control --notify 'Link is shortened'")

clipboard.set_text(text)
clipboard.store()

Edit /usr/bin/keyboard-shortcuts:

if key == 'c': # or another letter
    os.system("su user -c 'run-standalone.sh /home/user/.bin/clck.py'")
blog comments powered by Disqus