The xdotool command on Linux can automate just about any keystroke or mouse actions from the command line, or for shortcut keys

I’m busy looking into xdotool to automate various actions on Linux with the Elgato Stream Deck (well because Elgato only provides apps for Windows and MacOS). There is a good Linux alternative app to work with the Stream Deck, but I do need to be able to execute some commands when I want to bring a specific window into focus from the background, and then to execute a key press shortcut. So an example may be to bring Brave Beta browser window into focus, then activate tab 3 and do a tab fresh.

Another tip I worked out is instead of struggling to identify which window has which name exactly, you can also right-click on a window’s title bar and choose to rename the window. When I restarted that application, it retained the window name.

So, to bring Brave Beta browser into focus, activate tab 2 (CTRL-2), and then do a fresh (CTRL-R), I can just set this command string to a hot key on the Stream Deck: ‘xdotool search –name ‘Brave-Beta’ windowactivate –sync key ctrl+2 ctrl+r’.

You can still do this sort of thing without having any Stream Deck by just setting the same string to any Linux shortcut on the keyboard.

Xdotool lets you simulate keyboard input and mouse activity, move and resize windows, etc. It does this using X11’s XTEST extension and other Xlib functions. With xdotool, you can search for windows and move, resize, hide, and modify window properties like the title. If your window manager supports it, you can use xdotool to switch desktops, move windows between desktops, and change the number of desktops.

See github.com/jordansissel/xdotool

eshep,

@GadgeteerZA Most every window manager is going to inherently have a way to set hotkeys/keybindings/shortcuts...whatever you wanna call em. But you're certainly on the right track using xdotool. I'm eager to hear how it goes!

GadgeteerZA,
@GadgeteerZA@beehaw.org avatar

@eshep Too right, I discovered that great trick to rename the Window was only working with the Brave browser windows. OBS Studio by default does not have that option. Also, my having num lock keys to work as mouse pointer movements was interfering with those shortcut keys. I could use wmctrl to rename a window title but it is only temporary. So still work in progress.

MisterDigital,

Note for the folks using Wayland, there’s also ydotool that doesn’t require X11: github.com/ReimuNotMoe/ydotool

SafetyGoggles,

But it does not work well at all, especially when you try to get the mouse cursor to a certain coordinate. The same coordinate gets different results every boot for some reason.

You also have to run a background service for it to work.

GadgeteerZA,
@GadgeteerZA@beehaw.org avatar

Yes I think right at the bottom of the page I linked to, they mentioned two options for Wayland.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines