Skip to content

Commit 180b11b

Browse files
author
Alberto Milone
committed
Add support for the DisplayStopCommand entry
This entry allows executing a script right after stopping X
1 parent 4d50323 commit 180b11b

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

data/man/sddm.conf.rst.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ OPTIONS
8585
Path of script to execute when starting the display server.
8686
Default value is "@DATA_INSTALL_DIR@/scripts/Xsetup".
8787

88+
`DisplayStopCommand=`
89+
Path of script to execute when stopping the display server.
90+
Default value is "@DATA_INSTALL_DIR@/scripts/Xsetup".
91+
8892
`MinimumVT=`
8993
Minimum virtual terminal number that will be used
9094
by the first display. Virtual terminal number will

data/scripts/Xstop

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
# Xstop - run as root after stopping X

src/common/Configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ namespace SDDM {
6161
"A script to execute when starting the desktop session"));
6262
Entry(DisplayCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xsetup"), _S("Xsetup script path\n"
6363
"A script to execute when starting the display server"));
64+
Entry(DisplayStopCommand, QString, _S(DATA_INSTALL_DIR "/scripts/Xstop"), _S("Xstop script path\n"
65+
"A script to execute when stopping the display server"));
6466
Entry(MinimumVT, int, MINIMUM_VT, _S("Minimum VT\n"
6567
"The lowest virtual terminal number that will be used."));
6668
);

src/daemon/XorgDisplayServer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,23 @@ namespace SDDM {
233233
// log message
234234
qDebug() << "Display server stopped.";
235235

236+
QString displayStopCommand = mainConfig.XDisplay.DisplayStopCommand.get();
237+
238+
// create display setup script process
239+
QProcess *displayStopScript = new QProcess();
240+
241+
// set process environment
242+
QProcessEnvironment env;
243+
env.insert("DISPLAY", m_display);
244+
env.insert("HOME", "/");
245+
env.insert("PATH", mainConfig.Users.DefaultPath.get());
246+
env.insert("SHELL", "/bin/sh");
247+
displayStopScript->setProcessEnvironment(env);
248+
249+
// start display setup script
250+
qDebug() << "Running display stop script " << displayStopCommand;
251+
displayStopScript->start(displayStopCommand);
252+
236253
// clean up
237254
process->deleteLater();
238255
process = nullptr;

0 commit comments

Comments
 (0)