bbidulock / icewm

A window manager designed for speed, usability, and consistency
Other
570 stars 97 forks source link

Support shutdown/reboot/sleep on FreeBSD #761

Closed danfe closed 5 months ago

danfe commented 6 months ago

Consider the following patch I've been running with for a while, works just fine:

--- src/default.h.orig  2023-12-28 18:29:47 UTC
+++ src/default.h
@@ -193,6 +193,11 @@ XSV(const char *, shutdownCommand,              "test 
 XSV(const char *, rebootCommand,                "test -e /run/systemd/system && systemctl reboot || loginctl reboot")
 XSV(const char *, suspendCommand,               "test -e /run/systemd/system && systemctl suspend || loginctl suspend")
 XSV(const char *, hibernateCommand,             "test -e /run/systemd/system && systemctl hibernate || loginctl hibernate")
+#elif __FreeBSD__
+XSV(const char *, shutdownCommand,              "shutdown -p now")
+XSV(const char *, rebootCommand,                "shutdown -r now")
+XSV(const char *, suspendCommand,               "zzz")
+XSV(const char *, hibernateCommand,             0)
 #else
 XSV(const char *, shutdownCommand,              0)
 XSV(const char *, rebootCommand,                0)

Hibernate (suspend to disk, S4) is not supported on FreeBSD.

gijsbers commented 5 months ago

Would it be OK to use "poweroff" and "reboot" instead?

danfe commented 5 months ago

Would it be OK to use "poweroff"

Yes, it would: per the manpage, calling poweroff is equivalent to shutdown -p now. However,

and "reboot" instead?

This one is different: reboot merely flushes the file system cache to disk, sends all running processes a SIGTERM (and subsequently a SIGKILL) signal, and restarts the system; it short-circuits the normal shutdown process by not going through all of the RC and other bookkeeping of stopping processes and logging actions properly before killing the OS. You may want to check out this forum thread. Thus, for consistency's sake, I've opted for shutdown(8) in both cases.