%
% anyremote configuration file for wmctrl - http://www.sweb.cz/tripie/utils/wmctrl/ (Server-mode)
%

% STATUS stable
% XTEST no
% SOUND no
% ENV no

GuiAppName=WmCtrl
GuiAppType=Application
GuiAppBinary=true
GuiAppDesc=The wmctrl program is a UNIX/Linux command line tool to interact with an EWMH/NetWM compatible X Window Manager.
GuiAppProtocols=Server

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Exec(P=`which wmctrl|grep wmctrl|grep -v no|grep -v edit|grep -v anyremote|wc -l|tr -d " "`;if [ "x$P" == "x0" ]; then $(CfgDir)/Utils/message.sh "ERROR: wmctrl is not installed"; fi);

(Connect)=\
	Set(parameter,debug,on);\
        Set(title,WmCtrl);\
	Set(list,replace,WmCtrl,---);\
	Macro(WMCTRL_MENU);

Cancel=Exit

GET_WIN_ID=Make(var,winid,echo $(Param)|cut -d " " -f 1);
WMCTRL_MENU=Set(menu,replace,Desktops,Windows,Disconnect);

* *=Set(text,replace,Help,Use menu to choose window or desktop operations);
Back=Set(text,close);\
	Set(list,clear);\
	Macro(WMCTRL_MENU);

Push($$)=Macro(Desktops($$));

Desktops($$)=ExecAndSet(list,replace,Desktops,wmctrl -d|tr -s " "|cut -d ":" -f 1,4|cut -d " " -f 1,6,7|sed 's/$/,/');\
	Set(menu,replace,Show);
	
Windows($$)=ExecAndSet(list,replace,Windows,wmctrl -l|sed 's/$/,/');\
	Set(menu,replace,Activate,Fullscreen,Above,Below,Close);
	
Show($$)=Make(var,switchto,echo $(Param)|cut -d " " -f 1);\
	Exec(wmctrl -s $(switchto));
	
Activate($$)=Macro(GET_WIN_ID);\
	Exec(wmctrl -i -a $(winid));
	
Fullscreen($$)=Macro(GET_WIN_ID);\
	Exec(wmctrl -i -r $(winid) -b toggle,fullscreen);
	
Above($$)=Macro(GET_WIN_ID);\
	Exec(wmctrl -i -r $(winid) -b toggle,above);

Below($$)=Macro(GET_WIN_ID);\
	Exec(wmctrl -i -r $(winid) -b toggle,below);

Close($$)=Macro(GET_WIN_ID);\
	Exec(wmctrl -i -c $(winid));
	
Back($$)=Set(list,replace,WmCtrl,---);\
	Macro(WMCTRL_MENU);
	
Disconnect($$)=Set(disconnect);

[End]

