Skip to content

Automatic profile switch based on process detection#343

Open
cazzoo wants to merge 11 commits into
berarma:masterfrom
cazzoo:feat/auto-switch
Open

Automatic profile switch based on process detection#343
cazzoo wants to merge 11 commits into
berarma:masterfrom
cazzoo:feat/auto-switch

Conversation

@cazzoo
Copy link
Copy Markdown
Contributor

@cazzoo cazzoo commented Apr 23, 2026

This feature add capability for automatic profile switch when a game executable is detected.
This relies on the current profile system.
Works on both GUI and CLI (adds a --watch argument).
Auto-switch is an application settings that can be enabled or disabled at any time.

As side note, it also defines a DEFAULT profile to revert back when games are closed, restoring a default setting.

Note: This is AI Generated code (fully), steer by my own requests. I validated the use-case but it can contain some bugs or undesired behavior.

cazzoo added 11 commits April 22, 2026 21:45
- process_watcher.py: scan /proc for running processes (comm + exe symlink)
- profile_auto_switcher.py: background thread that polls processes,
  matches against profile game_processes INI keys, auto-loads profiles,
  and sends desktop notifications on switch
- Add 'game_processes' to defaults and types (stored as string, comma-separated)
- load(): reads game_processes from profile INI [profile] section
- save(): writes game_processes to [profile] section separately
- Add set_game_processes/get_game_processes
- Fully retrocompatible: missing key = None, existing profiles unchanged
- --watch: headless daemon that polls processes and auto-switches profiles
- --watch-interval: configurable poll interval (default 2s)
- --default-profile: fallback profile when no game detected
- --list-profiles: list available profiles
- Graceful shutdown on SIGINT/SIGTERM
- on_auto_switch_state_set: start/stop ProfileAutoSwitcher
- on_game_processes_changed: live update of process names
- on_game_processes_focus_out: sync on focus loss
- Clean up auto_switcher on window destroy
- Add start_auto_switch/stop_auto_switch methods
- Auto-update profile combobox when auto-switch changes profile
- Clean up switcher on SIGINT/window destroy
- Import ProfileAutoSwitcher
…atically

Creates auto-switch toggle and game_processes entry in the existing
Tools tab ListBox without modifying main.ui or gtk_ui.py.
Dynamically attaches set/get methods to the ui object.
- Import setup_auto_switch_widgets
- Call it after ui.start() to inject toggle + entry into Tools tab
- Create GtkHandlers instance for signal wiring
- Fix DeviceManager.start() to accept optional callback parameter
- Fix model.set_ui() not being called during GUI initialization
- Fix --list and --watch not discovering devices (init_device_list never called)
- Fix process picker dialog with live refresh and search filter
- Fix auto-switch crashing from background thread GTK access
- Fix duplicate 'Switched to profile' log output
- Fix --watch mode not loading/applying profiles (headless flag)
- Fix --watch using root's profile path instead of SUDO_USER's
- Fix DEFAULT profile as persistent editable profile (not just device reset)
- Fix game processes not updating on profile change (flush_ui + load from [profile])
- Add single-instance lock via fcntl to prevent concurrent oversteer processes
- Add auto-switch toggle persistence across restarts via preferences
- Add process picker dialog with filter/search from running processes
- Add removable tag pills for selected game processes
- Add FFB settings to profile switch log output
- Add --profile-path CLI argument
- Reduce excessive debug logging, suppress matplotlib spam
- Fix UI handler signal name mismatches in main.ui
- Fix set_height_request -> set_size_request for GTK compatibility
- Add run.sh convenience script for dev testing
The original code accessed button_labels[pressed_button_count + 1] before
incrementing, causing an IndexError when pressing the 9th (last) button.

Fixed by incrementing first, then checking bounds before accessing the label.
The UI label is only updated when there's a next step; the last press
finalizes the setup instead.
- Filter DEFAULT from file scan and combobox to avoid duplicate entry
- Save FFB integer settings with default 0 instead of skipping None
  so sliders (spring, damper, friction, autocenter) stay enabled
@cazzoo
Copy link
Copy Markdown
Contributor Author

cazzoo commented Apr 29, 2026

Hi @berarma , I just issued that PR that appears useful to me. Would you mind review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant