Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a command to be executed during shutdown #7671

Closed
littleblack111 opened this issue Sep 6, 2024 · 24 comments
Closed

a command to be executed during shutdown #7671

littleblack111 opened this issue Sep 6, 2024 · 24 comments
Labels
enhancement New feature or request

Comments

@littleblack111
Copy link
Contributor

Description

like a command that executes before anything start to shutdown.

use cases of this can be for sth like: #2475 (comment)
or stuff like writing script to see if system is updating and cancel the shutdown if it is

@littleblack111 littleblack111 added the enhancement New feature or request label Sep 6, 2024
@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

You can script this with a systemd unit targetting shutdown.target. Ask chatgpt.

Not a hyprland issue.

@littleblack111
Copy link
Contributor Author

ik. i mean this isnt really a issue... its a feature request

but if i do before shutdown.target
it would be like display manger closed, pipwire and everything.

thus stuff like #2475 (comment) won't be achivable

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

Still a systemd thing. You need a hyprland.service started by systemd and a script.service that triggers After=hyprland.service

@littleblack111
Copy link
Contributor Author

uncertain wdym by a hyprland.service. but if its a service that runs along hyprland or starts hyprland. then i'm pretty sure After=hyprland will make it start after hyprland start instead of when hyprland is shutting down. but even if it runs after hyprland shuts. still wont be able to do stuff like #2475 (comment) cuz

it would be like display manger closed, pipwire and everything.

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

True my bad, it is not After. You can use ExecStopPost probably in the systemd unit. You have to play with systemd to achieve this.

@littleblack111
Copy link
Contributor Author

I see.. May I know wdym by hyprland.service though? like replace display manager and just start hyprland?

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

Yes

@littleblack111
Copy link
Contributor Author

littleblack111 commented Sep 6, 2024

Actually, that sounds like a good idea. since my display manager config is just autologin... ill have a try

I copied the sddm service file and modified:

[Unit]
Description=Hyprland
[email protected]
After=systemd-user-sessions.service [email protected] plymouth-quit.service systemd-logind.service [email protected]
PartOf=graphical.target
StartLimitIntervalSec=30
StartLimitBurst=2


[Service]
ExecStart=/usr/bin/Hyprland
; Restart=always
User=system
Group=system

[Install]
Alias=display-manager.service

@littleblack111
Copy link
Contributor Author

nope. doesnt work. i'm pretty sure theres a service that sets xdg_runtime_dir. suggested by https://www.reddit.com/r/archlinux/comments/167v652/hyprland_refusing_to_start_says_xdg_runtime_dir/ its a pam_systemd probelm. which idk what the service is. thus this wont work...

@littleblack111
Copy link
Contributor Author

please read the link provided. i am experiencing that issue. and if the env is not set. my runtime is prob not mounted as well... so hyprland will prob fail

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

I am pretty sure that you can achieve it someway or another. I think that your service file is not good for hyprland. I havent use systemd to start hyprland before, but I would try login with my user in the tty and starting the service manually from it to see whats going on.

@littleblack111
Copy link
Contributor Author

littleblack111 commented Sep 6, 2024

starting it manually would work

wdym by the user and group should be in my users service file? like ~/.config/systemd?

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

User=youruser
Group=youruser

Also look at After= , because you just need your user to login first and after trigger it automatically. You can achieve it. Look https://wiki.archlinux.org/title/Getty#Virtual_console

@littleblack111
Copy link
Contributor Author

wdym? I did:

[Service]
ExecStart=/usr/bin/Hyprland
; Restart=always
User=system
Group=system
ik i can do that. but i dont wanna login. i want it to be automaticlly on. dont worry about security cuz they would need to unlock the LUKS via password first in order to unlock the disk

@Vladimir-csp
Copy link
Contributor

Ordering is reversed on deactivation. Setting After=unit1.service in unit2.service will delay deactivation of unit1.service until unit2.service is deactivated

Also, check this out.

@littleblack111
Copy link
Contributor Author

cool repo!

@Vladimir-csp
Copy link
Contributor

On the topic though, exec-shutdown might be handy anyway.
I.e. Labwc has both autostart and shutdown scripts.

@littleblack111
Copy link
Contributor Author

yes. thats Y i'm filing this feature request. hope some maintainer sees this :D

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

ik i can do that. but i dont wanna login. i want it to be automaticlly on. dont worry about security cuz they would need to unlock the LUKS via password first in order to unlock the disk

Look at the archwiki link I provided to you. Learn your init system to achieve what you want. You can ask on hyprland's discord too. Good luck.

@littleblack111
Copy link
Contributor Author

i see you can auto login. but i think

On the topic though, exec-shutdown might be handy anyway.
as well

@Aqa-Ib
Copy link
Contributor

Aqa-Ib commented Sep 6, 2024

You can set up the hyprland service after the autologin service running as your user. That should work fine.

@Trimutex
Copy link
Contributor

Trimutex commented Sep 7, 2024

@littleblack111 Try #7683

@littleblack111
Copy link
Contributor Author

@littleblack111 Try #7683

Ty for making it! I'll try later when I get on my computer

@vaxerski
Copy link
Member

vaxerski commented Sep 7, 2024

closing per #7683

@vaxerski vaxerski closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants