I'm using 12.04, WIN+1 is a hotkey in Unity, and now I've removed unity and changed shell to gnome-shell-3.4, but I still cannot use WIN+NUM as an hotkey change to desktop NUM, I set it in system settings but nothing happens.

thks for any help.


I assume that you want to bind for any bash command.

1.0 First get commands to change workspace from terminal

  • Go to first workspace. Open terminal and run wmctrl -d | awk '{print $6} for me it yields 0,0 note it as co-ordinates of first workspace.

  • Move terminal to Next workspace and do above procedure again for all workspaces.

My output after doing above steps

virpara@Ascension:~$ wmctrl -d | awk '{print $6}' #in workspace 1
virpara@Ascension:~$ wmctrl -d | awk '{print $6}' #in workspace 2
virpara@Ascension:~$ wmctrl -d | awk '{print $6}' #in workspace 3
virpara@Ascension:~$ wmctrl -d | awk '{print $6}' #in workspace 4

You may be thinking What we've got after doing this? we have co-ordinates to switch to desired workspace.

We can use wmctrl -o X,Y to switch to respective workspaces. where X,Y are your workspace co-ordinates.

For me, Commands to switch to workspaces are as follows,

For Workspace 1 => wmctrl -o 0,0
For Workspace 2 => wmctrl -o 1366,0
For Workspace 3 => wmctrl -o 0,768
For Workspace 4 => wmctrl -o 1366,768

2.0 Set HotKeys for those commands

How to install AutoKey

Open software center > search for autokey > install AutoKey(GTK)

How to bind any key ?

Step 1 :

Press Ctrl+Shift+N or from File > Create.. > New Script. Rename with whatever you like.

enter image description here

Step 2 :

Paste below code as shown, I'll bind Super+1 to Workspace 1. Replace wmctrl -o 0,0 with your command.

import os
os.system("wmctrl -o 0,0")

enter image description here

Step 3 :

Then in bottom-right corner there is three Set buttons to set for Abbreviation or Hotkey or Window Filter. Click second Set button (because we want to set hotkey).

enter image description here

Step 4 :

Click Super then Click Press to Set and hit a key you want to assign(in your case 1. I'm hitting 1).

enter image description here

Step 5 :

Click OK.

Step 6 :

Click Save in bottom-right corner.

enter image description here

Try hitting Super+1.

Go to Step 1 : and do this for all commands you got earlier in 1.0 to bind to Super+2, 3, 4 .

  • well, but what if I want to use WIN+1,2,3 to change to desktop 1,2,3...?
    – Nami WANG
    Jun 10 '12 at 5:13
  • @namiheike I've edited answer. Jun 10 '12 at 12:42
  • thks, it works.
    – Nami WANG
    Jun 12 '12 at 8:26
  • well, but if I press WIN+2 in a textbox, It will first input a '2' char, then change to desk 2, is there any way to solve this? sendkey another backspace?
    – Nami WANG
    Jun 12 '12 at 8:49
  • 1
    well, I should check the option "trigger immediately". thx
    – Nami WANG
    Jun 13 '12 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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