Automatic profile switch based on process detection#343
Open
cazzoo wants to merge 11 commits into
Open
Conversation
- 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
Contributor
Author
|
Hi @berarma , I just issued that PR that appears useful to me. Would you mind review it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.