Focus/activate window which is to the right/left/up/down?
Ralf Mardorf
ralf.mardorf at alice-dsl.net
Sun Sep 25 12:01:42 CEST 2016
On Sun, 25 Sep 2016 10:17:40 +0200, killermoehre wrote:
>Am 25.09.2016 um 08:02 schrieb Сергей Процеров (Sergey Protserov):
>> Hello everybody! I am using Xfce4 4.12.3 and I would like to be able
>> to activate a window, which is to the right/left/up/down side of
>> current window, using keybindings (like it is in tiling window
>> managers or in Openbox). Could you please tell me, how can I
>> implement it? Thank you in advance.
>
>if you want Openbox features, than use Openbox
>https://wiki.xfce.org/howto/other_window_manager
Or stay with xfwm4 and write a script using wmctrl. Sometimes xdotool
might be helpful, too.
An example, the terminal is active and I activated the Claws window:
[rocketmouse at archlinux ~]$ wmctrl -lx
0x00c00003 -1 panel.fbpanel archlinux panel
0x0080001d -1 panel.lxpanel archlinux panel
0x01600003 0 claws-mail.Claws-mail archlinux Rocketmouse - Claws Mail 3.14.0
0x01000012 0 evolution.Evolution archlinux Inbox (55388 unread) - Evolution
0x01c00003 0 main_window.Sylpheed archlinux Unknown Crewman - Sylpheed 3.5.1
0x0173153e 0 claws-mail.Claws-mail archlinux Re: Focus/activate window which is to the right/left/up/down? - Compose message [Edited]
0x01e00007 0 roxterm.Roxterm archlinux rocketmouse at archlinux:~
0x0220007f 0 Navigator.Icecat archlinux linux - How to use wmctrl to activate window of a given class? - Super User - GNU IceCat
[rocketmouse at archlinux ~]$ wmctrl -x -a claws-mail.Claws-mail
You could assign a script to a shortcut. Pushing the shortcut a script
could activate one window after the other, e.g. using a
"for"-loop getting the windows from a list. The list likely could be
provided by $(wmctrl -lx | cut -d" " -f4 | grep -v '^$') , but you
should test, if this always works. If you want it more advanced, the
script needs to check the position of the active window and those of
the windows surrounding the active window. This is what you want and
it's possible to do this, too.
Off-topic:
An example how I use wmctrl:
If I push Ctrl+7 my WM (openbox without a desktop environment) runs
win75 and if I push Ctrl+Alt+7 it runs win75 - , win75 is the
following script, that resize the active window:
[rocketmouse at archlinux ~]$ cat /usr/local/bin/win75
#!/bin/bash
eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
X_FIX=$(grep X_FIX ~/.rocketmouse/win75/config | cut -d"=" -f2)
Y_FIX=$(grep Y_FIX ~/.rocketmouse/win75/config | cut -d"=" -f2)
((XX=X-X_FIX))
((YY=Y-Y_FIX))
WIDTH=$(calc "int($WIDTH*0.75)")
case $1 in
"") HEIGHT=$(calc "int($HEIGHT*0.75)");;
esac
echo "x:$X-$X_FIX=$XX/y:$Y-$Y_FIX=$YY"
wmctrl -i -r $WINDOW -b remove,maximized_vert,maximized_horz
wmctrl -i -r $WINDOW -e "0,$XX,$YY,$WIDTH,$HEIGHT"
eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
echo "x:$X-$X_FIX=$XX/y:$Y-$Y_FIX=$YY"
exit
To avoid that the resized windows are moving, a config is required,
providing an offset that can be found by trial and error:
[rocketmouse at archlinux ~]$ cat ~/.rocketmouse/win75/config
X_FIX=4
Y_FIX=50
Regards,
Ralf
More information about the Xfce
mailing list