Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In xfce I would like to switch to a particular workplace by pressing two keys after each other. for example first F2 and than the letter A. Control-A together is hard to type for me.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This program, switches to screen 0-9 and a-z, (11 - 37). It needs to callable chmod +x switcher.py and be called by a shortcut in key/shortcuts.

import subprocess


import Tkinter as tk


class App(object):
    def __init__(self, master, **kwargs):
        self.master = master
        master.geometry('200x200+0+0')
        master.bind('<KeyPress>', self.react_to_keypress)
        master.after(2500, quit)

    def react_to_keypress(self, event):
        key = event.char.lower()
        try:
            int(key)
        except ValueError:
            if ord(key) < 97 or ord(key) > 122:
                return False
            else:
                key = str(ord(key) - 97 + 10)
                print key
        subprocess.call(["/usr/bin/wmctrl", "-s " + key])

    def quit(self):
        self.master.quit()

root = tk.Tk()
app = App(root)

root.mainloop()
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.