You are not logged in.

#1 2014-05-17 13:09:56

andreas1724
Member
Registered: 2014-01-03
Posts: 7

[SOLVED] XFCE4 shortcut "Switch window same application" not working

I am running archlinux 64bit with xfce4 and its native window manager xfwm4. The default shortcut to switch between windows for the same application is <Super>-Tab. The shortcut works for some applications, but unfortunately not for all. The shortcut doesn't work for evince, xterm, gnome-calculator, abiword, ... I don't want to change the window manager. Maybe, the best solution could be a script, to change between windows for the same application. Does anybody know a command or script to do this?

Last edited by andreas1724 (2014-05-17 18:22:48)

Offline

#2 2014-05-17 16:15:44

andreas1724
Member
Registered: 2014-01-03
Posts: 7

Re: [SOLVED] XFCE4 shortcut "Switch window same application" not working

This seems to work for me:

#!/bin/bash

# get id of the focused window
active_win_id=$(xprop -root '_NET_ACTIVE_WINDOW' | awk -F '# 0x' '{print $2}' | awk -F '[^0-9a-fA-F]' '{print $1}')
if [ "$active_win_id" = "0" ]; then
    active_win_id=""
fi

current_desktop=$(xprop -root '_NET_CURRENT_DESKTOP' | awk '{print $3}')

# get window manager class of current window
win_class=$(wmctrl -x -l | grep $active_win_id | awk '{print $3}' )

# get list of all windows matching with the class above
win_list=$(wmctrl -x -l | grep -P "^[^\s]+\s+$current_desktop\s" | grep $win_class | awk '{print $1}')

# get next window to focus on
switch_to=$(echo $win_list | sed s/.*$active_win_id// | awk '{print $1}')

# if the current window is the last in the list ... take the first one
if [ "$switch_to" = '' ];then
    switch_to=$(echo $win_list | awk '{print $1}')
fi

# switch to window
wmctrl -i -a $switch_to

I got it from http://lars.st0ne.at/blog/switch%20betw … pplication
For getting the id of the focused window, I add the awk -F '[^0-9a-fA-F]' '{print $1}' to erase the stuff after the hexadecimal windows-id. Otherwise the script fails in my case. The other thing I changed is, that the script only switches between windows of the same workspace.

Last edited by andreas1724 (2014-05-17 20:59:15)

Offline

Board footer

Powered by FluxBB