Is it possible? I do not use elogind.
Is there something else maybe?
It seems not looking https://wiki.archlinux.org/title/Acpid.
I use "echo disk > /sys/power/state" to hibernate.
It probably can be done using a combination of acpid and pm-utils(AUR).
I first came across this as a fix for 'suspend when closing the lid' on my chromebook.
https://archlinuxarm.org/wiki/Samsung_Chromebook.
pm-utils has not been updated since 2017 but still builds.
And I'm fairly sure it still works. I'd have to update the chromebook to check.
There could be other methods ?
When I press the button or use a lid only acpid should work.
But if send the command to hibernate via a keyboard shortcut how can I do something?
I think that it would be nice to have some dedicated daemon.
I found out that before e/logind people used to use https://github.com/ConsoleKit2/ConsoleKit2, that it's in the AUR.
It is used by FreeBSD.
I was not planning to communicate this yet but as I a see more and more related topics in our forum I'll make a start now:
It's not available for use yet but lately I have been working on a new repo that provides packages like consolekit2, pm-utils and quite a few more to be able to run some custom Xorg and Wayland desktops with neither elogind nor libelogind, but makes use of seatd, turnstile and basu.
These are some currently known limitations:
- This will not be a drop-in replacement for elogind.
- This will not work for all desktops.
- This will not work for all packages.
- It is experimental, so not suited to be used for any daily driver.
- This repo will not be supported in any way by Artix Linux.
- This will result in polkit no longer working for the login1/session actions (reboot/shutdown/suspend/hibernate).
A word of caution related to the original post: don't suspend/hibernate by writing directly to /sys/power/state; this will cause drivers to miss state change interrupts and crash, causing devices to no longer work when the system is resumed unless re-acitvated by a module unload/reload or rescan. Use pm-utils instead.
During the coming weekend I hope to be able to provide more information.
artist
I don't quite get what your problem is.
Anyway check etc/acpi/handler.sh. Especially this part:
button/lid)
case "$3" in
close)
logger 'LID closed'
;;
open)
logger 'LID opened'
;;
*)
logger "ACPI action undefined: $3"
;;
esac
It's not properly configured by default.
Please, consider naming it [world-clown].
As I stated:
Correct me if I am wrong .
Good to know.
I did now about pm-utils back when I was using elogind, it did not work (loginctl hibernate) so I was writing directly.
Is there something else besides consolekit that should I use? I still have to learn what's that.
I am running bspwm right now.
According to https://web.archive.org/web/20200928212358if_/https://wiki.gentoo.org/wiki/ConsoleKit:
So not it's not really useful for me.
Basu
Will Artix keep to having packages depending on elogind?
Alpine does not installed elogind for networkmanager etc. there are UIs like sxmo that works fine without.
A clown world.
Due to set backs this has been put on hold.
artist
I found out that I have elogind-daemon running and it is needed for Xorg I think, killing it kills the UI.
So I disabled acpid since I just press the power button and that is handled by the elogind-daemon process.
According to htop it is started by dinit so it is not clear.
There is no service:
dinitctl list | grep elogind
I have found out about zzz (https://github.com/jirutka/zzz).
From the man page:
FILES
/etc/zzz.d/*
Hook scripts found in this directory are executed before/after the system is
suspended/resumed by zzz.
/etc/zzz.d/suspend/*
Hook scripts found in this directory are executed before the system is suspended
by zzz. This directory is supported for compatibility with zzz(8) on Void Linux.
/etc/zzz.d/suspend/*
Hook scripts found in this directory are executed after the system is resumed.
This directory is supported for compatibility with zzz(8) on Void Linux.
[...]
I did not test hooks yet.
Artix runit has (a possibly slightly tweaked version of?) Void's zzz (the OG) (https://gitea.artixlinux.org/artix/runit-artix/src/branch/master/script/zzz). It's a shell script that doesn't rely on runit being PID 1 and can be used on any init system.
The general solution to the question in the original post is making acpid call a tool that handles hooks, does the kind of extra setup Artist mentioned, then suspends, instead of just suspending through /sys/power/state. Like zzz (either implementation), pm-utils or loginctl suspend.
It's indeed needed for Xorg (Artix would need to patch it to use libseat instead of talking to elogind directly (https://git.devuan.org/devuan/xorg-server/src/branch/suites/experimental/debian/patches/0001-Support-libseat.patch)).
Elogind is started because of the
/usr/share/dbus-1/system-services/org.freedesktop.login1.service file. If Xorg queries for {systemd-,e}logind's functions through the D-Bus (a kind of "message mailman") daemon and the init system hasn't started it yet, D-Bus will "helpfully" start another process that reads the contents of that file, then starts elogind on its own. When that middle process exits, htop and other tools will consider PID 1 (dinit, in your case) as the parent.
I'm oversimplifying a bit here, google about double-forking and reparenting to learn more.
I wanted to used acipd to run hooks.
At the moment since I do not close a lid or use other actions I do not need it.
I teste zzz hook it worked fine.
cat /etc/zzz.d/hook.sh
#!/bin/sh
case "$1" in
pre)
DISPLAY=:0 su -c 'playerctl pause' user
# Lock the screen only when suspending since I have disk encryption no need after hibernating
if [ "$ZZZ_MODE" = "suspend" ]; then
DISPLAY=:0 su -c '~/bin/lock-screen.sh' user &
fi
;;
post)
;;
esac
I am not sure about all the options here:
On Alpine I can run xorg without libseat/seatd and elogind, I do not know why.
They are not installed and there is no process.
zzz is in the AUR and it's quick to install:
aur/zzz 0.1.1-3 [installed] [2+] [0.00%] [11 Mar 2023]
A simple program to suspend or hibernate your computer
I use a custom bash script just for my specific situation:
slep.sh (https://gitlab.freedesktop.org/-/project/4522/uploads/0dcaaccede4ee532a0fd1287bade2a1a/suspend-script.sh.txt)