JFLib

plat/linux_life.rs (Linux)#

Source: lib/plat/linux_life.rs

linux_life -- lifecycle events on Linux

  life_start()     (the first window) the SIGTERM handler and the watcher thread, once
  life_poll()      (wait) a SIGTERM that arrived -> E_SESSION_END

SIGTERM (logout, shutdown, `kill`) sets a flag and wakes the loop: the app gets
E_SESSION_END (UIC_SESSION_END), saves, and ends.  The watcher thread has connections of
its own (linux_dbus.rs): logind's PrepareForSleep(b) on the system bus (only from the unique
name that owns org.freedesktop.login1, followed through NameOwnerChanged) -> E_POWER (1
sleep, 0 woke up); the settings portal's SettingChanged(namespace, key, value) on the
session bus -> E_SETTINGS with SET_THEME (color-scheme, accent-color, gtk-theme),
SET_CONTRAST (contrast, high-contrast), SET_FONTS (font names, text-scaling-factor),
SET_LOCALE (region), SET_OTHER (org.gnome.desktop.wm.preferences button-layout,
action-*-titlebar: the library's title bar); other keys are ignored.  The settings files
without the portal (linux_settings.rs: GTK's gtk-4.0 / gtk-3.0 settings.ini, KDE's kdeglobals)
through inotify on $XDG_CONFIG_HOME and its gtk-4.0 / gtk-3.0 folders (not recursive; the
folders are watched once created): a write, rename or removal of one of those files ->
E_SETTINGS SET_THEME | SET_OTHER, once per batch of events, and only while the last read of
the settings used the files (the portal said everything: its signals are enough).  Without
a bus and without inotify the thread ends quietly; jfgui_LIFE=0 turns it off.
  • fn life_start() the SIGTERM handler and the watcher thread (once)

  • fn life_poll() (wait) a SIGTERM since the last call -> E_SESSION_END queued

Source: docs/API.md in the JFLib repository.