You are not logged in.
I like the Unity feature where a key binding either opens or focuses an application window. With KDE I can define a keyboard shortcut which, for example, performs
wmctrl -xa emacs.Emacs || emacsHowever, I'd like it to focus on the last focused window, not the first opened window. Is there a command to list all windows in the order they were recently used? (Clearly the Task Switcher gets this information from somewhere.)
Last edited by raul_l (2014-12-16 16:58:24)
Raul Laasner
Offline
The command I was looking for is
xprop -root | grep "^_NET_CLIENT_LIST_STACKING"If anyone is interested, this script
#!/bin/bash
app=$1
workspace=$(wmctrl -d | grep '\*' | cut -d ' ' -f1)
win_list=$(wmctrl -lx | grep $app | grep " $workspace " | awk '{print $1}')
IDs=$(xprop -root|grep "^_NET_CLIENT_LIST_STACKING" | tr "," " ")
IDs=(${IDs##*#})
for (( idx=${#IDs[@]}-1 ; idx>=0 ; idx-- )) ; do
for i in $win_list; do
if [ $((i)) = $((IDs[idx])) ]; then
wmctrl -ia $i
exit 0
fi
done
done
exit 1in conjunction with the key binding
the_above_script.sh emacs.Emacs || emacsproduces the correct Unity behavior. (How to mark this thread solved?)
EDIT: I modified the script a little bit. It turns out wmctrl and xprop use slightly different formats for displaying hexadecimal numbers.
Last edited by raul_l (2014-12-17 12:08:07)
Raul Laasner
Offline
Edit your first post to change the title.
Offline