%
% anyremote configuration file for kmplayer management. (Server-mode)
% prerequisites: kmplayer, amixer/pactl utility
% 
%

% STATUS stable
% XTEST no
% SOUND mixer
% ENV no
% FBROWSER v.3i
% DEF_VIDEO_PLAYER   
% ALL_IN_ONE 

GuiAppName=Kmplayer
GuiAppBinary=kmplayer
GuiAppRun=echo 'A=`qdbus 2> /dev/null|grep kmplayer`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi'|sh -s
GuiAppIcon=kmplayer.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Media Player for KDE

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Include($(CfgDir)/Utils/aliases-server-fbrowser-v3i.cfg);\
	Include($(CfgDir)/Utils/aliases-server-video-player.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,kde4_app,by_value,kmplayer);\
	Macro(TEST_KDE4_APP);\
	Make(var,app_name,by_value,KMplayer);\
	Make(var,open_file,by_value,);\
	Make(var,app_manage_mode,by_value,kmplayer);

(Connect)=\
	Make(mode,kmplayer_init);

[Mode]=kmplayer_init : default_video_player_init

APP_IS_RUN=\
	Make(var,app_run,A=`qdbus 2> /dev/null|grep kmplayer`; if [ "x$A" = "x" ]; then echo 0; else echo 1; fi);

[ModeEnd]

[Mode]=kmplayer : default_video_player

% (EnterMode) by Utils/aliases-server-video-player.cfg

APP_START_IF=\
	Set(title,$(open_file));\
	Exec(P=`qdbus|grep kmplayer`; if [ "x$P" = "x" ]; then cd "`cat $HOME/.anyRemote/ar_storedir.tmp`"; kmplayer $(open_file) 2> /dev/null & fi);

% Application window should be present in output of "wmctrl -l"
APP_RAISE=\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch kmplayer);

APP_QUIT=\
	Exec(qdbus `qdbus|grep kmplayer` /MainApplication org.kde.KApplication.quit);

APP_FULLSCREEN=\
	Exec(qdbus `qdbus|grep kmplayer` /kmplayer/MainWindow_1 org.kde.KMainWindow.activateAction view_fullscreen > /dev/null);

PLAY=\
	Exec(qdbus `qdbus|grep kmplayer` /kmplayer/MainWindow_1 org.kde.KMainWindow.activateAction play > /dev/null);

RWD=\
	Exec(KMP=`qdbus|grep kmplayer`;POS=`qdbus $KMP /KMPlayerPart org.freedesktop.DBus.Properties.Get org.kde.KMediaPlayer position`;NEWPOS=`expr $POS - 10000`;qdbus $KMP /KMPlayerPart org.kde.KMediaPlayer.seek $NEWPOS > /dev/null);

FF=\
	Exec(KMP=`qdbus|grep kmplayer`;POS=`qdbus $KMP /KMPlayerPart org.freedesktop.DBus.Properties.Get org.kde.KMediaPlayer position`;NEWPOS=`expr $POS + 10000`;qdbus $KMP /KMPlayerPart org.kde.KMediaPlayer.seek $NEWPOS > /dev/null);

STOP=\
	Exec(qdbus `qdbus|grep kmplayer` /kmplayer/MainWindow_1 org.kde.KMainWindow.activateAction stop > /dev/null);

PAUSE=\
	Exec(qdbus `qdbus|grep kmplayer` /kmplayer/MainWindow_1 org.kde.KMainWindow.activateAction pause > /dev/null);

[ModeEnd]

[End]
