Autostart option added

This commit is contained in:
2026-10-18 18:26:06 +02:00
parent 74503c27dd
commit 95f101c0c9
22 changed files with 2987 additions and 80 deletions

View File

@@ -361,6 +361,39 @@ Start-up orders:
comes from a build without the action — and `on_activate` re-presents the
window that is already there instead of building a second one. A stale window
therefore never stays next to a fresh one, and the daemon is not involved.
- Menu, help and options: `Help` (also `F1`) opens a one-page explanation of the
rows, types, capture dialog, daemon status and tray; `Options` opens a small
non-modal window with the GUI's own switches (tray behaviour, language,
autostart) and the daemon in detail (state, version, keyboard, config file, last
key), while the footer keeps the one-line summary. A `GMenu` cannot host a
switch, so the options are a window.
- Autostart is the session's `.desktop` entry and nothing else
(`src/autostart.{h,cpp}`): `~/.config/autostart/gkeymapper.desktop` existing (and
not switched off by the desktop's own tool) *is* "on", so the switch cannot
disagree with what the session reads at login. It starts the window, never the
daemon: the daemon is a user service, and it stays the only part that has to
run. The window is a convenience — the mappings can be edited any time, and the
G keys work with it closed.
- Language switching is immediate, without a restart and without losing rows that
were not saved: gettext is handed the code through `LANGUAGE` plus a fresh
`setlocale`, and the windows are built again (the rows are carried over with
`collect_mappings`/`apply_mappings`; the tray menu is announced with
`LayoutUpdated`). `System language` is the default and follows the desktop;
the choice lives in `gui.conf` and is applied before the first string is built,
so a restart keeps it.
- `Minimize to tray`: closing or minimizing hides the window instead of quitting,
and the tray icon shows it again (`Show`) or quits the program (`Close`). GTK4
has no minimize signal and `GdkToplevel` has no properties, so the state is
polled (250 ms) while the option is on; hiding happens only while a panel really
hosts the icon — without one there would be no way back to the window. The
preference lives in `~/.config/gKeyMapper/gui.conf`, next to `mappings.conf` but
a file of its own, so a mapping file stays a mapping file.
- The tray icon is a `StatusNotifierItem` plus a `com.canonical.dbusmenu` menu
spoken over GIO (`src/trayicon.{h,cpp}`): the protocol libxapp and
libappindicator wrap, without their GTK3 dependency — a GTK4 process must not
load GTK3. The icon travels as an `IconPixmap`, because the panel is another
process and cannot read the icons compiled into the binary. Both watcher names
are watched and the item registers once, preferring `org.kde.StatusNotifierWatcher`.
## 6. Code layout
@@ -368,6 +401,11 @@ Start-up orders:
src/ # GUI (existing)
daemonclient.{h,cpp} # D-Bus client (status/reload/signals)
singleinstance.{h,cpp} # one GUI only: a new start closes the running instance
trayicon.{h,cpp} # tray icon: StatusNotifierItem + dbusmenu over GIO
settings.{h,cpp} # gui.conf (window preferences, e.g. minimize to tray)
autostart.{h,cpp} # the session's autostart entry (~/.config/autostart)
help.{h,cpp} # help window
optionsdialog.{h,cpp} # options window: switches + detailed daemon status
daemon/ # as implemented (see §6 above)
ipc_dbus.{h,cpp} # GDBus service (control plane)
shared/