Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Move a window to a specific workspace?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Banana
Veteran
Veteran


Joined: 21 May 2004
Posts: 1392
Location: Germany

PostPosted: Mon Jan 23, 2023 9:03 am    Post subject: Move a window to a specific workspace? Reply with quote

I'm using XFCE and there a some keyboard shortcuts to move windows or switch to a workspace.

Is there either plugin or a script which could do the following:
Currently selected window (focus) moved to another workspace or even move a window to the current workspace from another one.
_________________
My personal space
My delta-labs.org snippets do expire

PFL - Portage file list - find which package a file or command belongs to.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2719

PostPosted: Mon Jan 23, 2023 9:43 am    Post subject: Reply with quote

x11-misc/xdotool can handle most things like that in a generic manner, e.g.
Code:
xdotool getactivewindow set_desktop_for_window 2 # move active window to workspace 2
xdotool set_desktop 2 # go to workspace 2
xfwm4 is fairly standard compliant so generic X tools like xdotool do what you'd expect and you don't need some special "control xfce" tool.

Can also be used to search window and perform operations based on window id regardless of where they are, may need a bit of getting used to (check the man page).

Edit: tools like devilspie2 may be of interest too, can be used to automatically run similar tasks when windows are created, like to always have a window appear on a specific workspace when opened (some DE already support this themselves, but this is a generic tool).
Back to top
View user's profile Send private message
Banana
Veteran
Veteran


Joined: 21 May 2004
Posts: 1392
Location: Germany

PostPosted: Mon Jan 23, 2023 12:00 pm    Post subject: Reply with quote

Thx for the tools. Looks promisingly!

Did a re-check in xfce4 window manager settings and there are actions to bind which can move a window to a workspace. Must have overlooked them.
Well, it will be a get-a-window-from script then.

Edit:
I've assembled something (Not very error proof)
Code:
#!/usr/bin/env -S bash -e
if [ -z "$1" ]
  then
    echo "Missing string to search for"
   exit 1;
fi

WINDOWNAME_TO_SEARCH=$1
CURRENT_WORKSPACE=$(xdotool get_desktop)

HEX_ID=$(wmctrl -lx | grep -i ${WINDOWNAME_TO_SEARCH} | awk '{print $1}')
WINDOW_ID=$(printf "%d" ${HEX_ID})

# remember if it was maximized
WINDOW_STAGE=$(xprop -id ${WINDOW_ID=} _NET_WM_STATE | awk '{ print $3 }')

# Un-maximize current window so that it can be moved
wmctrl -ir ${WINDOW_ID=} -b remove,maximized_vert,maximized_horz

xdotool set_desktop_for_window ${WINDOW_ID} ${CURRENT_WORKSPACE} && xdotool windowactivate ${WINDOW_ID}

# Maximize if it was before the move
if [ "${WINDOW_STAGE=}" = "_NET_WM_STATE_MAXIMIZED_HORZ," ]; then
    wmctrl -ir ${WINDOW_ID=} -b add,maximized_vert,maximized_horz
fi


any updates can be found here: http://91.132.146.200:3000/Banana/klimbim/src/master/bash/move-window-to-current-workspace.sh
_________________
My personal space
My delta-labs.org snippets do expire

PFL - Portage file list - find which package a file or command belongs to.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum