apognu / tuigreet

Graphical console greeter for greetd
GNU General Public License v3.0
992 stars 45 forks source link

Power option doesn’t work #38

Closed ghost closed 3 years ago

ghost commented 3 years ago

On Gentoo, the power option doesn't seem to work, not sure weather it's like previous problem #33 that Gentoo ebuild doesn't do something that requires this function to work.

apognu commented 3 years ago

This one should be on me.

I don't have a Gentoo box handy, do you know if the shutdown command can be used by regular users, or does it need root privileges?

That's the usual suspects issue I could see right now, without investigating further.

Currently, power options uses a crate that shells out to this command to shut down and reboot.

ghost commented 3 years ago

This one should be on me.

I don't have a Gentoo box handy, do you know if the shutdown command can be used by regular users, or does it need root privileges?

That's the usual suspects issue I could see right now, without investigating further.

Currently, power options uses a crate that shells out to this command to shut down and reboot.

Both shutdown reboot need to be executed either by sudo or doas.

The command I tested is doas shutdown -h now

apognu commented 3 years ago

Okay, so at least we know why it doesn't work, thanks (tuigreet runs as a regular user).

The crate I'm using does not support any kind of customization of the way to initiate shutdown, so I'll investigate doing it in-house. I may not be able to change default behavior (I cannot expect sudo or doas to be installed on a specific system), but I can add a way to customize the commands that are run (so you may specify a custom one).

I'll make some tests and come back to you.

apognu commented 3 years ago

Hey @IchikaOmamori, 227350195b37f4226df176350c41bd38cdbe1c85 adds a way to customize power commands through something like --power-shutdown 'sudo shutdown -h now'. This requires non-interactive commands and single-word arguments (no shell interpolation).

If you are able to give master a spin, couldy you tell me if everything works as expected?

ghost commented 3 years ago

Hey @IchikaOmamori, 227350195b37f4226df176350c41bd38cdbe1c85 adds a way to customize power commands through something like --power-shutdown 'sudo shutdown -h now'. This requires non-interactive commands and single-word arguments (no shell interpolation).

If you are able to give master a spin, couldy you tell me if everything works as expected?

Sorry, repoman doesn't seem to accept the version name tip so I cannot generate ebuild to emerge and test package.

apognu commented 3 years ago

Alright. This will be included in the next release as soon as I'm satisfied with the behavior.

ghost commented 3 years ago

Thank you for your work.

apognu commented 3 years ago

Thank you for reporting! :)

I just pushed 0.7.0, maybe this will allow you to test the --power-shutdown and --power-reboot arguments and provide feedback if you have any (especially because I cannot test on that many distribs)?

ghost commented 3 years ago

Thank you for reporting! :)

I just pushed 0.7.0, maybe this will allow you to test the --power-shutdown and --power-reboot arguments and provide feedback if you have any (especially because I cannot test on that many distribs)?

Both --power-shutdown and --power-reboot work!!!

The command I tested that work are loginctl poweroff and loginctl reboot.

doas shutdown -h now and doas reboot doesn't seem to work, I didn't test out sudo.

I would recommend use loginctl if use elogind, systemctl if use systemd.

apognu commented 3 years ago

Good news about the first part!

Do you have configured doas not to ask for a password for those specific commands? Right now, the commands used here must be non-interaxtive, so we won't display any prompts that could show.

I may add a warning about sudo and doas in the README and man page.

ghost commented 3 years ago

Good news about the first part!

Do you have configured doas not to ask for a password for those specific commands? Right now, the commands used here must be non-interaxtive, so we won't display any prompts that could show.

I may add a warning about sudo and doas in the README and man page.

I do use nopass with my current user name in doas.conf, I think in order to let commands to work in either sodo or doas, tuigreet need to be added to wheel group (or whatever that can make tuigreet gain superuser privilege, since tuigreet run as regular user).

apognu commented 3 years ago

That makes sense. Anyway, that would be local configuration specific to a system. Can I consider this issue resolved?

ghost commented 3 years ago

That makes sense. Anyway, that would be local configuration specific to a system. Can I consider this issue resolved?

Yes, everything work perfectly fine. Thanks for your work.