Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: "sddm" ignores "HaltCommand"

  1. #21
    Join Date
    Oct 2008
    Location
    Germany, Bremen
    Posts
    59

    Default Re: "sddm" ignores "HaltCommand"

    Quote Originally Posted by the_wumpus View Post
    ... need more time to investigate, maybe I have to configure the power manager and not sddm...
    Well, as OpenSUSE is systemd-based, sddm just forwards the poweroff command to logind. And yet I have not seen any possibility to provide a custom power off or shutdown command to logind ...
    .. seems I finally have to alter the global poweroff target, which I originally wanted to avoid. But changing sddm to not use logind it a custom HaltCommand is provided does not seem to be a good solution as well.
    Not good at all .

  2. #22
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    13,285
    Blog Entries
    2

    Default Re: "sddm" ignores "HaltCommand"

    Quote Originally Posted by the_wumpus View Post
    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
    OK.
    Then replace your shutdown command instead of modifying it... either the binary or the systemd Unit file(using correct procedure by creating a copy of the Unit file in /etc/systemd/system/ and do not modify the original Unit file), however you're shutting down.

    Note that there are many ways to invoke a shutdown and there are a variety of shutdown, poweroff, etc methods that can be invoked either through your Desktop or not.

    Should be that simple.
    Swap out the command executable whether it's a binary, configuration, script or whatever.
    Your replacement should execute whatever you want and in the end will have to end with a default poweroff, shutdown or whatever, possibly renamed or relocated so it's not invoked first in the sequence of your custom shutdown..

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #23
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    3,962

    Talking Re: "sddm" ignores "HaltCommand"

    Quote Originally Posted by the_wumpus View Post
    And yet I have not seen any possibility to provide a custom power off or shutdown command to logind ...
    .. seems I finally have to alter the global poweroff target, which I originally wanted to avoid. But changing sddm to not use logind it a custom HaltCommand is provided does not seem to be a good solution as well.
    Yes, it's not easy and, more than few things make it not that simple …

    Code:
    QDBusInterface logind{"org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus()};
    const auto message = logind.callWithArgumentList(QDBus::Block, "CanPowerOff", {});
    QDBusPendingReply< QString > canPowerOff = message;
    Q_ASSERT(canPowerOff.isFinished());
    if (canPowerOff.isError()) {
        const auto error = canPowerOff.error();
        qWarning().noquote()
                << QDBusInterface::tr("Asynchronous call finished with error: %1 (%2)")
                   .arg(error.name(), error.message());
        return EXIT_FAILURE;
    }
    if (canPowerOff.value() == "yes") {
        QDBusPendingReply<> powerOff = logind.callWithArgumentList(QDBus::Block, "PowerOff", {true, });
        Q_ASSERT(powerOff.isFinished());
        if (powerOff.isError()) {
            const auto error = powerOff.error();
            qWarning().noquote()
                    << QDBusInterface::tr("Asynchronous call finished with error: %1 (%2)")
                       .arg(error.name(), error.message());
            return EXIT_FAILURE;
        }
    } else {
        qCritical().noquote()
                << QCoreApplication::translate("poweroff", "Can't power off: CanPowerOff() result is %1")
                   .arg(canPowerOff.value());
        return EXIT_FAILURE;
    }
    And a polkit tweak – ‘/etc/polkit-1/rules.d/10-enable-shutdown.pkla’ – possibly not needed with openSUSE …
    Code:
    [Enable shoutdown for users]
    Identity=unix-group:users
    Action=org.freedesktop.login1;org.freedesktop.login1.power-off;org.freedesktop.login1.power-off-ignore-inhibit;org.freedesktop.login1.power-off-multiple-sessions
    ResultAny=yes
    ResultInactive=yes
    ResultActive=yes

  4. #24
    Join Date
    Oct 2008
    Location
    Germany, Bremen
    Posts
    59

    Default Re: "sddm" ignores "HaltCommand"

    Quote Originally Posted by dcurtisfra View Post
    Yes, it's not easy and, more than few things make it not that simple …
    ... yes, full acknowledge. Maybe I will drop a feature request to logind to be able to customize the power off behavior ... but meanwhile, I agree with TSU that now the easiest way is to alter the standard "poweroff" behavior.
    I think this thread can be closed right now; if I have difficulties with the implementation I will open a new thread because it*s another topic then.

    Thanks for the discussion , regards, the_wumpus

  5. #25
    Join Date
    Oct 2008
    Location
    Germany, Bremen
    Posts
    59

    Thumbs up Re: "sddm" ignores "HaltCommand"

    Quote Originally Posted by tsu2 View Post
    OK.
    Then replace your shutdown command instead of modifying it... either the binary or the systemd Unit file(using correct procedure by creating a copy of the Unit file in /etc/systemd/system/ and do not modify the original Unit file), however you're shutting down.

    Note that there are many ways to invoke a shutdown and there are a variety of shutdown, poweroff, etc methods that can be invoked either through your Desktop or not.

    Should be that simple.
    Swap out the command executable whether it's a binary, configuration, script or whatever.
    Your replacement should execute whatever you want and in the end will have to end with a default poweroff, shutdown or whatever, possibly renamed or relocated so it's not invoked first in the sequence of your custom shutdown..
    Hi, yes, as I now learned that is it actually not ssdm initiating the poweroff, but logind, I agree that it is the best way to alter the default poweroff behavior by changing the appropriate (copy of the...) unit file or something like that. Changing and re-compiling sddm or logind would surely be "a bit" too much in this case .

    As written in my reply to dcurtisfra, I think this thread can be closed now; if I don't get along with the implementation I'll create a new thread as this would be a different topic.

    Thanks for the discussion , regards, the wumpus

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •