Screen change script argument

This commit is contained in:
Szymon Szeląg 2019-02-05 19:44:14 +01:00
parent 41f5ef2e09
commit 24b3ee547c
5 changed files with 63 additions and 34 deletions

5
.gitignore vendored
View File

@ -20,3 +20,8 @@ src/gui/gui.pro.user*
src/gui/.qmake.stash src/gui/.qmake.stash
src/gui/.rnd src/gui/.rnd
src/setup/win32/barrier.suo src/setup/win32/barrier.suo
Makefile
*.cmake
**/CMakeFiles/
CMakeCache.txt
/rpm

View File

@ -61,6 +61,10 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
// save configuration file path // save configuration file path
args.m_configFile = argv[++i]; 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 { else {
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str())); LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str()));
return false; return false;

View File

@ -117,7 +117,10 @@ ServerApp::help()
" [--display <display>] [--no-xinitthreads]" " [--display <display>] [--no-xinitthreads]"
# define WINAPI_INFO \ # define WINAPI_INFO \
" --display <display> connect to the X server at <display>\n" \ " --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" \
" path to script to run on screen change\n" \
" first argument is screen name\n"
#else #else
# define WINAPI_ARGS "" # define WINAPI_ARGS ""
# define WINAPI_INFO "" # define WINAPI_INFO ""
@ -679,6 +682,21 @@ ServerApp::handleNoClients(const Event&, void*)
void void
ServerApp::handleScreenSwitched(const Event& e, 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));
std::string cmd = std::string(args().m_screenChangeScript);
cmd += " ";
cmd += info->m_screen;
cmd += " &";
system(cmd.c_str());
}
#endif
} }
int int

View File

@ -19,7 +19,8 @@
ServerArgs::ServerArgs() : ServerArgs::ServerArgs() :
m_configFile(), m_configFile(),
m_config(NULL) m_config(NULL),
m_screenChangeScript()
{ {
} }

View File

@ -29,4 +29,5 @@ public:
public: public:
String m_configFile; String m_configFile;
Config* m_config; Config* m_config;
String m_screenChangeScript;
}; };