I would like to create a keyboard shortcut that will open a new terminal window only if none exists on the current desktop. Otherwise, the currently existing one will be focused. I just upgraded from Fedora 24 to Fedora 25. Before upgrading, I had the following script bound to
desktop="$(xdotool get_desktop)" # Get number of current desktop #Check if there is an open terminal on the current desktop. output="$(xdotool search --onlyvisible --class --desktop $desktop gnome-terminal)" if [[ -n "$output" ]] then xdotool windowactivate $output #If there is, then move focus to it. else gnome-terminal & #Otherwise, open a new terminal. fi
However, it seems that the update has broken the script, and it no longer runs properly; a new terminal is always opened, regardless of the presence of an existing one. As a test, I tried running this one liner
desktop="$(xdotool get_desktop)" && for i in $(xdotool search --desktop $desktop --class ".*"); do xdotool getwindowname $i; done. Unsurprisingly, its output never includes the name of an existing terminal window. It seems that the problem is that
xdotool no longer recognizes the gnome-terminal in Fedora 25, and as a result the above script will always create a new terminal.
xdotool getwindowfocus getwindowname in terminal returns:
xdo_get_focused_window_sane failed (code=1) xdo_focus_window reported an error
So it really seems that xdotool can no longer recognize