From nobody Tue May 3 19:36:25 2022 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1BA831AA832E for ; Tue, 3 May 2022 19:58:40 +0000 (UTC) (envelope-from mazen@illumed.net) Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kt9kk6XFhz4b4V for ; Tue, 3 May 2022 19:58:38 +0000 (UTC) (envelope-from mazen@illumed.net) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Kt9kb12Lfz9sw7 for ; Tue, 3 May 2022 21:58:31 +0200 (CEST) From: Mazin Fadl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illumed.net; s=MBO0001; t=1651607909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=N//CO4nnFC5n3HlsSg/UBfUB/hpnfw84qrUT6u8Gvcw=; b=BvVAhaw1WfCXm9WUuwmFy/wO9DF3YsocJkPhma3V6jfj0TzrLxR0s7hp6mJhxmIKPmrvGp JOpdvko9vOa4DdrENLIaFVGo2Qo9W0Jro/Ve2dzlxOrlhI4bEEPBMbjlcKQLKYzB5QbIed dNtgo3uit+pkrj4UT0H84cfKToNZ0V3gan5pwlRMUFFMvq2qMLx30cxKRtbE3eY+mfw05k 3fJrhRkvpKlHyc0apWuc5t5ADJh/Ik9r7wSDw92km6wssn/ehO/GIv4cchmbLFUgdTwkY2 xErymJ9+Zb5+7oaUp/kNCaYY6qBvLFQCk/Uwp2viU77LN7QrXEPY8TZtE8LK8g== To: freebsd-questions@freebsd.org Subject: get uaudio pcm/mixer device name using devd Date: Tue, 03 May 2022 15:36:25 -0400 Message-ID: <8635hq1j8c.fsf@mars.illumed.net> List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 4Kt9kk6XFhz4b4V X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=illumed.net header.s=MBO0001 header.b=BvVAhaw1; dmarc=pass (policy=none) header.from=illumed.net; spf=pass (mx1.freebsd.org: domain of mazen@illumed.net designates 80.241.56.172 as permitted sender) smtp.mailfrom=mazen@illumed.net X-Spamd-Result: default: False [-4.10 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[illumed.net:s=MBO0001]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:80.241.56.0/21]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[illumed.net:+]; DMARC_POLICY_ALLOW(-0.50)[illumed.net,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MLMMJ_DEST(0.00)[freebsd-questions]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:199118, ipnet:80.241.56.0/21, country:DE]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[80.241.56.172:from] X-ThisMailContainsUnwantedMimeParts: N Hi all, Using devd, is it possible to pass through to an action the pcm/mixer device name created when a usb audio device is attached? My objective is to set the default sound device to a specific usb audio device, which can't be hardcoded via sysctl 'hw.snd.default_unit' due to device order switching with multiple usb audio devices. I have a working configuration using the following devd.conf: notify 100 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "ATTACH"; match "vendor" "0x040d"; match "product" "0x340b"; action "/etc/set_usb_audio.sh"; }; and in set_usb_audio.sh: #!/bin/sh # get our preferred mixer cardnumber=$(mixer -a | grep -F 'snd_uaudio (play)' | grep -o '[[:digit:]]\+') if [ -n "$cardnumber" ]; then logger set_usb_audio.sh: found usb audio playback on dsp$cardnumber # set default audio card mixer -d "$cardnumber" >/dev/null # unmute our FX-AUDIO dac mixer -f /dev/mixer"$cardnumber" pcm2=1 >/dev/null fi mixer -a doesn't print the usb product names for my devices, its output is generic, like: pcm12:mixer: at ? kld snd_uaudio (play) ... pcm13:mixer: at ? kld snd_uaudio (rec) which makes my current matching method broad, hence the question about passing through the pcm/mixer device name variable from devd. Thanks, mazin