### Install Build Tools Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Run once to install all build prerequisites: .NET SDK, GitHub CLI, Inno Setup 6, Certum SimplySign Desktop, Python 3, and signtool.exe. ```powershell .\tools\Install-BuildTools.ps1 ``` -------------------------------- ### Build Signed Installer Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Builds a signed installer from an existing Final directory. Validates signatures, signs binaries, compiles with Inno Setup, and signs the resulting installer. ```powershell .\tools\Build-Installer.ps1 -FinalDir .\Final ``` -------------------------------- ### Build Installer (Skip Signing) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Builds the installer from an existing Final directory without signing binaries or the installer. ```powershell .\tools\Build-Installer.ps1 -FinalDir .\Final -SkipSigning ``` -------------------------------- ### SoundSwitch.CLI command examples Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/faq/command-line.md Example commands for the SoundSwitch.CLI executable. All commands accept --json for machine-readable output; failures in JSON mode print a JSON object with an error field and exit with code 1. ```shell SoundSwitch.CLI.exe switch --type Playback SoundSwitch.CLI.exe switch --type Recording SoundSwitch.CLI.exe mute --toggle SoundSwitch.CLI.exe profile --list --json SoundSwitch.CLI.exe status SoundSwitch.CLI.exe devices ``` -------------------------------- ### Settings JSON success output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for the settings --json command on success. ```json { "success": true } ``` -------------------------------- ### Publish Release from Source Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Builds from source and generates the installer without publishing to GitHub. Produces a self-contained release in the Final directory. ```powershell .\tools\Publish-Release.ps1 -BuildFromSource -Configuration Release ``` -------------------------------- ### Ensure hook thread and install hook Source: https://github.com/belphemur/soundswitch/blob/dev/docs/hotkey-hybrid-hook-fallback.md Starts a dedicated STA background thread with a message pump, required for WH_KEYBOARD_LL to function. Sets the hook and runs the application message loop. ```csharp private static void EnsureHookThreadRunning() { if (_hookThread != null && _hookThread.IsAlive) return; _hookThread = new Thread(HookThreadProc) { Name = "KeyboardHookThread", IsBackground = true }; _hookThread.SetApartmentState(ApartmentState.STA); _hookThread.Start(); } private static void HookThreadProc() { _hookProc = LowLevelKeyboardHookCallback; using var curProcess = Process.GetCurrentProcess(); using var curModule = curProcess.MainModule; _hookHandle = SetWindowsHookEx( WH_KEYBOARD_LL, _hookProc, GetModuleHandle(curModule.ModuleName), 0); // Message pump — required for WH_KEYBOARD_LL to function Application.Run(); } ``` -------------------------------- ### Publish to GitHub Releases Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Publishes to GitHub Releases. Downloads the draft release, builds and signs the installer, uploads it, sets the release body from CHANGELOG.md, and publishes after confirmation. ```powershell # For stable releases .\tools\Publish-Release.ps1 -Channel release ``` ```powershell # For beta releases .\tools\Publish-Release.ps1 -Channel beta ``` -------------------------------- ### Validation commands for website build Source: https://github.com/belphemur/soundswitch/blob/dev/website/AGENTS.md Commands to install dependencies and build the VuePress site. The build must pass cleanly after every change. ```bash cd website npm ci # install dependencies npm run docs:build # changelog sync + VuePress build — must pass cleanly ``` -------------------------------- ### Devices JSON output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for the devices --json command, showing arrays of playback and recording device names. ```json { "playbackDevices": [ "Speakers (Realtek(R) Audio)", "Headset Earphone (HyperX Cloud II)" ], "recordingDevices": [ "Microphone (USB Audio Device)" ] } ``` -------------------------------- ### Profile list JSON output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON array output for the profile --list --json command, showing profile details. ```json [ { "name": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingDevice": "Microphone (USB Audio Device)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ] ``` -------------------------------- ### Breaking change commit example Source: https://github.com/belphemur/soundswitch/blob/dev/docs/contributing.md Example of a breaking change commit that triggers a major release by appending `!` to the type. The footer must include the `BREAKING CHANGE:` note. ```text feat(api)!: change device switching API signature BREAKING CHANGE: The `SwitchDevice` method now requires a `DeviceType` enum parameter. ``` -------------------------------- ### Switch command JSON success output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for a successful switch command with --json. The 'type' field reflects the requested device type. ```json { "success": true, "type": "Playback" } ``` -------------------------------- ### Profile trigger JSON success output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for a successful profile trigger with --name and --json. ```json { "success": true, "profile": "Gaming" } ``` -------------------------------- ### Initialize and use MicrophoneMuteBannerManager Source: https://github.com/belphemur/soundswitch/blob/dev/docs/banner-manager.md Initializes the banner manager on the UI thread, creates an instance, and updates the mute state for a specific microphone. The Setup method must be called once on the UI thread before creating the manager. ```csharp // Must be called once on the UI thread MicrophoneMuteBannerManager.Setup(); // Create an instance of the manager var manager = new MicrophoneMuteBannerManager(); // Update mute state for a specific microphone manager.UpdateMicrophoneMuteState("mic-id-123", "USB Microphone", isMuted: true); ``` -------------------------------- ### Mute command JSON output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for a mute command with --json, showing the device name and mute state. ```json { "deviceName": "Microphone (USB Audio Device)", "isMuted": false } ``` -------------------------------- ### Status JSON output Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Example of the JSON output for the status --json command, showing active profile and device names. Note: 'Active Profile' shows the last profile explicitly triggered by a user action or trigger; it may not reflect changes made outside SoundSwitch. ```json { "activeProfile": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "recordingDevice": "Microphone (USB Audio Device)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ``` -------------------------------- ### Add fallback path in RegisterHotKey Source: https://github.com/belphemur/soundswitch/blob/dev/docs/hotkey-hybrid-hook-fallback.md Modified RegisterHotKey logic: on failure, removes the hotkey from the registered dictionary, adds it to the hook collection, starts the hook thread, and logs a warning. ```csharp lock (_instance) { return (bool)_instance.Invoke(() => { if (_instance._registeredHotkeys.ContainsKey(hotKey)) return false; var id = _instance._hotKeyId++; _instance._registeredHotkeys.Add(hotKey, id); if (NativeMethods.RegisterHotKey(_instance.Handle, id, (uint)hotKey.Modifier, (uint)hotKey.Keys)) return true; // FAILED: fallback to hook _instance._registeredHotkeys.Remove(hotKey); lock (_hookedHotkeys) { _hookedHotkeys.Add(hotKey); } EnsureHookThreadRunning(); Log.Warning("RegisterHotKey conflict for {hotkey}, using hook fallback", hotKey); return true; }); } ``` -------------------------------- ### Build and test SoundSwitch solution Source: https://github.com/belphemur/soundswitch/blob/dev/docs/contributing.md Build the solution to verify compilation, then run the test suite. Both commands use the Debug configuration. ```cmd dotnet build SoundSwitch.sln -c Debug ``` ```cmd dotnet test SoundSwitch.sln -c Debug ``` -------------------------------- ### SoundSwitch.CLI.exe --help Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Displays all available commands and their syntax. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe --help ``` -------------------------------- ### SoundSwitch.CLI.exe profile --list Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Lists all available audio profiles. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] profile --list ### Description Lists all available audio profiles. ### Command `SoundSwitch.CLI.exe profile --list` ### Parameters #### Options - `--list` (flag) - Required - List all available profiles. - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON array of profile objects, each with `name`, `playbackDevice`, `playbackCommunicationDevice`, `recordingDevice`, and `recordingCommunicationDevice` fields. - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json [ { "name": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingDevice": "Microphone (USB Audio Device)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ] ``` ``` -------------------------------- ### SoundSwitch.CLI.exe settings --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Opens the SoundSwitch settings window and prints the result as JSON. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe settings --json ``` -------------------------------- ### Run tests for SoundSwitch.Tests and SoundSwitch.Audio.Manager.Tests Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Runs the test projects for the main application and the audio manager. Execute from the repository root. ```cmd dotnet test SoundSwitch.Tests\SoundSwitch.Tests.csproj dotnet test SoundSwitch.Audio.Manager.Tests\SoundSwitch.Audio.Manager.Tests.csproj ``` -------------------------------- ### Build individual SoundSwitch projects Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Builds each project individually. The table lists the main application, audio manager, shared utilities, CLI, IPC, UI menu, and UI user controls projects. ```cmd dotnet build SoundSwitch\SoundSwitch.csproj ``` ```cmd dotnet build SoundSwitch.Audio.Manager\SoundSwitch.Audio.Manager.csproj ``` ```cmd dotnet build SoundSwitch.Common\SoundSwitch.Common.csproj ``` ```cmd dotnet build SoundSwitch.CLI\SoundSwitch.CLI.csproj ``` ```cmd dotnet build SoundSwitch.IPC\SoundSwitch.IPC.csproj ``` ```cmd dotnet build SoundSwitch.UI.Menu\SoundSwitch.UI.Menu.csproj ``` ```cmd dotnet build SoundSwitch.UI.UserControls\SoundSwitch.UI.UserControls.csproj ``` -------------------------------- ### Build All Projects (Debug) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Builds all projects in the solution with the Debug configuration. ```cmd dotnet build SoundSwitch.sln -c Debug ``` -------------------------------- ### List all available profiles Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use this command to list all available audio profiles. Requires SoundSwitch to be running. ```shell SoundSwitch.CLI.exe profile --list ``` -------------------------------- ### Open settings window Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use this command to open the SoundSwitch settings window. Requires SoundSwitch to be running. ```shell SoundSwitch.CLI.exe settings ``` -------------------------------- ### SoundSwitch.CLI.exe --version Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Displays the version of the CLI. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe --version ``` -------------------------------- ### SoundSwitch.CLI.exe profile --name "Gaming" Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Activates the specified audio profile. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] profile --name "Gaming" ### Description Activates the specified audio profile. ### Command `SoundSwitch.CLI.exe profile --name "Gaming"` ### Parameters #### Options - `--name` (string) - Required - Name of the profile to activate. - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `success` field (e.g., `{ "success": true }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### settings Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to open SoundSwitch settings. ```APIDOC ## SoundSwitch.CLI.exe settings ### Description Opens SoundSwitch settings. ### Command `SoundSwitch.CLI.exe settings [--json]` ### Parameters - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe settings --json ``` ### Response #### Success Response - `success` (boolean) - Indicates the settings were opened successfully. #### Response Example ```json { "success": true } ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### SoundSwitch.CLI.exe profile --list --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Lists all available audio profiles as JSON. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe profile --list --json ``` -------------------------------- ### Build SoundSwitch for Linux (compile-only) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-14-startup-order-setcolormode-fix.md Compile-only build for the Linux gate. Use this to verify the project builds without running it. The flags -p:LinuxBuild=true and -p:BuildProjectReferences=false are required. ```bash dotnet build SoundSwitch/SoundSwitch.csproj -c Debug -p:LinuxBuild=true -p:BuildProjectReferences=false ``` -------------------------------- ### Project structure tree Source: https://github.com/belphemur/soundswitch/blob/dev/website/AGENTS.md Shows the directory layout of the website/ folder, including src/.vuepress, scripts, worker, package.json, and wrangler.jsonc. ```text website/ ├── src/ │ ├── .vuepress/ │ │ ├── components/ # Global Vue components registered in client.ts │ │ ├── config.ts # VuePress site & theme configuration │ │ ├── client.ts # Client-side app enhancement (component registration) │ │ └── styles/ # Global SCSS overrides │ └── **/*.md # Documentation pages ├── scripts/ │ └── sync-changelog.mjs # Copies root CHANGELOG.md → src/changelog.md ├── worker/ # Cloudflare Worker entry point ├── package.json └── wrangler.jsonc ``` -------------------------------- ### SoundSwitch.CLI.exe profile --name "Gaming" Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Activates the "Gaming" audio profile. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe profile --name "Gaming" ``` -------------------------------- ### SoundSwitch.CLI.exe devices Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Lists devices selected for switching (active and selected in settings). The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe devices ``` -------------------------------- ### profile --list Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to list all available profiles. ```APIDOC ## SoundSwitch.CLI.exe profile --list ### Description Lists all available profiles. ### Command `SoundSwitch.CLI.exe profile --list [--json]` ### Parameters - `--list` (flag) - Required - Indicates to list profiles. - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe profile --list --json ``` ### Response #### Success Response - Array of profile objects, each containing: - `name` (string) - Profile name. - `playbackDevice` (string) - Playback device name. - `playbackCommunicationDevice` (string) - Playback communication device name. - `recordingDevice` (string) - Recording device name. - `recordingCommunicationDevice` (string) - Recording communication device name. #### Response Example ```json [ { "name": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingDevice": "Microphone (USB Audio Device)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ] ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### SoundSwitch.CLI.exe devices Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Lists devices that are both active and selected for switching in SoundSwitch settings. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] devices ### Description Lists devices that are both active and selected for switching in SoundSwitch settings. ### Command `SoundSwitch.CLI.exe devices` ### Parameters #### Options - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `playbackDevices` and `recordingDevices` arrays. - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "playbackDevices": [ "Speakers (Realtek(R) Audio)", "Headset Earphone (HyperX Cloud II)" ], "recordingDevices": [ "Microphone (USB Audio Device)" ] } ``` ``` -------------------------------- ### SoundSwitch.CLI.exe devices --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Lists switchable devices in machine-readable JSON. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe devices --json ``` -------------------------------- ### Switch to next recording device Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use this command to cycle to the next recording device. Requires SoundSwitch to be running. ```shell SoundSwitch.CLI.exe switch --type Recording ``` -------------------------------- ### Profile list commands Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md List all available profiles. The --json variant prints a JSON array of profile objects with fields 'name', 'playbackDevice', 'playbackCommunicationDevice', 'recordingDevice', and 'recordingCommunicationDevice'. ```shell SoundSwitch.CLI.exe profile --list SoundSwitch.CLI.exe profile --list --json ``` -------------------------------- ### Switch to next playback device Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use this command to cycle to the next playback device. Requires SoundSwitch to be running. ```shell SoundSwitch.CLI.exe switch --type Playback ``` -------------------------------- ### SoundSwitch.CLI.exe switch --type Playback Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Cycles to the next playback device. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] switch --type Playback ### Description Cycles to the next playback device. ### Command `SoundSwitch.CLI.exe switch --type Playback` ### Parameters #### Options - `--type` (string) - Required - Device type: `Playback` or `Recording`. - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `success` field (e.g., `{ "success": true }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Open settings commands Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Open SoundSwitch settings. The --json variant prints a success object on success and an error object on failure (exit code 1). ```shell SoundSwitch.CLI.exe settings SoundSwitch.CLI.exe settings --json ``` -------------------------------- ### SoundSwitch.CLI.exe status --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Shows active profile and current devices in machine-readable JSON. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe status --json ``` -------------------------------- ### SoundSwitch.CLI.exe switch --type Playback --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Cycles to the next playback device and prints JSON status. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe switch --type Playback --json ``` -------------------------------- ### GDI Reference-Counting Lifecycle Diagram Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.Common/Framework/Icon/AGENTS.md ASCII diagram of the GDI reference-counting lifecycle. Shows how CachedEntry wraps System.Drawing.Icon with a thread-safe refCount, how IconHandle increments it, and how Release() decrements it until zero triggers icon.Dispose(). ```text ┌────────────────────────────────────────────┐ │ CachedEntry (internal) │ │ • wraps System.Drawing.Icon (HICON) │ │ • thread-safe refCount (int) │ └────────────────────────────────────────────┘ ▲ ▲ cache holds │ refCount=1 │ refCount+1 per handle initial ref │ │ │ ┌───────────────┐ │ │ IconHandle │ ← caller must Dispose() │ └───────────────┘ │ (eviction callback) entry.Release() ──► refCount-- if refCount==0 ──► icon.Dispose() ``` -------------------------------- ### SoundSwitch.CLI.exe status Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Shows the active profile and current default audio devices. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] status ### Description Shows the active profile and current default audio devices (playback, recording, and communication). ### Command `SoundSwitch.CLI.exe status` ### Parameters #### Options - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `activeProfile`, `playbackDevice`, `recordingDevice`, `playbackCommunicationDevice`, and `recordingCommunicationDevice` fields. - `activeProfile` is `null` when no profile has been triggered since startup. - Device fields are empty strings (`""`) when no matching device is present. - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "activeProfile": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "recordingDevice": "Microphone (USB Audio Device)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ``` ``` -------------------------------- ### status Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to show active profile and current default audio devices. ```APIDOC ## SoundSwitch.CLI.exe status ### Description Shows the active profile and current default audio devices. ### Command `SoundSwitch.CLI.exe status [--json]` ### Parameters - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe status --json ``` ### Response #### Success Response - `activeProfile` (string) - The active profile name. - `playbackDevice` (string) - Current playback device name. - `recordingDevice` (string) - Current recording device name. - `playbackCommunicationDevice` (string) - Current playback communication device name. - `recordingCommunicationDevice` (string) - Current recording communication device name. Devices not present are serialized as empty strings (`""`). #### Response Example ```json { "activeProfile": "Gaming", "playbackDevice": "Speakers (Realtek(R) Audio)", "recordingDevice": "Microphone (USB Audio Device)", "playbackCommunicationDevice": "Headset Earphone (HyperX Cloud II)", "recordingCommunicationDevice": "Headset Microphone (HyperX Cloud II)" } ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### Run all tests in the solution Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Runs all tests in the solution using the Debug configuration. ```cmd dotnet test SoundSwitch.sln -c Debug ``` -------------------------------- ### SoundSwitch.CLI.exe switch --type Recording Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Cycles to the next recording device. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] switch --type Recording ### Description Cycles to the next recording device. ### Command `SoundSwitch.CLI.exe switch --type Recording` ### Parameters #### Options - `--type` (string) - Required - Device type: `Playback` or `Recording`. - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `success` field (e.g., `{ "success": true }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### devices Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to list devices that SoundSwitch will cycle through. ```APIDOC ## SoundSwitch.CLI.exe devices ### Description Lists devices that are both currently active and selected in SoundSwitch settings (i.e., devices SoundSwitch will cycle through). ### Command `SoundSwitch.CLI.exe devices [--json]` ### Parameters - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe devices --json ``` ### Response #### Success Response - `playbackDevices` (array of strings) - List of playback device names. - `recordingDevices` (array of strings) - List of recording device names. #### Response Example ```json { "playbackDevices": [ "Speakers (Realtek(R) Audio)", "Headset Earphone (HyperX Cloud II)" ], "recordingDevices": [ "Microphone (USB Audio Device)" ] } ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### SoundSwitch.CLI.exe status Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Shows active profile and current default audio devices. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe status ``` -------------------------------- ### SoundSwitch.CLI.exe mute --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Prints the current microphone mute state as JSON. ```APIDOC ## [CLI] mute --json ### Description Prints the current microphone mute state as JSON. ### Command `SoundSwitch.CLI.exe mute --json` ### Parameters #### Options - `--json` (flag) - Required - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `deviceName` and `isMuted` fields (e.g., `{ "deviceName": "...", "isMuted": false }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "deviceName": "...", "isMuted": false } ``` ``` -------------------------------- ### Full Release Workflow Source: https://github.com/belphemur/soundswitch/blob/dev/docs/building.md Full release workflow: cleans and publishes projects into Final, converts Markdown docs to HTML, bundles assets, and delegates to Build-Installer.ps1 for each selected architecture. ```powershell # Build from source and generate the installer (no publishing to GitHub) .\tools\Publish-Release.ps1 -BuildFromSource -Configuration Release ``` -------------------------------- ### switch Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to switch between recording or playback audio devices. ```APIDOC ## SoundSwitch.CLI.exe switch ### Description Switches between recording or playback audio devices. Supports human-readable and JSON output. ### Command `SoundSwitch.CLI.exe switch --type [--json]` ### Parameters - `--type` (string) - Required - The device type to switch to. Valid values: `Recording`, `Playback`. - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe switch --type Playback --json ``` ### Response #### Success Response - `success` (boolean) - Indicates the switch was successful. - `type` (string) - The device type that was switched to. #### Response Example ```json { "success": true, "type": "Playback" } ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### List devices commands Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md List devices that are both currently active and selected in SoundSwitch settings (i.e., devices SoundSwitch will cycle through). The --json variant prints a JSON object with 'playbackDevices' and 'recordingDevices' arrays; on failure prints an error object (exit code 1). ```shell SoundSwitch.CLI.exe devices SoundSwitch.CLI.exe devices --json ``` -------------------------------- ### Status commands Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Show active profile and current default audio devices. The --json variant prints a JSON object with fields 'activeProfile', 'playbackDevice', 'recordingDevice', 'playbackCommunicationDevice', and 'recordingCommunicationDevice'. Devices not present are serialized as empty strings. On failure, prints an error object and exits with code 1. ```shell SoundSwitch.CLI.exe status # Human-readable table output SoundSwitch.CLI.exe status --json # Machine-readable JSON output ``` -------------------------------- ### SoundSwitch.CLI.exe mute --json Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Prints the current microphone mute state as JSON. The CLI communicates with the main SoundSwitch process via IPC, so the main application should be running. ```bash SoundSwitch.CLI.exe mute --json ``` -------------------------------- ### DeviceChangeWording enum and updated BuildDefaultChanged signature Source: https://github.com/belphemur/soundswitch/blob/dev/docs/windows-notification-toast-refactor.md Adds an explicit wording selector so the single code path serves both channels. Banner uses SettingsStrings.tooltipOnHover_option_playbackDevice/_recordingDevice; WindowsNotification uses TrayIconStrings.playbackChanged/recordingChanged. ```csharp internal enum DeviceChangeWording { Banner, WindowsNotification } internal static BannerData BuildDefaultChanged(DeviceFullInfo device, DeviceChangeWording wording); ``` -------------------------------- ### Startup crash stack trace for SetCompatibleTextRenderingDefault Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-14-startup-order-setcolormode-fix.md The exact exception stack trace observed on nightly 7.3.3.27 at startup on a dark-mode Windows 11 machine. The process terminates before any UI or tray icon appears. ```text System.InvalidOperationException: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application. at System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(Boolean defaultValue) at SoundSwitch.Program.OldMain(String[] args) in SoundSwitch/Program.cs:line 131 at SoundSwitch.Program.Main(String[] args) in SoundSwitch/Program.cs:line 54 ``` -------------------------------- ### Namespace audit grep for Application.* and theme APIs Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-03-dark-theme-winforms.md Namespace audit command to verify that every Application.* call has the System.Windows.Forms namespace reachable. Run on Linux because CsWinRT prebuild blocks dotnet build on that host. ```bash grep -nE 'Application\.|SetColorMode|SystemColorMode|Invalidate|RefreshTheme' \ SoundSwitch/Program.cs \ SoundSwitch/UI/Forms/Settings.cs \ SoundSwitch/UI/Component/IconTextComboBox.cs \ SoundSwitch/UI/Component/TextProgressBar.cs ``` -------------------------------- ### Enable system color mode with Application.SetColorMode in Program.cs Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-03-dark-theme-winforms.md Place this line in Program.cs after Application.EnableVisualStyles() and before Application.Run(appContext). SystemColorMode.System (enum value 1) makes every form created after this call follow the OS AppsUseLightTheme registry value. This automatically repaints standard controls and sets the DWM immersive dark mode attribute on the top-level window (Win11 only). ```csharp Application.SetColorMode(SystemColorMode.System); ``` -------------------------------- ### Switch audio device commands Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Switch between recording or playback devices. The --json variant prints a success object with 'success' and 'type' fields, or an error object on failure (exit code 1). ```shell SoundSwitch.CLI.exe switch --type Recording SoundSwitch.CLI.exe switch --type Playback SoundSwitch.CLI.exe switch --type Playback --json ``` -------------------------------- ### SoundSwitch.CLI.exe mute --toggle Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Toggles the microphone mute state. Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] mute --toggle ### Description Toggles the microphone mute state. ### Command `SoundSwitch.CLI.exe mute --toggle` ### Parameters #### Options - `--toggle` (flag) - Required - Toggle the mute state. - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `deviceName` and `isMuted` fields (e.g., `{ "deviceName": "...", "isMuted": false }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "deviceName": "...", "isMuted": false } ``` ``` -------------------------------- ### NotificationContentBuilder proposed method signatures Source: https://github.com/belphemur/soundswitch/blob/dev/docs/windows-notification-toast-refactor.md Proposed internal static methods returning BannerData for default device change, profile change, app rule matched, and microphone mute changed notifications. Each fills Title, Text, Image, and Priority, leaving Position/Ttl/Opacity/DisplayInfo to the caller. ```csharp internal static BannerData BuildDefaultChanged(DeviceFullInfo device); internal static BannerData BuildProfileChanged(Profile.Profile profile, Bitmap icon); internal static BannerData BuildAppRuleMatched(DeviceFullInfo playback, DeviceFullInfo recording, Bitmap icon); internal static BannerData BuildMicrophoneMuteChanged(string microphoneName, bool newMuteState); ``` -------------------------------- ### Add hook infrastructure fields Source: https://github.com/belphemur/soundswitch/blob/dev/docs/hotkey-hybrid-hook-fallback.md Initializes fields for tracking hooked hotkeys and the hook infrastructure. The static delegate field prevents garbage collection. ```csharp private static readonly HashSet _hookedHotkeys = new(); private static IntPtr _hookHandle = IntPtr.Zero; private static Thread _hookThread; private static LowLevelKeyboardProc _hookProc; // static field prevents GC collection ``` -------------------------------- ### TelemetryService Class Diagram (ASCII Art) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/TELEMETRY_DESIGN.md ASCII diagram of the TelemetryService class showing its static fields, Reload method, and all tracking methods that emit metrics or breadcrumbs. It lists the metric type (Counter or Distribution) for each tracking method. ```text ┌─────────────────────────────────────────────────────┐ │ TelemetryService │ │ static volatile bool _enabled │ │ static void Reload() ← called on settings │ │ static bool IsEnabled() │ │ │ │ TrackPlaybackSwitch(trigger) → Metrics.Counter │ │ TrackRecordingSwitch(trigger) → Metrics.Counter │ │ TrackMicMute(trigger, muted) → Metrics.Counter │ │ TrackProfileActivated(…) → Metrics.Counter │ │ TrackProfileCreated() → Metrics.Counter │ │ TrackProfileDeleted() → Metrics.Counter │ │ TrackProfileActivationFailed(…) → Metrics.Counter │ │ TrackAppRuleActivated(string processBasename, string triggerSource) → Metrics.Counter │ │ TrackAppRuleCreated() → Metrics.Counter │ │ TrackAppRuleDeleted() → Metrics.Counter │ │ TrackNotificationBanner(…) → Metrics.Counter │ │ TrackNotificationWindows() → Metrics.Counter │ │ TrackNotificationSound() → Metrics.Counter │ │ TrackUpdateMode(mode) → Metrics.Counter │ │ TrackUpdateCheck(trigger) → Metrics.Counter │ │ TrackUpdateAvailable(mode) → Metrics.Counter │ │ TrackUpdateInstalled(mode, result) → Metrics.Counter │ │ TrackUpdatePostponed() → Metrics.Counter │ │ TrackSetting(name, value) → Metrics.Counter │ │ TrackProfileCount(count) → Metrics.Distribution │ │ TrackAppRuleCount(count) → Metrics.Distribution │ │ TrackCliCommand(cmd, exitCode) → Metrics.Counter │ │ TrackDevicesEnumerated(type, count) → Metrics.Distribution │ │ │ │ Breadcrumb(category, message) → AddBreadcrumb │ └─────────────────────────────────────────────────────┘ ``` -------------------------------- ### Add P/Invoke imports for hook (Interop.cs) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/hotkey-hybrid-hook-fallback.md Adds P/Invoke imports for the low-level keyboard hook and module handle retrieval. Required for the fallback mechanism when RegisterHotKey fails. ```csharp internal static class NativeMethods { // Low-level keyboard hook [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool UnhookWindowsHookEx(IntPtr hhk); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] internal static extern IntPtr GetModuleHandle(string lpModuleName); } ``` -------------------------------- ### Show current audio status Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use these commands to display the current audio status, with optional JSON output for machine-readable format. ```shell SoundSwitch.CLI.exe status SoundSwitch.CLI.exe status --json ``` -------------------------------- ### Trigger a specific profile Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Use this command to apply a specific profile by name. The profile name must be valid; invalid names produce an error. ```shell SoundSwitch.CLI.exe profile --name "Headphones + Mic" ``` -------------------------------- ### TelemetryService Enabled Gate and TrackPlaybackSwitch Source: https://github.com/belphemur/soundswitch/blob/dev/docs/TELEMETRY_DESIGN.md Shows the enabled gate pattern: a volatile _enabled field, Reload() reading AppConfigs.Configuration.Telemetry, and EnsureEnabled() as a no-op guard. TrackPlaybackSwitch calls EnsureEnabled then emits a Counter metric. Reload is called on startup and when settings save; no Sentry reinitialization is needed because AutoSessionTracking is set once at startup. ```csharp public static class TelemetryService { private static volatile bool _enabled; public static void Reload() { _enabled = AppConfigs.Configuration.Telemetry; } private static void EnsureEnabled() { if (!_enabled) return; // no-op } public static void TrackPlaybackSwitch(string trigger) { EnsureEnabled(); SentrySdk.Metrics.Counter("soundswitch.playback.switched", 1, new Dictionary { ["trigger"] = trigger }); } } ``` -------------------------------- ### Theme-aware OutlineColor and PenLine in SettingsForm Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-03-dark-theme-winforms.md Theme-aware replacement for the outline pen. Uses WindowsThemeHelper.IsDarkModeEnabled() to choose dark grey (80,80,80) on dark backgrounds or Gainsboro otherwise. Also requires overriding OnSystemColorsChanged on SettingsForm to repaint when the OS theme flips. ```csharp private static Color OutlineColor => WindowsThemeHelper.IsDarkModeEnabled() ? Color.FromArgb(80, 80, 80) // dark grey on dark bg : Color.Gainsboro; private static Pen PenLine(int width = 1) => new(OutlineColor, width); ``` -------------------------------- ### SoundSwitch.CLI.exe mute --state false Source: https://github.com/belphemur/soundswitch/blob/dev/website/src/usage/cli.md Sets the microphone mute state to false (unmute). Optionally accepts --json for machine-readable output. ```APIDOC ## [CLI] mute --state false ### Description Sets the microphone mute state to false (unmute). ### Command `SoundSwitch.CLI.exe mute --state false` ### Parameters #### Options - `--state` (boolean) - Required - Mute state to set (e.g., `false` for unmute). - `--json` (flag) - Optional - Output in JSON format. ### Response #### Success Response - On success, prints a JSON object with `deviceName` and `isMuted` fields (e.g., `{ "deviceName": "...", "isMuted": false }`). - On failure in JSON mode, prints `{ "error": "..." }` and exits with code 1. #### Response Example ```json { "deviceName": "...", "isMuted": false } ``` ``` -------------------------------- ### profile --name Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Command to trigger a specific profile by name. ```APIDOC ## SoundSwitch.CLI.exe profile --name ### Description Triggers a specific profile by name. ### Command `SoundSwitch.CLI.exe profile --name "" [--json]` ### Parameters - `--name` (string) - Required - The name of the profile to trigger. - `--json` (flag) - Optional - Outputs the result as JSON. ### Request Example ```shell SoundSwitch.CLI.exe profile --name "Gaming" --json ``` ### Response #### Success Response - `success` (boolean) - Indicates the profile was triggered successfully. - `profile` (string) - The name of the triggered profile. #### Response Example ```json { "success": true, "profile": "Gaming" } ``` #### Error Response - `error` (string) - Description of the failure. #### Error Example ```json { "error": "Failed to retrieve status" } ``` Exit code 1 on failure. ``` -------------------------------- ### Original PenLine and RectOutline in SettingsForm Source: https://github.com/belphemur/soundswitch/blob/dev/docs/design/ui/2026-09-03-dark-theme-winforms.md Original outline pen and rectangle helper from Settings.cs:82-87. Uses hardcoded Color.Gainsboro for the outline border on the playback/recording/profiles preview pane, which becomes near-invisible on dark backgrounds. ```csharp private static Pen PenLine(int width = 1) => new(Color.Gainsboro, width); private static Rectangle RectOutline(int offsetW, int offsetH, Control topLeft, Control bottomRight) => ...; ``` -------------------------------- ### Sentry SDK Metrics API Signatures (Counter, Distribution, Gauge) Source: https://github.com/belphemur/soundswitch/blob/dev/docs/TELEMETRY_DESIGN.md Shows the Sentry SDK 6.9.0 API for emitting Counter, Distribution, and Gauge metrics. Metrics are GA and available directly on SentrySdk.Metrics without the Experimental prefix. Supported value types are byte, short, int, long, float, double; attributes accept string, bool, and numeric types up to 64-bit. ```csharp // Counter — record one occurrence SentrySdk.Metrics.EmitCounter("soundswitch.playback.switched", 1, new KeyValuePair("trigger", "hotkey")); // Distribution — record a numeric value with optional unit SentrySdk.Metrics.EmitDistribution("soundswitch.devices.count", 3, MeasurementUnit.None, new KeyValuePair("device_type", "playback")); // Gauge — snapshot a value SentrySdk.Metrics.EmitGauge("soundswitch.queue.depth", 5, MeasurementUnit.None, new KeyValuePair("queue", "profile_activation")); ``` -------------------------------- ### Trigger profile command Source: https://github.com/belphemur/soundswitch/blob/dev/SoundSwitch.CLI/README.md Trigger a specific profile by name. With --name and --json, on success prints a JSON object with 'success' and 'profile' fields; on failure prints an error object (exit code 1). ```shell SoundSwitch.CLI.exe profile --name "Profile Name" ``` -------------------------------- ### Improve Power Resume Handling with WM_POWERBROADCAST Source: https://github.com/belphemur/soundswitch/blob/dev/docs/hotkey-hybrid-hook-fallback.md Add WM_POWERBROADCAST handling in WndProc as a more reliable companion to SystemEvents.PowerModeChanged. On PBT_APMRESUMEAUTOMATIC, it dispatches ReRegisterAllHotkeys via BeginInvoke to re-register RegisterHotKey hotkeys; hook-based hotkeys survive sleep automatically. ```csharp private const int WM_POWERBROADCAST = 0x0218; private const int PBT_APMRESUMEAUTOMATIC = 0x0012; // In WndProc, before base.WndProc: case WM_POWERBROADCAST: if (m.WParam.ToInt32() == PBT_APMRESUMEAUTOMATIC) { BeginInvoke((Action)ReRegisterAllHotkeys); } break; private void ReRegisterAllHotkeys() { // Take a thread-safe snapshot of registered hotkeys var hotkeysSnapshot = _registeredHotkeys.ToArray(); // Re-register RegisterHotKey hotkeys (hook-based survive sleep automatically) foreach (var (hotKey, hotKeyId) in hotkeysSnapshot) { NativeMethods.UnregisterHotKey(_instance.Handle, hotKeyId); NativeMethods.RegisterHotKey(_instance.Handle, hotKeyId, (uint)hotKey.Modifier, (uint)hotKey.Keys); } } ```