Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-04-04 13:59:56

emil2007
Member
Registered: 2017-03-29
Posts: 20

Remapping Alt+Tab?

I want to remap Alt+Tab this way:

Pressing the back quote key ( ` ) once, popup the switching pane with the last used window selected. Pressing the back quote key again switches to the last used window. Also, before pressing the back quote key second time to be able to go through the list with the Tab key.

Is this possible? I can do this in Windows with the program TaskSwitchXP but for linux i can't find a program that can do this.

Offline

#2 2017-11-10 19:51:35

Misko_2083
Member
Registered: 2015-10-13
Posts: 211
Website

Re: Remapping Alt+Tab?

Don't know if this can be done the way you want. I've made a small script than launches a jgmenu with the window list.
If a menu item is clicked it will focus that window. It works with openbox but also xfce because of the freedesktop standards.
I've set up the keyboard shortcut to launch the script.
Screenshot---11012017---061045-PM.th.png
Number between the icon and the window title, is the number of display or workspace in xfce.
Script:

#!/bin/bash

#Check dependancies
DEPCOUNT=0
for DEP in /usr/bin/{xdotool,xprop,wmctrl,convert,awk,perl} /bin/{grep,echo}; {
	[ -x "$DEP" ] || {
		echo "$LINENO" "Dependency '$DEP' not met."
		DEPCOUNT+=1
	}
}

[ $DEPCOUNT -gt 0 ] && exit 1

TMPDIR=$(mktemp -d /tmp/XXXXXX)
trap "rm -rf $TMPDIR" EXIT

# With process substitution output from "wmctrl -l" is redirected to file descriptor 3
# while loop reads  "win_id" and "display" variables from file descriptor 3
while read -r win_id display text <&3
	do

	# filter windows with win_id that has X window properties of type normal or dialog
	if xprop -id $win_id | grep -e "^_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL" \
                                    -e "^_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG" &>/dev/null
		then
		# Get WM_CLASS X window property
		wm_class=$(xprop -id $win_id WM_CLASS | awk -F'"' '{print $4}')

		if  hash convert &>/dev/null;then
			# Convert icon to pam then use imagemagic to convert to png
			xprop -notype 32c -id $win_id _NET_WM_ICON \
			|    perl -0777 -pe '@_=/\d+/g;
				printf "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE RGB_ALPHA\nENDHDR\n", splice@_,0,2;
				$_=pack "N*", @_;
				s/(.)(...)/$2$1/gs' \
			| convert pam:- $TMPDIR/$wm_class.png 2>/dev/null
		fi

		# if WM_CLASS is a "Wrapper"
		if [[ "${wm_class}" == "Wrapper" ]]
		then
			# Get WM_CLASS X window property _NET_WM_NAME
			wm_class=$(xprop -id $win_id _NET_WM_NAME | awk -F '"' '{print $2}')

			echo "\"\"\"$display $text\"\"\",xdotool windowactivate $win_id,xfwm4"
		else
			# print
			echo "\"\"\"$display $text\"\"\",xdotool windowactivate $win_id,$TMPDIR/$wm_class.png"
		fi
	fi
done 3< <(wmctrl -l | awk '{print $1,$2,substr($0, index($0,$4), 30)}') | jgmenu --simple --at-pointer

# Close file descriptor 3
exec 3<&-

exit

The script requires:
wmctrl, xdotool, xprop
jgmenu https://github.com/johanmalm/jgmenu/
imagemagick

Why is imagemagick a dependancy?
   - From the Xindow property _NET_WM_ICON the raw icon data is converted to pam image format and then piped to convert (imagemagick).

xprop -notype 32c -id $win_id _NET_WM_ICON \
                  |    perl -0777 -pe '@_=/\d+/g;
                       printf "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE RGB_ALPHA\nENDHDR\n", splice@_,0,2;
                       $_=pack "N*", @_;
                       s/(.)(...)/$2$1/gs' \
                  | convert pam:- $TMPDIR/$wm_class.png

Window list can be displayed with zenity --list or yad --list dialogs, floating menu near mouse pointer was more convenient for me.


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.006 seconds, 7 queries executed - Memory usage: 525.06 KiB (Peak: 529.87 KiB) ]