Merge pull request #249 from vorph1/screen-change-script
Screen change script argument
This commit is contained in:
commit
fac5610b44
|
@ -20,3 +20,8 @@ src/gui/gui.pro.user*
|
|||
src/gui/.qmake.stash
|
||||
src/gui/.rnd
|
||||
src/setup/win32/barrier.suo
|
||||
Makefile
|
||||
*.cmake
|
||||
**/CMakeFiles/
|
||||
CMakeCache.txt
|
||||
/rpm
|
||||
|
|
|
@ -61,6 +61,10 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
|
|||
// save configuration file path
|
||||
args.m_configFile = argv[++i];
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--screen-change-script", 1)) {
|
||||
// save screen change script path
|
||||
args.m_screenChangeScript = argv[++i];
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str()));
|
||||
return false;
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#if WINAPI_MSWINDOWS
|
||||
#include "platform/MSWindowsScreen.h"
|
||||
#elif WINAPI_XWINDOWS
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "platform/XWindowsScreen.h"
|
||||
#elif WINAPI_CARBON
|
||||
#include "platform/OSXScreen.h"
|
||||
|
@ -117,7 +119,10 @@ ServerApp::help()
|
|||
" [--display <display>] [--no-xinitthreads]"
|
||||
# define WINAPI_INFO \
|
||||
" --display <display> connect to the X server at <display>\n" \
|
||||
" --no-xinitthreads do not call XInitThreads()\n"
|
||||
" --no-xinitthreads do not call XInitThreads()\n" \
|
||||
" --screen-change-script <path>\n" \
|
||||
" full path to script to run on screen change\n" \
|
||||
" first argument is the new screen name\n"
|
||||
#else
|
||||
# define WINAPI_ARGS ""
|
||||
# define WINAPI_INFO ""
|
||||
|
@ -679,6 +684,28 @@ ServerApp::handleNoClients(const Event&, void*)
|
|||
void
|
||||
ServerApp::handleScreenSwitched(const Event& e, void*)
|
||||
{
|
||||
Server::SwitchToScreenInfo* info = (Server::SwitchToScreenInfo*)(e.getData());
|
||||
|
||||
#ifdef WINAPI_XWINDOWS
|
||||
if (!args().m_screenChangeScript.empty()) {
|
||||
LOG((CLOG_INFO "Running shell script for screen \"%s\"", info->m_screen));
|
||||
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
|
||||
if (!access(args().m_screenChangeScript.c_str(), X_OK)) {
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
execl(args().m_screenChangeScript.c_str(),args().m_screenChangeScript.c_str(),info->m_screen,NULL);
|
||||
exit(0);
|
||||
} else if (pid < 0) {
|
||||
LOG((CLOG_ERR "Script forking error"));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
LOG((CLOG_ERR "Script not accessible \"%s\"", args().m_screenChangeScript.c_str()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
ServerArgs::ServerArgs() :
|
||||
m_configFile(),
|
||||
m_config(NULL)
|
||||
m_config(NULL),
|
||||
m_screenChangeScript()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -29,4 +29,5 @@ public:
|
|||
public:
|
||||
String m_configFile;
|
||||
Config* m_config;
|
||||
String m_screenChangeScript;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue