How to switch X windows from the command-line?

6,937

Solution 1

Sounds like you're looking for wmctrl - see here for more examples.

Edit: Your window manager/desktop environment has to be standards compliant (EWMH). And here are more examples.

Solution 2

In cases where sr_'s solution does not work, you can also try xautomation. One of the tools included in that package is xte (see manpage) - it simulates keystrokes, mouse movement and more. Here's how you can use it to simulate Alt+Tab:

xte "keydown Alt_L" "key Tab" "keyup Alt_L"
Share:
6,937

Related videos on Youtube

GarouDan
Author by

GarouDan

Updated on September 18, 2022

Comments

  • GarouDan
    GarouDan over 1 year

    How can I create a script that automatically switches windows? I'm trying to do the same thing Alt+Tab does.

  • GarouDan
    GarouDan over 12 years
    Nice! I'll read a bit more about that. Thx.
  • GarouDan
    GarouDan over 12 years
    Thx a lot @rozcietrzewiacz. wmctrl worked fine. But looks like xautomation can't manipulate windows...can it? manpage In your link xautomation I didn't find no documenation... =/
  • rozcietrzewiacz
    rozcietrzewiacz over 12 years
    It can manipulate virtually anything that you can, when you see the screen - just use one of the shipped programs. See my updated answer about Alt+Tab.
  • GarouDan
    GarouDan over 12 years
    is possible simulate F5 key by xte? Didn't find anything in xte or google yet. This is another question that I did.
  • rozcietrzewiacz
    rozcietrzewiacz over 12 years
    @GarouDan Didn't you try? xte "key F5" works perfectly for me.
  • Alex
    Alex about 7 years
    Thanks for the link to wmctrl. Unfortunately it looks like your first link is broken. Here's man wmctrl, which might help others.