Artix Linux Forum

Artix Linux => System => Topic started by: kiblaster on 10 February 2025, 17:23:21

Title: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 10 February 2025, 17:23:21
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.
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: gripped on 10 February 2025, 17:57:29
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 ?
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 11 February 2025, 15:32:09
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.
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 26 February 2025, 21:35:21
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.
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: Artist on 27 February 2025, 00:13:23
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
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: darcy on 27 February 2025, 08:11:49
I don't quite get what your problem is.
Anyway check etc/acpi/handler.sh. Especially this part:
Code: [Select]
    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.

Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: nous on 27 February 2025, 19:11:03
- 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).
Please, consider naming it [world-clown].
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 27 February 2025, 22:10:19
I don't quite get what your problem is.
As I stated:
Quote
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?
Correct me if I am wrong .

Quote
A word of caution related to the original post: don't suspend/hibernate by writing directly to /sys/power/state
...
 Use pm-utils instead.
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.
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 07 March 2025, 17:09:20
According to https://web.archive.org/web/20200928212358if_/https://wiki.gentoo.org/wiki/ConsoleKit:
Quote
ConsoleKit's primary function is to support multi-user setups.
So not it's not really useful for me.

Basu
Quote
Some projects rely on the sd-bus library for DBus support. However not all systems have systemd or elogind installed. This library provides just sd-bus (and the busctl utility).

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.

Quote
Please, consider naming it [world-clown].
A clown world.
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: Artist on 10 March 2025, 01:36:22
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.

Due to set backs this has been put on hold.

artist
Title: Re: Perform actions before/after hibernating/suspending with acpid
Post by: kiblaster on 13 March 2025, 21:11:39
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:
Code: [Select]
dinitctl list | grep elogind