%
% anyremote configuration file for okular (http://okular.kde.org) management (Server-mode)
%

% STATUS stable
% XTEST yes
% SOUND no
% ENV no
% FBROWSER v.4i
% IPC DBUS
% DEF_PRESENTATION   
% ALL_IN_ONE
% MEDIACENTER presentation

GuiAppName=Okular
GuiAppBinary=okular
GuiAppRun=U=`id -u`;A=`pgrep -l -u $U okular`; if [ "x$A" = "x" ]; then echo NOK; else echo OK; fi
GuiAppIcon=okular.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Okular is a universal document viewer for KDE4

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Include($(CfgDir)/Utils/aliases-server-fbrowser-v4i.cfg);\
	Macro(FBROWSER_IC_INIT);\
	Include($(CfgDir)/Utils/aliases-server-presentation.cfg);\
	Make(var,open_file,by_value,);\
	Make(var,app_name,by_value,Okular);\
	Make(var,app_manage_mode,by_value,okular_manage);

(Exit)=\
	Macro(FBROWSER_IC_EXIT);

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

[Mode]=okular : default_presentation_init

APP_IS_RUN=\
	Make(var,app_run,pgrep -u `id -u` okular|head -1|wc -l);

[ModeEnd]

[Mode]=okular_manage : default_presentation

GETPID=Make(var,okular_pid,pgrep -u `id -u` okular);

APP_SETUP=\
	Make(var,okular_fs,by_value,showFullScreen);

APP_START_IF=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" = "x" ]; then cd "$(fbrowser_dir)";okular $(open_file)& fi 2> /dev/null);

APP_RAISE=\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch okular);

APP_QUIT=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /MainApplication org.kde.KApplication.quit; fi);\
	Set(title, );
	
PRES_START=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /okular org.kde.okular.slotTogglePresentation; fi);

PRES_PREV_PAGE=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /okular org.kde.okular.slotPreviousPage; fi);

PRES_NEXT_PAGE=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /okular org.kde.okular.slotNextPage; fi);

PRES_ZOOM_IN=\
	Emulate(keydown,Control_L,key,plus,keyup,Control_L)
	
PRES_ZOOM_OUT=\
	Emulate(keydown,Control_L,key,minus,keyup,Control_L)

PRES_FIRST_PAGE=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /okular org.kde.okular.slotGotoFirst; fi);

PRES_LAST_PAGE=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then dbus-send --type=method_call --dest=org.kde.okular-$(okular_pid) /okular org.kde.okular.slotGotoLast; fi);

PRES_TOGGLE_FULLSCREEN=\
	Macro(GETPID);\
	Exec(if [ "x$(okular_pid)" != "x" ]; then qdbus org.kde.okular-$(okular_pid) /okular/okular__Shell com.trolltech.Qt.QWidget.$(okular_fs); fi);\
	Make(var,okular_fs,if [ "x$(okular_fs)" = "xshowFullScreen" ]; then echo showNormal; else echo showFullScreen; fi);

PRES_REFRESH=\
	Macro(GETPID);\
	Exec(qdbus org.kde.okular-$(okular_pid) /okular/okular__Shell com.trolltech.Qt.QWidget.repaint);

[ModeEnd]

[End]
