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

config: add exec-shutdown for running commands on shutdown #7683

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

Trimutex
Copy link
Contributor

@Trimutex Trimutex commented Sep 7, 2024

Describe your PR, what does it fix/add?

Adds a config option for executing programs on shutdown.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

Nothing that could crash Hyprland while running immediately found.

Is it ready for merging, or does it need work?

Ready, but want tested by #7671 for any edge cases I might be able to fix

@littleblack111
Copy link
Contributor

@Trimutex I tried it. doesnt really work(I tried hyprctl clients > ~/asdf, which reads "Couldn't read (5)". I think wl_display_terminate prob already terminated all the windows? I tried to move g_pConfigManager->dispatchExecShutdown(); to CCompositor::stopCompositor right before wl_display_terminate but it doesnt seem to execute then. I tried to just putting logs(Debug::log(INFO, "stuff") but the whole stopCompositor part seem to not execute any of the code inside. uncertain how does this work(cuz im noob to coding wayland) but it seems to be the first function that get called when its terminating(by signal).

But anyways. I don't know how would I continue this... But, I hope we can add a exec-pre-shutdown and a exec-post-shutdown. the pre one for first immediate action before any window gets destroyed or anything(e.g. to save info like hyprctl clients, but im not sure if this not working is becuz the IPC shuts down?). But thank you for giving it a go! Hope we can find a solution soon

src/Compositor.cpp Outdated Show resolved Hide resolved
@Trimutex
Copy link
Contributor Author

Trimutex commented Sep 7, 2024

@littleblack111 this should provide what you are looking for now I think

@vaxerski vaxerski merged commit 70add90 into hyprwm:main Sep 7, 2024
10 checks passed
@littleblack111
Copy link
Contributor

@Trimutex is there any way to make it execute it when is shutdown not via hyprctl dispatch exit? I tried sigterm, it doenst execute it.

@Trimutex
Copy link
Contributor Author

Trimutex commented Sep 9, 2024

I'm a little confused about this. Are you asking for it to be handled post-hyprland-shutdown or as its resetting the variables?

@littleblack111
Copy link
Contributor

so, if I shut off hyprland via the the exit dispatcher. it will execute. but any other way(reboot, soft-reboot, restart display manager) will not trigger it.

@Trimutex
Copy link
Contributor Author

Trimutex commented Sep 9, 2024

so, if I shut off hyprland via the the exit dispatcher. it will execute. but any other way(reboot, soft-reboot, restart display manager) will not trigger it.

The closest you can come to that is a wrapper for Hyprland in a script I think. This seems like a bit of an XY problem to me tho

@Trimutex
Copy link
Contributor Author

Trimutex commented Sep 9, 2024

If you want stuff to run on reboot or similar a bash script attached to a restart button inside of Hyprland that is run which calls reboot at end of script is my best guess of what you actually want

@littleblack111
Copy link
Contributor

as described at #7671 I want to do #2475 and possibly pause the shutdown or something if some important task is being executed

@Trimutex
Copy link
Contributor Author

Trimutex commented Sep 9, 2024

as described at #7671 I want to do #2475 and possibly pause the shutdown or something if some important task is being executed

I don't think Hyprland itself is capable of stopping reboot for updates. You can defer the reboot/shutdown call though by using a script that is called to replace shutdown by whatever method you prefer.

@littleblack111
Copy link
Contributor

is the shutdown process if linux un-pausable?

@Trimutex
Copy link
Contributor Author

is the shutdown process if linux un-pausable?

theoretically yes but realistically only if its scheduled for later. attempting to pause it for updates seems unnecessary anyways as other solutions make more sense (e.g. wrapper script for shutdown that checks if a file contains a "1", skipping shutdown if it does)

@Trimutex Trimutex deleted the exec-shutdown branch September 26, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants