feat(presets): add per-preset output device association#294
Open
dennislemennace wants to merge 1 commit into
Open
feat(presets): add per-preset output device association#294dennislemennace wants to merge 1 commit into
dennislemennace wants to merge 1 commit into
Conversation
Lets a preset optionally remember which output device was active when it
was saved, and switch to that device automatically when the preset is
loaded — making profile switching a single action instead of two.
- PresetManager: new _presetDevices map (name → {deviceId, useDefault}),
persisted in preset_devices.json alongside the existing preset_rules.json.
setPresetDevice/clearPresetDevice/hasPresetDevice/applyPresetDevice API.
applyPresetDevice() sets AppConfig::AudioOutputDevice +
AudioOutputUseDefault, which triggers a live switch via
PipewireAudioService::onAppConfigUpdated — the same path SettingsFragment
uses. A _suppressDeviceApply guard prevents a feedback loop when a
device-change rule fires and loads a preset via onOutputDeviceChanged.
rename() and remove() keep the map in sync.
- PresetFragment: "Remember output device" checkbox (opt-in; default
behaviour unchanged). Hidden on PulseAudio builds alongside the existing
rules button, since the PulseAudio device-switch path is stubbed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Hi, I am new to github and this is my first PR using LLM. This is a feature which is super convenient for my use case, which is having different profile presets for each device. This allows the output device to be saved with the preset if the checkbox is enabled. I have built and tested on Bazzite and seems to work well. Please consider approving this, and let me know if I can improve this PR in anyway! Thanks for the great software :) |
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.
What this does
Adds an opt-in "Remember output device" checkbox to the Presets panel. When checked at save time, the currently selected output device is stored alongside the preset. When that preset is later loaded — from the panel or the tray icon — the app automatically switches to that device, making profile switching a single action.
Default behaviour is completely unchanged: presets saved without the checkbox never affect the output device.
Implementation details
Storage — a new
preset_devices.jsonsidecar file managed byPresetManager, structured as a JSON object mapping preset name →{deviceId, useDefault}. This mirrors the existingpreset_rules.jsonpattern and deliberately keeps device names out of the portable.confpreset files, since they are machine-specific.Apply path —
applyPresetDevice()setsAppConfig::AudioOutputDevice+AppConfig::AudioOutputUseDefault, which triggers a live device switch viaPipewireAudioService::onAppConfigUpdated— the same pathSettingsFragmentuses when the user picks a device manually.Feedback-loop guard — the existing
onOutputDeviceChangedrule system loads presets in response to device changes. A_suppressDeviceApplyflag prevents the loaded preset from firing another device change in that code path.Rename/delete sync —
PresetManager::rename()andremove()keep_presetDevicesin sync so stale entries don't accumulate.PulseAudio — the new checkbox is hidden under
#ifdef USE_PULSEAUDIOalongside the existing Rules button, since the PulseAudio device-switching path is stubbed (PulsePipelineManagerhardcodesuse_default_sink = true).Files changed
src/data/PresetManager.h— new map, path helper, load/save/set/clear/has/apply declarationssrc/data/PresetManager.cpp— full implementation + hooks inloadFromPath,rename,remove,onOutputDeviceChangedsrc/interface/fragment/PresetFragment.ui—rememberDeviceQCheckBoxsrc/interface/fragment/PresetFragment.cpp— checkbox wired to save/reflect state; hidden on PulseAudio