Skip to main content
Topic: Perform actions before/after hibernating/suspending with acpid (Read 790 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Perform actions before/after hibernating/suspending with acpid

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.

Re: Perform actions before/after hibernating/suspending with acpid

Reply #1
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 ?

Re: Perform actions before/after hibernating/suspending with acpid

Reply #2
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.

Re: Perform actions before/after hibernating/suspending with acpid

Reply #3
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.

Re: Perform actions before/after hibernating/suspending with acpid

Reply #4
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
Linux is simple; use Artix, or Submit Your System To Evil Malicious D(a)emons

 

Re: Perform actions before/after hibernating/suspending with acpid

Reply #5
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.


Re: Perform actions before/after hibernating/suspending with acpid

Reply #6
- 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].

Re: Perform actions before/after hibernating/suspending with acpid

Reply #7
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.

Re: Perform actions before/after hibernating/suspending with acpid

Reply #8
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.

Re: Perform actions before/after hibernating/suspending with acpid

Reply #9
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
Linux is simple; use Artix, or Submit Your System To Evil Malicious D(a)emons

Re: Perform actions before/after hibernating/suspending with acpid

Reply #10
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