Skip to content

Enhancement: Add tray icon option to use Windows' own volume icons - #129

Merged
G-Stas merged 7 commits into
G-Stas:mainfrom
ElektroStudios:feature/system-volume-tray-icons
Nov 4, 2026
Merged

G-Stas merged 7 commits into
G-Stas:mainfrom
ElektroStudios:feature/system-volume-tray-icons

Conversation

@ElektroStudios

@ElektroStudios ElektroStudios commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds a fourth value to the Tray icon setting (General page): Windows volume icons. With it, the tray shows the glyphs of Windows' own volume icon instead of Volumey's, for the same states (high, mid, low, zero, mute, no device). The glyphs are read from the system file at runtime, so a set that has been patched on the PC (customized volume icons) shows up in the tray as well.

I use customized system volume icons and wanted Volumey to keep showing them. A "pick your own icon" option seemed far too complicated, so this reuses what Windows already has.

General page with the new tray icon option

Tray icon following the volume with a customized icon set

How

  • TrayIconKind.SystemIcons is the new setting value (saved as "TrayIcon": "SystemIcons"), added to AppBehaviorViewModel.TrayIcons. The settings list stays a plain combo box.
  • New TrayIconConverter.SystemIconProvider, a TrayIconProvider like the light and dark ones. It reads each glyph once (also when it fails) with IconHelper.GetFromDll, using a negative index, which ExtractIconEx treats as a resource ID.
  • The file is %windir%\SystemResources\SndVolSSO.dll.mun (the folder comes from Environment.SpecialFolder.Windows). The icons are in that file, not in System32\SndVolSSO.dll.
  • The resource IDs are in one table, SystemIconProvider.ResourceIds. Tested on Windows 10:
State Resource ID
Mute 120
Zero 121
Low 122
Mid 123
High 124
No device 125
  • Windows has its own glyph for a volume of zero, which Volumey's own set doesn't, so there is a new IconType.Zero. Pick returns it only for this option; the other options behave as before (zero is still "low").
  • The system glyphs have their colors already, so the theme isn't used with them.
  • If a glyph can't be read (file or icon missing), the converter falls back to Volumey's own glyph of that state, in the theme's color (zero maps to low), so the tray never goes empty. The failure is logged once.
  • New string TrayIcon_SystemIcons in every .resx. The translations are mine, not native; please check them if you have someone for those languages.

Tests

  • Pick: same glyph as the volume level option, except Zero for a volume of zero.
  • The resource table covers every state, with different IDs.
  • The converter sends each system glyph only when it changes, ignores the theme, and switching back to Volumey's glyph updates the tray.
  • The converter falls back to Volumey's glyph when the system one is missing.
  • The real file: every state's icon is read (inconclusive when the file doesn't exist).
  • TrayIcons offers every TrayIconKind value; the choice is saved and read at start and loaded from settings.json.
  • EveryLanguageTranslatesEveryString already covers the new string in all languages.

Tested on

Only Windows 10, with the default icons and with a customized set. I haven't been able to check it on Windows 11.

The small icon from ExtractIconEx is used, not the exact tray size the app icon gets in ReadIconOfSize. If you want that for the system icons too, that needs a change on top.

Windows 11

If the icons are somewhere else there, only these need to change, in SystemIconProvider.cs:

  • ResourceFileName (now SndVolSSO.dll.mun, in %windir%\SystemResources) if the file has another name or location there.
  • ResourceIds, the icon group ID of each state.

To find them, open C:\Windows\SystemResources\SndVolSSO.dll.mun in Resource Hacker (look at the Icon Group entries as shown in this screenshot). Then run the tests: EveryVolumeStateHasASystemIconResource checks the table and TheSystemIconsAreReadFromWindowsFile checks that the real file gives an icon for every state.

Feel free to change anything on top of my branch.

Add a "Windows volume icons" value to the tray icon setting. It shows the
glyphs of Windows' own volume icon (read from SndVolSSO) in place of
Volumey's, following the volume, mute and no-device states, so a
customized set keeps showing in the tray.

- TrayIconKind.SystemIcons, offered in the General page's tray icon box
- SystemIconProvider reads the icons by resource ID from
  SystemResources\SndVolSSO.dll.mun, or System32\SndVolSSO.dll when
  there is no .mun file
- IconType.Zero: Windows has its own glyph for a volume of zero; it is
  only used by this option
- a glyph missing from the file falls back to Volumey's own
- strings added to all language resources
- tests for the glyph picking, the converter, the resource table, the
  settings and the real file
@ElektroStudios ElektroStudios changed the title Feature/system volume tray icons Add tray icon option to use Windows' own volume icons Oct 31, 2026
@ElektroStudios ElektroStudios changed the title Add tray icon option to use Windows' own volume icons Enhancement: Add tray icon option to use Windows' own volume icons Oct 31, 2026
@G-Stas

G-Stas commented Nov 2, 2026

Copy link
Copy Markdown
Owner

The icons are actually in the same place in Windows 11. How about we just replace old VolumeLevel mode with your new one? Don't see much point in the old one

@ElektroStudios

Copy link
Copy Markdown
Contributor Author

The icons are actually in the same place in Windows 11. How about we just replace old VolumeLevel mode with your new one? Don't see much point in the old one

I'd keep both, since they give the user a choice of look:

  • VolumeLevel is Volumey's own glyph set, drawn in the taskbar's light/dark colors.
  • Windows volume icons are the system's own icons.

Someone who likes Volumey's look keeps it, and someone who wants the tray to match Windows (or their patched icons) can pick that. Honestly, I believe it would be a mistake to remove/reduce the customization options available to the end user.

That said, if you still prefer a single mode, I can replace VolumeLevel and keep Volumey's glyphs only as a fallback for when the system file can't be read for any reason. In that case, there is one thing to decide first: the system icons are read with ExtractIconEx, which returns the small icon of the resource, not one at the exact tray size like the app icon gets in ReadIconOfSize.

Which would you prefer?

  1. Keep the small icon as it is now, and just replace VolumeLevel with the system icons.
  2. Read the system icons at the exact tray size too, then replace VolumeLevel.

I'm happy to do either on this branch.

@G-Stas

G-Stas commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Let’s add yours as a separate mode for now, maybe I'll remove the old mode later.

Two things to change:

  • Read the icons at the exact tray size. ExtractIconEx only gives the 16 px frame, which gets blurry at 125% scale and up; PrivateExtractIcons(path, -id, size, size, …) gives the right one.
  • The system volume icons are white only, so they’re almost invisible on a light theme taskbar. It needs to be handled to actually match Windows volume icons (they change to dark)

@ElektroStudios

ElektroStudios commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Sharing this icon here for reference, it may be useful in the future: a test icon with frames of 64, 48, 40, 32, 28, 24, 20 and 16 px, each one showing its own size as a number, so it's easy to check which frame Windows gives at each DPI scale.

volume-icon-sizes-test.zip

Preview:
WinSnap 03

I'll test the changes in a couple of hours in my environment and report back after committing.

@ElektroStudios

ElektroStudios commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed a5bf657. The system icons are now read with PrivateExtractIcons at the tray's size (the same size the app icon uses), instead of ExtractIconEx's small icon. It's kept as a separate mode, as you suggested.

I added tests for the size read from a file and for the converter's glyph choice.

I tested it with the numbered icon above at different display scales. On my Windows 10, the tray shows:

  • 16 px at 100%
  • 20 px at 125%
  • 24 px at 150%
  • 28 px at 175%
bandicam.2026-11-03.10-39-57-641_new.mp4

One thing I noticed: the tray icon size is read once, when the icon is first loaded, so changing the display scale while Volumey is running isn't followed. That already happens with the app icon, so I left it out of this PR. It could be handled in another one.

@G-Stas

G-Stas commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Seems ok, but on a light taskbar the no-device icon stays white (red badge fails the white check)t. Windows darkens just the speaker and keeps the badge. Suggestion: treat pixels whose channels differ by ≥ 0x40 as colored, flood-fill from the edge through non-colored pixels, invert only what the fill reaches.
image

@ElektroStudios

Copy link
Copy Markdown
Contributor Author

Suggestion: treat pixels whose channels differ by ≥ 0x40 as colored, flood-fill from the edge through non-colored pixels, invert only what the fill reaches.

Thanks, done in 9b6f833. On a light taskbar, only what a flood fill reaches from the edge through pixels without a color of their own (channels within 0x40) is inverted, so the red badge of the no-device icon and what it encloses should keep their colors. I added tests with a white glyph that has a red badge with a white dot inside.

I also tested it locally with a custom icon for a muted device: badge-glyph-test.zip

The following image is a representation, not a screenshot, of the result on a dark taskbar (left) and a light taskbar (right). The real result is practically the same.

badge-preview

One addition on top of the suggestion: the fill result is only inverted if it is white, so a custom gray or black icon is left as it is, instead of turning white on a light taskbar.

@G-Stas

G-Stas commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Nice! Mostly ready to merge then, needs merging actual main and after merging: #131 re-runs the tray binding on a scale change, but the system icons are cached per state at the first size, so they stay blurry. Keep one dark/light SystemIconProvider pair per tray size (a Dictionary<int, (Dark, Light)> keyed by getTraySize()), created with type => LoadFromSystem(type, size); a new size then gives a new provider, and your currentIconProvider != systemProvider check sends the icon again.

G-Stas
G-Stas previously approved these changes Nov 4, 2026
@ElektroStudios

ElektroStudios commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Implemented the per-size system icon cache.

TrayIconConverter now keeps a dark/light SystemIconProvider pair in a dictionary keyed by the tray icon size. Each pair loads the system glyphs at that specific size using LoadFromSystem(type, size).

When the display scale changes, #131 triggers the tray binding again. The converter detects the new size, creates a new provider pair and sends the correctly sized icon to the tray. Previously used sizes reuse their cached providers.

I've also added a test covering provider creation on a new size and reuse when switching back to a previously cached size.

✅ I tested DPI scaling changes on Windows 10 while Volumey is running to verify that the system icons automatically adjust to the correct size at each scale. Used icon from: #129 (comment)

Note: The two UI test failures on commit 80a2c67 were transitory and unrelated to my changes: one was an OSD binding error during test cleanup, and the other was a failure to open the Sound Control Panel. Both tests passed in the subsequent run without any code changes.

@G-Stas

G-Stas commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Awesome, thank you very much

@G-Stas
G-Stas merged commit 0186b94 into G-Stas:main Nov 4, 2026
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.

2 participants