You are not logged in.
I've been struggling for a while with getting my acpi handler script working correctly with pulseaudio and pipewire.
Looking at journalctl, it reports the error as:
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
I'll spare the gory details of my struggles, but I got it fixed.
Currently the page https://wiki.archlinux.org/title/Acpid only has a small comment about the XDG_RUNTIME_DIR variable:
Note: These commands may not work as expected with PulseAudio. [1] For full functionality, run commands as the current user while specifying the XDG_RUNTIME_DIR environment variable, for example with:
# sudo -u user XDG_RUNTIME_DIR=/run/user/user_id pactl
I have a more fleshed out implementation of this, which was a lot more work than expected.
https://gist.github.com/christian-oudar … d13563b594
TARGET_UID=1000
my_pactl() {
setpriv --reuid $TARGET_UID sh -c "XDG_RUNTIME_DIR=/run/user/$TARGET_UID pactl $*"
}
...
button/mute)
my_pactl set-sink-mute @DEFAULT_SINK@ toggle
logger 'Mute button pressed'
;;
button/volumeup)
my_pactl set-sink-mute @DEFAULT_SINK@ 0
my_pactl set-sink-volume @DEFAULT_SINK@ +5%
logger 'Volume up'
;;
button/volumedown)
my_pactl set-sink-volume @DEFAULT_SINK@ -5%
logger 'Volume down'
;;
Maybe we could share this in the wiki? I haven't contributed to the wiki yet, so I don't know what the process and norms are.
Last edited by christian-oudard (2023-05-31 16:53:20)
Offline
That snippet hardcodes a single user, so it won't work on multi-user systems. See https://wiki.archlinux.org/title/Acpid# … nt_display instead
Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Offline
Or don't harcode anything and allow users to handle events however they like through acpi_listen in their own session where these env vars are already set as expected.
Offline