The problem#
Previously, I wrote a script for opening and
immediately focusing xfce4-appfinder
. But
xfce4-appfinder
will notice if it's already open and just assume
you want to use the existing window. Even if it's on a different
desktop. And therefore attempting to focus it will either do nothing or
switch to that desktop, neither of which is desirable.
The solution#
The actual solution I settled on is more of a workaround than a
solution: having xfce4-appfinder
on a different desktop doesn't
really make sense, so I just set it to be on all desktops (specified
as the non-existent desktop -1
), so it would never be on the wrong
desktop:
xdotool set_desktop_for_window "$winid" -1
To actually move the window to the current desktop, replace
xdotool windowactivate "$winid"
with
desktop="$(xdotool get_desktop)"
win_desktop="$(xdotool get_desktop_for_window "$winid")"
if [[ "$desktop" == "$win_desktop" ]]
then
xdotool windowactivate "$winid"
else
xdotool set_desktop_for_window "$winid" -1
xdotool set_desktop_for_window "$winid" "$desktop" \
windowactivate "$winid"
fi
Although this assumes that you know the $winid
of the window you want
to move. If you have just the title it works just as well to use
wmctrl -R "Application Finder"