You are not logged in.

#1 2023-09-19 08:03:52

qtg
Member
Registered: 2023-09-19
Posts: 7

[SOLVED] Difficulty launching wlogout using acpid on Hyprland

So I've been trying to use acpid to launch wlogout when the power button is pressed on Hyprland, and while acpid did catch and managed to execute the script, wlogout are still not being launched.

Here's the script that'll get invoked when the power button is pressed:

#!/bin/sh
export DISPLAY=:1
kitty wlogout -p layer-shell

The script does run when run from the terminal, but when called by acpid, I got this error instead from journalctl:

Sep 19 15:55:12 qtg acpid[19387]: Authorization required, but no authorization protocol specified
Sep 19 15:55:12 qtg acpid[19387]: [262 15:55:12.200476] [glfw error 65544]: X11: Failed to open display :1
Sep 19 15:55:12 qtg acpid[19387]: GLFW initialization failed 

Am I missing something from my script? Or am I missing a package?

Last edited by qtg (2023-09-26 09:47:32)

Offline

#2 2023-09-19 08:58:05

seth
Member
Registered: 2012-09-03
Posts: 59,895

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

Why are you using kitty?
Why are you exporting the X11 DISPLAY instead of WAYLAND_DISPLAY ?
Why are you then referencing :1? Is there an X11 server running on :1 at all?

Offline

#3 2023-09-19 09:32:05

dogknowsnx
Member
Registered: 2021-04-12
Posts: 652

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

Have you tried to simply assign a keybinding?

EDIT: Hi and welcome to the forums!

Last edited by dogknowsnx (2023-09-19 09:33:19)


RI - Rest your Eyes and Self

"We are eternal, all this pain is an illusion" - Maynard James Keenan

Offline

#4 2023-09-19 12:51:58

qtg
Member
Registered: 2023-09-19
Posts: 7

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

dogknowsnx wrote:

Have you tried to simply assign a keybinding?

EDIT: Hi and welcome to the forums!

Oh, I completely forgot that I can do that!

Offline

#5 2023-09-19 12:58:32

qtg
Member
Registered: 2023-09-19
Posts: 7

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

seth wrote:

Why are you using kitty?
Why are you exporting the X11 DISPLAY instead of WAYLAND_DISPLAY ?
Why are you then referencing :1? Is there an X11 server running on :1 at all?

1. Because running it without kitty gives an error: "cannot open display: " so I thought running it from kitty would work
2. I tried changing it to WAYLAND_DISPLAY after reading your reply but still got an error about wayland failing to connect to the display. Tried it with ":1" and "wayland-1" which is what $WAYLAND-DISPLAY is set to
3. After reading about it, I can see that $XDISPLAY returns a ":1" so maybe there's one running?

Offline

#6 2023-09-19 13:02:10

seth
Member
Registered: 2012-09-03
Posts: 59,895

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

Are there two wayland sessions? (btw. _underscore_ ./. -dash- matters w/ the variable name)

Sanity check: can you run wlogout in your hyprland session?

You might also have to "sudo -u qtg" this.

Offline

#7 2023-09-20 07:38:47

dogknowsnx
Member
Registered: 2021-04-12
Posts: 652

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

qtg wrote:
dogknowsnx wrote:

Have you tried to simply assign a keybinding?

EDIT: Hi and welcome to the forums!

Oh, I completely forgot that I can do that!

If this has been an X/Y issue and you consider it solved, please edit the title by adding [SOLVED]

(although I'd wager that @seth would like to keep going...)


RI - Rest your Eyes and Self

"We are eternal, all this pain is an illusion" - Maynard James Keenan

Offline

#8 2023-09-20 23:50:03

qtg
Member
Registered: 2023-09-19
Posts: 7

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

seth wrote:

Are there two wayland sessions? (btw. _underscore_ ./. -dash- matters w/ the variable name)

Sanity check: can you run wlogout in your hyprland session?

You might also have to "sudo -u qtg" this.

Sorry for the late reply, but yes I can run wlogout and the script just fine from my terminal running on a hyprland session, It just cant be run from the script. Here's the current script:

#!/bin/sh
export WAYLAND_DISPLAY=wayland-1
sudo -u qtg wlogout

WAYLAND_DISPLAY is set to wayland-1 because thats what $WAYLAND_DISPLAY returns, unless thats not where I should be getting that value. Running the script from acpid returns this error:

Sep 21 07:38:21 qtg sudo[29754]:     root : PWD=/ ; USER=qtg ; COMMAND=/usr/bin/wlogout
Sep 21 07:38:21 qtg sudo[29754]: pam_unix(sudo:session): session opened for user qtg(uid=1000) by (uid=0)
Sep 21 07:38:21 qtg wlogout[29755]: cannot open display: 
Sep 21 07:38:21 qtg sudo[29754]: pam_unix(sudo:session): session closed for user qtg

Offline

#9 2023-09-21 05:56:48

seth
Member
Registered: 2012-09-03
Posts: 59,895

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

sudo -u qtg env WAYLAND_DISPLAY=wayland-1 wlogout

Offline

#10 2023-09-21 08:05:07

qtg
Member
Registered: 2023-09-19
Posts: 7

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

seth wrote:
sudo -u qtg env WAYLAND_DISPLAY=wayland-1 wlogout

still getting the same error

Offline

#11 2023-09-21 12:40:15

seth
Member
Registered: 2012-09-03
Posts: 59,895

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

The only way this makes any sense is that the wayland logout tool is an Xwayland client in which case you'll also have to set DISPLAY and XAUTHORITY - maybe USER
https://gist.github.com/AladW/de1c5676d93d05a5a0e1 demonstrates how to import those variables from a process (xinit) but you can also just hardcode them.

Offline

#12 2023-09-26 09:49:27

qtg
Member
Registered: 2023-09-19
Posts: 7

Re: [SOLVED] Difficulty launching wlogout using acpid on Hyprland

Hey, sorry for the late response but Im marking this as solved as using the Hyprland keybind already works out of the box. Sorry for the inconvenience

Offline

Board footer

Powered by FluxBB