summaryrefslogtreecommitdiff
path: root/content/2023
diff options
context:
space:
mode:
authord-s <ds@voyager.local>2023-03-16 22:55:32 +0100
committerd-s <ds@voyager.local>2023-03-16 22:55:32 +0100
commit026106d34a696c565eff4a853361c9c4c5ead2fe (patch)
tree6b8912e54f95ce441314f592907a5a54bf8ffb5c /content/2023
parentbdb81a0888041b2278529bcfca7d7f9948719c0d (diff)
feat: article for 2023-03-16
Diffstat (limited to 'content/2023')
-rw-r--r--content/2023/switching-between-speakers-and-headphones-on-freebsd.md51
1 files changed, 51 insertions, 0 deletions
diff --git a/content/2023/switching-between-speakers-and-headphones-on-freebsd.md b/content/2023/switching-between-speakers-and-headphones-on-freebsd.md
new file mode 100644
index 0000000..0555169
--- /dev/null
+++ b/content/2023/switching-between-speakers-and-headphones-on-freebsd.md
@@ -0,0 +1,51 @@
+---
+title: "Switching Between Speakers and Headphones on FreeBSD"
+category: "software"
+abstract: How to change the audio device?
+date: 2023-03-16T22:52:01+01:00
+year: 2023
+draft: false
+tags:
+- FreeBSD
+- headphones
+- speakers
+- ThinkPad
+- audio
+- tutorial
+---
+I want my laptop to switch to wired headphones when I attach them. FreeBSD has its own [Sound System](https://wiki.freebsd.org/Sound), so it's a great learning experience. I have yet to automate it (it is possible, but an attempt to do so forced me to do a complete rollback of the system state), but for now, this is working.
+
+First, check which audio outputs your device supports:
+
+```
+$ cat /dev/sndstat
+```
+
+In the case of my ThinkPad, this returns
+
+```
+Installed devices:
+pcm0: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm1: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm2: <NVIDIA (0x0094) (HDMI/DP 8ch)> (play)
+pcm3: <Conexant (0x1f86) (Analog)> (play/rec) default
+pcm4: <Conexant (0x1f86) (Left Analog Headphones)> (play)
+No devices installed from userspace.
+```
+
+The ones I care about are:
+pcm3 - the speakers
+pcm4 - the headphone jack
+
+I can now easily switch between them:
+
+```
+# enable speakers
+$ sysctl hw.snd.default_unit=3
+# enable headphones
+$ sysctl hw.snd.default_unit=4
+```
+
+(replace the value with the correct id from `sndstat` file.)
+
+This, however, comes with a huge caveat. Some apps (khem khem, Firefox) not native to FreeBSD come configured with PulseAudio instead of FreeBSD's Sound System. This creates a level of indirection, and changing system output may not work instantly. In the case of Firefox, I need to reload the tab. Some apps, as I've heard, require a restart.