wpctl: Allow virtual nodes in set-default command

Use prefix matching instead of exact matching for media.class when
validating nodes in the set-default command. This allows virtual
nodes (e.g. Audio/Source/Virtual) to be set as default devices,
while still excluding internal nodes.

Fixes #896

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
George Kiagiadakis 2026-01-26 12:39:17 +02:00
parent 80842cbb96
commit 024f88322c

View file

@ -870,7 +870,8 @@ set_default_run (WpCtl * self)
media_class = wp_pipewire_object_get_property (WP_PIPEWIRE_OBJECT (proxy),
PW_KEY_MEDIA_CLASS);
for (guint i = 0; i < G_N_ELEMENTS (DEFAULT_NODE_MEDIA_CLASSES); i++) {
if (!g_strcmp0 (media_class, DEFAULT_NODE_MEDIA_CLASSES[i])) {
if (g_str_has_prefix (media_class, DEFAULT_NODE_MEDIA_CLASSES[i]) &&
!g_str_has_suffix (media_class, "/Internal")) {
gboolean res = FALSE;
const gchar *name = wp_pipewire_object_get_property (
WP_PIPEWIRE_OBJECT (proxy), PW_KEY_NODE_NAME);