"sddm" ignores "HaltCommand"

Hi Forum,

to perform some backup on system shutdown (not on system reboot), I want to change the command which is executed if the user powers off the system by selecting “shutdown”. So I changed the “HaltCommand” to:

HaltCommand=/bin/systemctl isolate hts-backup-poweroff.service

Entering the command manually works perfectly, however it seems that “HaltCommand” is ignored, regardless whether I put in in a file in “/etc/sddm.conf.d” (KDE writes it correctly into “kde_settings.conf”) or whether I create a “/etc/sddm.conf”.

The sddm version is 0.18.1 on my Leap 15.1, as 15.2 does not provide a newer one, I for now refrained from testing on 15.2.

Did I oversee something :?

Greetings, The Wumpus.

Does this command work when you run it manually?

Usually, ‘/bin/systemctl’ is a symbolic link to ‘/usr/bin/systemctl’ …

  • It may well be that, SDDM is picky and, the “/usr/bin/” path has to be used if the default value is not to be used – the man page states:

              Halt command.  Default value is "**/usr/bin/**systemctl poweroff".

Yes, it does. Stops any not required service, performs backup (using rsnapshot), powers off.

Thank you very much for this hint. However, it made no difference. I tried both the kde-settings.conf in /etc/sddm.conf.d, as well as a manually created /etc/sddm.conf.


Is the content of the unit files associated with the unit “hts-backup-poweroff.service” similar to the content of the following files associated with systemd units?

  • /usr/lib/systemd/system/poweroff.target
  • /usr/lib/systemd/system/systemd-poweroff.service

The “poweroff” service contains “/usr/bin/systemctl --force poweroff” – I suspect that, “–force” is there for a good reason …

I’m also a little bit suspicious of the association of “.target” with the systemctl command “isolate” …

Hello dcurtisfra,

I am also not fully convinced that my “systemd” implementation of backup + poweroff is the most optimal variant, however I verified it and it works w/o issues if I call it manually. The “hts-backup-poweroff.service” service itself starts “hts-backup.service”, and once this is finished it executes “/usr/bin/systemctl poweroff” like specified as default value.

What I forgot to mention is that the system behaves normally as if no custom “HaltCommand” is provided, that is it performs a shutdown with final power off. I therefore assume that the ignoring has nothing to do with my service, but it’s rather a sddm issue.

Regards, The Wumpus

As a test, I replaced my custom HaltCommand with “/usr/bin/systemctl reboot”, which is the default for RebootCommand. Again, the machine performed a power-off instead the expected reboot, so anything I write to “HaltCommand” is just ignored.

Any Ideas :\ ?

Am curious what you are trying to accomplish with a custom halt command embedded in your DM as opposed to the default command (which you verified works manually).



Well, the idea is that if the machine is powered off (by the user selecting “shut down” from the desktop, or from the DM), some backup shall be performed before the real power-off. However, I do not want to change the original systemd power-off services etc., instead I created my own systemd services and scripts which work if started manually via shell.
The only thing what is missing now is to call these own services instead of the original ones when the user issues a shut down via the DM. That should be possible by providing a custom “HaltCommand”, however it seems that anything I put in there is ignored.

Regards, the_wumpus

Why not simply create service that performs needed actions as ExecStop command during shutdown?

At which service to put the ExecStop ? I wanted the following things to be considered: a) Unneeded services (webserver, database server, all users, …) should have stopped before the backup is started, b) do not change original files if possible to avoid problems if files are overwritten by update, c) do not change the original behavior of “systemctl shutdown”. All this is pretty good accomplished by creating a set of own services. This works and is not the real problem.

The only, remaining problem is that sddm unfortunately refuses to use customized halt (power-off) commands as proposed…

Regards, the_wumpus

Meaning that, the Simple Desktop Display Manager is maybe a little too simple and therefore, some code reading is needed …

  • I had a suspicion that, within the “[General] section” and specifically the “HaltCommand=” option, SDDM accepts only one parameter to the “systemctl” command but, your test showed that this is not the case – all “systemctl” parameters are ignored …
  • Even worse, the “HaltCommand=” option itself may well be being ignored by SDDM …
  • The /sbin/ commands “halt” and “reboot” are symbolic links to “/usr/bin/systemctl” – what happens if the “HaltCommand=” option simply calls the command “reboot” (without a path … )?

Well, simple in my opinion should never mean that features described in the documentation are just ignored without any note. But, being used to aerospace engineering, I might have been just too optimistic:sarcastic:. So, what I got from this discussion, is that I did not oversee something concerning sddm configuration (I had also replaced “/bin” by “/usr/bin”), but that somehow sddm is maybe a bit “unfinished”. Let’s see if I find some time checking the code… sigh.

Regards, the_wumpus

Base only on a quick Google search on SDDM options and reading the SDDM ArchWiki,
It seems that Display Managers support different options, they aren’t nearly the same in what they do and how they can be customized.

For instance although it might show up somewhere in the MAN pages and elsewhere (I didn’t check), the commands you are trying to enable aren’t mentioned so can be assumed are not supported.

In any case, I’m not envisioning why you should need a custom Halt command (or alias for that matter… Is that an option for you?)
I’m envisioning you can script anything you want to happen during a customized shutdown, giving the master script a unique name and then your User can invoke it instead of the normal shutdown.


Your own service that you create.

I suspect that, “simple” for the case of SDDM means “simplistic” – a little bit too much simplification …

  • Possibly a little bit too much Qt and not enough UML or SDL State Machines … >:)

Yeap, it’s full of QT stuff.
Besides that, a first code review and additional internet research revealed that sddm supports different “power managers” via backends, and for some of them it simple redirects the shutdown command to that power manager, thereby happily ignoring any custom halt configuration. Of course it is not possible to configure which backend to use. IMHO this feature / behavior should have been documented … need more time to investigate, maybe I have to configure the power manager and not sddm…

I still do not understand your wish to create a custom poweroff command.
To me, a “poweroff” is simple, and clearly defined… A particular action that is uncomplicated.

Why do you insist in a complex poweroff?
A typical modular approach to programming easily suggests that any modifications should be kept separate, and would be executed prior to a standard poweroff.

Are you restricting yourself by method of invoking a shutdown/poweroff?
Are working with some other kind of restriction that requires that the shutdown/poweroff command be invoked by the DM?


Seems I was not able to explain it correctly, sorry. I am implementing some backup solution, which fulfills the following requirements:

  • The backup shall be performed if the computer is going to be powered off. Its not a server, it’s a desktop which usually gets powered off at the end of the day or whenever the job is finished.
  • By doing the backup just before power off, after each user is logged out and major services (such as database server etc.) have stopped, I avoid the problem with files being modified during backup. Only the minimum required services are running during backup (network, sshd, local mounts).
  • I what it to be seamlessly integrated into the standard way the computer is operated, that means the user selects power down from the desktop or the display manager, and that’s it. I don’t want the user to have to call a special command before selecting power off; besides that in this case it would be difficult to stop non required services as the user of course is not logged in as root (ok, could use suid, but that’s not the point here).
  • I, however, do not want
    the original systemd shutdown or power off services or any script to be altered, to avoid any problems by updates overwriting the altered files. - Finally, it would be nice not to have the original behavior of shutdown power off being altered, again to avoid possible conflicts.

… and after all, this was not really hard to implement. It is based on rsnapshot plus some custom systemd services, no altering of “original” services was required. And all to have it seamlessly integrated into the “standard way” is to change the command sddm performs if a shutdown is selected by the user - pretty easy and straight forward, well, *at least it should have been like this…

*Hopefully I now explained it correctly. If not, it may be better to contact me via private message, as I have the feeling this is going off-topic meanwhile because the original request was just about why sddm ignores custom halt commands. Any that seems to be getting clear now as I realized that the shutdown command may be just forwarded to some external power manager instead calling the default or custom shutdown command.

Regards, the_wumpus