17

I'm trying to map alt tab behavior to a mouse button using xdotool in my .xbindkeysrc. What I want to do is map something like

"xdotools keydown alt key Tab"
release b:7

but by doing this the alt key gets stuck, and it prevents my other mappings from working until I press the alt key on the keyboard. Is there a way to do this without having to press the alt key to get things unstuck? Without keydown it just switches back and forth between two windows, with keydown it behaves like I want (displaying the alt-tab switcher) but the alt key is stuck. Is there a way to unstick the key after using the alt tab switcher using xdotools?

2
  • 3
    I think you have to set the alt key to release too. Apr 15, 2012 at 3:25
  • @ fossfreedom I believe he means another invocation of xdotool. Like: xdotool keyup alt "simulation" because it is a simulation of the user doing something with the keyboard.
    – user344200
    Oct 31, 2014 at 7:06

5 Answers 5

20
"xdotool keydown alt key Tab; sleep 2; xdotool keyup alt"
b:7

The sleep interval allows me to access the menu and choose, and then it closes automatically. It's probably not the best solution but it works. If anyone has a better alternative please let me know. I find that xbindkeys only seems to work intermittentlly. It does not work on the overview (not for this command, but for a button tied to the super key. And after installing docky, I fnid that it does not work unless there is an open window available in the workspace. Odd behavior.

2

Alternative which works for me.

3-finger swipe right:

xdotool keydown 0xffea + key 0xff09

Explanation:
▪It simple holds ALT and presses TAB at same time.
▪This allows access the menu.
▪Once you select from menu you have to to release the holded ALT key by performing 3-finger swipt left operation.


3-finger swipe left:

xdotool keyup 0xffea

Explanation:
▪ It simple releases the ALT key.
0xffea is value of ALT key.
0xff09 is value of TAB key.

Please note that both commands must be executed, otherwise the system gets stuck. It then is not possible anymore to enter any text, because the Alt key has not been released.

3
  • 4
    the command alone keeps the locked state of the alt key
    – FantomX1
    Sep 21, 2020 at 1:21
  • 2
    took me a while to get unstuck with this. Luckily I switched to the laptop's built-in keyboard (which worked).
    – Asaf
    Aug 11, 2021 at 16:37
  • 2
    Nice trolling with this. Had to reboot to escape, lol
    – Inigo
    Oct 1, 2022 at 18:17
2

Gary's answer works for me, but switches always between 2 apps only.
I would use this to switch between all open apps:

xdotool keydown alt key Tab key Left key Left; sleep 2; xdotool keyup alt
-1

well, I think it over and found there is a workaround, you can just make another simulation to perform alt key release. This should be the most convenient way to simulate window switch with mouse gesture.

1
  • 7
    ... and for those of us who dont know what is a "simulation" and how to do this - perhaps you can explain this in your answer. Thanks.
    – fossfreedom
    Sep 7, 2012 at 15:17
-1

slide all tab alt+tab, slide all windows alt+esc:

#!/bin/bash while true; xdotool keydown alt; do sleep $(shuf -i2-5 -n1) xdotool key Escape ;sleep 2;xdotool key Return; done

1
  • this could definitely use some explanation and improvement on clarity.
    – john-jones
    Nov 22, 2023 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .