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

@@ -1,5 +1,14 @@
# gKeyMapper
![C++17](https://img.shields.io/badge/C%2B%2B-17-00599C?logo=cplusplus&logoColor=white)
![GTK 4](https://img.shields.io/badge/GTK-4-7FE719?logo=gtk&logoColor=black)
![GLib/GIO](https://img.shields.io/badge/GLib%2FGIO-D--Bus-4A86CF)
![libusb](https://img.shields.io/badge/libusb-1.0-c8a200)
![xkbcommon](https://img.shields.io/badge/xkbcommon-layout--aware-6E4C13)
![i18n](https://img.shields.io/badge/i18n-de%20%7C%20en%20%7C%20es%20%7C%20fr-blueviolet)
![systemd](https://img.shields.io/badge/systemd-user%20service-30D475?logo=systemd&logoColor=white)
![Platform](https://img.shields.io/badge/platform-Linux%20Mint%20%7C%20Ubuntu-FCC624?logo=linux&logoColor=black)
GTK4 application (C++) for remapping the G keys **G1–G9** of a Logitech **G910**
to other keys or commands (Linux Mint / Ubuntu).
@@ -8,6 +17,12 @@ G-keys from the keyboard and replays the actions is implemented as well; the
GUI and the daemon talk over a small D-Bus channel (status, reload, test) — see
`docs/daemon-plan.md`.
**Only the daemon has to run.** It is the part that reads the G keys and replays
the action, and it runs as a systemd user service. The window is for editing the
mappings and for the status: it may be closed at any time, and starting it with
the session (`Options` → `Start with the session`) is a convenience, not a
requirement.
Documentation and source comments are written in English.
## Requirements
@@ -93,6 +108,44 @@ build — and then shows its own window, so a stale window can never stay next t
fresh one. Row edits that were not saved are lost with the replaced window,
because saving is always explicit (`Save mappings`).
### Menu, tray icon and minimize to tray
The menu button in the title bar holds `Export configuration...` / `Import
configuration...`, `Options`, `Help` (also `F1`), `About` and `Quit` (`Ctrl+Q`).
* `Help` opens a one-page explanation of the nine rows, the four types, the
capture dialog, the daemon status and the tray.
* `Options` opens a small window with the GUI's own switches and the daemon in
detail: state, version, keyboard, the config file it reads and the last G key
that fired (the footer says the same in one line). The window is not modal, so
it keeps updating while it is open. One of its switches is the language
(`System language`, or a fixed `de`/`en`/`es`/`fr`): it switches the window, the
menus and the tray menu right away — nothing to restart, and rows that were not
saved yet are kept.
* `Start with the session` opens the window when you log in. It writes the usual
autostart entry (`~/.config/autostart/gkeymapper.desktop`, starting the binary
that is running) and removes it again when you switch it off; an entry that the
desktop's own startup tool has disabled counts as off, too. Like the window
itself this is a convenience: the G keys do not need it, only the daemon has to
run (see `Running the daemon` below).
`Minimize to tray` keeps gKeyMapper reachable from the panel: the window is
hidden instead of closed when you close or minimize it, and the tray icon's menu
shows it again (`Show`) or quits the program (`Close`). Closing still quits when
the option is off — or when no panel hosts the tray icon, because then there
would be no way back to the window. The option is remembered in
`~/.config/gKeyMapper/gui.conf`, a file of its own so `mappings.conf` stays a
pure mapping file. The same file holds the chosen language; with `System
language` (the default) the desktop's locale decides.
The tray icon is a StatusNotifierItem plus a `com.canonical.dbusmenu` menu over
GIO — the same protocol libxapp and libappindicator wrap, only without their GTK3
dependency (a GTK4 process must not load GTK3). It needs no package of its own and
works wherever the protocol is hosted: the Cinnamon panel (via `xapp-sn-watcher`),
KDE, Unity or GNOME with the AppIndicator extension. The icon travels as a pixmap
because the panel is a different process and cannot read the icons compiled into
the binary.
## Running the daemon
The daemon reads G1–G9 from the keyboard and replays the configured action
@@ -288,6 +341,10 @@ src/mappings.{h,cpp} # GUI glue: config file <-> row widgets
src/capturedialog.{h,cpp} # key-capture dialog
src/daemonclient.{h,cpp} # D-Bus client for the daemon (status/reload)
src/singleinstance.{h,cpp} # one GUI only: a new start closes a running instance
src/trayicon.{h,cpp} # tray icon: StatusNotifierItem + dbusmenu over GIO
src/settings.{h,cpp} # gui.conf (window preferences, e.g. minimize to tray)
src/help.{h,cpp} # help window
src/optionsdialog.{h,cpp} # options window: switches + detailed daemon status
shared/mapping.{h,cpp} # mappings format + shortcut parsing (GUI & daemon)
shared/keys.{h,cpp} # canonical key names -> Linux key codes
shared/keymap.{h,cpp} # layout-aware key lookups (xkbcommon), GUI + daemon