Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added comments for users that can't use systemctl. #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Bavuett
Copy link

@Bavuett Bavuett commented Apr 25, 2022

As a Void Linux user, I had problems using this script.
By browsing this repo's issues, I have discovered that you can't use systemctl on Void Linux (I am a new Linux user so I didn't know that). For this reason, I added comments to help people like me who don't know about these details to encourage them to use loginctl as an alternative, which works without any problem.

@Bavuett Bavuett marked this pull request as draft April 25, 2022 13:50
@Bavuett Bavuett marked this pull request as ready for review April 25, 2022 13:58
@ohxxm
Copy link

ohxxm commented Apr 26, 2022

Making this a separate file would be better so the user can automatically use the script instead of having to edit it.

@Bavuett
Copy link
Author

Bavuett commented Apr 26, 2022

Will do that!

Editing the script to better fit what was decided in the Pull Request.
This script is made to work on Void Linux and distros that don't use systemctl
@Bavuett
Copy link
Author

Bavuett commented Apr 26, 2022

Done! This should fit your needs.

@ohxxm
Copy link

ohxxm commented Apr 26, 2022

Great! Let's hope this can be merged.

@Bavuett
Copy link
Author

Bavuett commented Apr 27, 2022

Hi! I noticed that the Pull Request isn't merged. Is everything ok, or is there something I need to do?

@ohxxm
Copy link

ohxxm commented Apr 27, 2022

I can't merge pull requests. Only the owner can or anyone with the pull request permission.

@Bavuett
Copy link
Author

Bavuett commented Apr 27, 2022

Ah, sorry. I got confused and thought you had the permissions. Have a good day!

@ohxxm
Copy link

ohxxm commented May 17, 2022

Had to install elogind first and edit sudoers file for this to work

@ohxxm
Copy link

ohxxm commented May 23, 2022

UPDATE:
You can add this to one of the forks such as mine(https://github.com/Spaxly/rofi-power-menu) as a separate branch until I get a script working to choose systemctl or other commands.

@gagero
Copy link

gagero commented Jun 15, 2022

@Spaxly What edit did you make to your sudoers to get this working?

@ohxxm
Copy link

ohxxm commented Jun 15, 2022

@Spaxly What edit did you make to your sudoers to get this working?

I had to allow the commands to be used without sudo, I don't have the specifics because I don't use Void or rofi power menu anymore

@jluttine
Copy link
Owner

jluttine commented Apr 4, 2023

Thanks for the PR! I'm not too familiar with systemctl and loginctl, so do you know if systemctl could be replaced with loginctl in the original script? I mean, is there any reason to use systemctl instead of loginctl, do you know?

@gagero
Copy link

gagero commented Apr 4, 2023

You could certainly replace poweroff and reboot, and I'm fairly certain you can replace hibernate and suspend as well.

@Bavuett
Copy link
Author

Bavuett commented Apr 12, 2023

Hey! Sorry for not answering, but here in Italy we have a quite long Easter vacation and I stayed off of GitHub as well.

I am not using Void Linux much anymore, but as far as I know Loginctl is Runit's (Systemd alternative that Void uses) CLI for managing the power status of the machine.

Since I am now using Fedora and can use Systemctl without any problems I didn't look up for ways to improve it further, but I am available if you need help since I rely on your script daily and would love to be useful.

@jluttine
Copy link
Owner

jluttine commented May 3, 2023

Alright, it seems that the "standard" loginctl with systemd doesn't have commands for suspend/hibernate/reboot/shutdown: https://www.freedesktop.org/software/systemd/man/loginctl.html

I wonder if these commands are more general, that is, work on a larger set of Linux OSes:

  • suspend: pm-suspend (requires pm-utils package)
  • hibernate: pm-hibernate (requires pm-utils package)
  • reboot: reboot or shutdown -r (do these work only with systemd or does each OS define aliases in a way that works in that OS?)
  • shut down: poweroff or shutdown -P (do these work only with systemd or does each OS define aliases in a way that works in that OS?)

Alternatively, the script could try a few different ways to do the action until the command succeeds. For instance:

systemctl poweroff || poweroff || shutdown -P
systemctl suspend || loginctl suspend || pm-suspend

Or something like that. But I'd prefer having a single command that's supposed to work on all Linux OSes if possible.

EDIT: Apparently, there's no "POSIX-way" of shutting down etc. And I couldn't find any reference on if there exists "The Correct Command".

@d3jv
Copy link

d3jv commented Sep 15, 2024

Void and many other systems use elogind which has all of the commands used in this script that would otherwise be run with systemctl on a systemd system so you can absolutely just replace systemctl with loginctl.

Maybe there could be a flag to switch to it like --elogind.

Or you can just put alias systemctl=loginctl into your bashrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants