3

I am using gnome-shell 3.14 on archlinux 3.17.3-1. I have a keyboard shortcut (ctrl+alt+T) to open an xfce4-terminal.

My issue is that when I triger this shortcut the focus is not set the the newly open terminal. I tried adding to my .zshrc

[[ -n "$DISPLAY" ]] && wmctrl -i -a $(wmctrl -l | grep Terminal | tail -n 1 | cut -d ' ' -f1)

And that worked ... until I tried opening multiples tabs in a terminal. When opening a new tab, .zshrc is run and the focus is moved to the last terminal, wich may not be the open I am currently working on.

So I removed the command from my .zshrc file and tried editing the command executed my the shortcut keyboard to

xcfe4-terminal&
sleep 0.1
wmctrl -i -a $(wmctrl -l | grep Terminal | tail -n 1 | cut -d ' ' -f1)

I tried increassing the sleep duration, but still it doesn't do the job (focus isn't set)

Therefore I have 2 question :

  • Is it possible to somehow have a script get the window id of the xfce4-terminal running the script ?

  • Is it possible to run a command when opening a xfce4-terminal (like if it has in the .zshrc even thow it's not in it). I tried the --execute option but it doesn't suit my needs as is only runs the focusing command and leaves me with a useless window

2 Answers 2

2

I know this thread is 3 years old already but I've been suffering from the same problem lately as I moved from plasma to cinnamon. This is what I came up with

Add this to your .zshrc(or any other shell config file)

xdotool windowactivate $(xdotool search --onlyvisible --class 'xfce4-terminal' | tail -n1) &>/dev/null
0

I had this problem too. I've changed my keyboard shortcut to xfce4-terminal --disable-server and now the terminals seem to get focus properly.

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jun 14, 2022 at 18:30

You must log in to answer this question.

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