Skip to content

Commit

Permalink
Add support for running X setup commands at slim startup
Browse files Browse the repository at this point in the history
This patch adds support similar to that which can be achieved
in other DM's (such as XDM) by customizing or editing their
Xsetup scripts.  This was added in particular to support
nvidia-drivers based Optimus setups, which need to execute
two xrandr commands in order for Xorg to render on-screen
correctly.  Usage is simple: write a script with the needed
commands, ensure it is executable, and set the xsetup_script
option in slim.conf to the full path of this script.
  • Loading branch information
axs-gentoo committed Sep 28, 2015
1 parent dce02ef commit e58c19a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ void App::Run() {

CreateServerAuth();
StartServer();


// Run setup script
if (cfg->getOption("xsetup_script") != "") {
const char* xsetup_cmd = cfg->getOption("xsetup_script").c_str();
logStream << APPNAME << ": executing xsetup script '" << xsetup_cmd << "'" << endl;
char *tmp = new char[strlen(xsetup_cmd) + 60];
sprintf(tmp, xsetup_cmd);
system(tmp);
delete [] tmp;
logStream << APPNAME << ": xsetup script '" << xsetup_cmd << "' finished." << endl;
}

#endif

}
Expand Down
1 change: 1 addition & 0 deletions cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Cfg::Cfg()
options.insert(option("suspend_cmd",""));
options.insert(option("sessionstart_cmd",""));
options.insert(option("sessionstop_cmd",""));
options.insert(option("xsetup_script",""));
options.insert(option("console_cmd","/usr/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
options.insert(option("screenshot_cmd","import -window root /slim.png"));
options.insert(option("welcome_msg","Welcome to %host"));
Expand Down
5 changes: 5 additions & 0 deletions slim.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ xauth_path /usr/bin/xauth
# Xauth file for server
authfile /var/run/slim.auth

# Optional script for X setup - to run commands after
# X starts but before the panels draw. This provides
# the ability to add custom commands, the same as one
# would by modifying the Xsetup_0 script in XDM.
#xsetup_script /etc/X11/Xsetup_0.sh

# Activate numlock when slim starts. Valid values: on|off
# numlock on
Expand Down

0 comments on commit e58c19a

Please sign in to comment.