summaryrefslogtreecommitdiff
path: root/drafts/dell-dock.php
diff options
context:
space:
mode:
Diffstat (limited to 'drafts/dell-dock.php')
-rw-r--r--drafts/dell-dock.php102
1 files changed, 102 insertions, 0 deletions
diff --git a/drafts/dell-dock.php b/drafts/dell-dock.php
new file mode 100644
index 0000000..4a9dd9a
--- /dev/null
+++ b/drafts/dell-dock.php
@@ -0,0 +1,102 @@
+<h1>Make Your Docking Station Work for You (on FreeBSD)</h1>
+
+<p class="description">
+ I have a Dell Latitude E-series laptop running FreeBSD 12.2-RELEASE. I also
+ have a Dell E-Port II docking station on my desk. I wanted to be able to take
+ my shut, sleeping laptop and plop it down on the docking station, hit the dock
+ power button, and have the laptop wake up and switch over to all of the
+ docking station peripherals. So I did it! And now I'm going to write about it
+ so I don't forget how. You need to know a little bit about FreeBSD
+ <code>sysctl</code> knobs, display outputs in X, sound devices, and
+ <code>ifconfig</code> networking.
+</p>
+
+<h2>Switching from Ethernet to WiFi and Back Again, Seamlessly</h2>
+
+<p>
+ FreeBSD doesn't magically swap from wireless to wired connections by default,
+ but there's an easy way to remedy this: link failover. I recommend reading the
+ <a href="https://www.freebsd.org/doc/handbook/network-aggregation.html"
+ >FreeBSD handbook page on network aggregation</a
+ >
+ as it's where I found out about link aggregation and failover. Basically,
+ aggregation lets you bind two of your network interfaces together into a
+ single virtual interface. Failover lets your traffic continue moving as long
+ as one of the aggregated interfaces has is connected.
+ Here's what I had to do:
+</p>
+
+<ol>
+ <li>
+ Bind the wireless network interface (wlan0) to the MAC address of the wired
+ interface (em0)
+ </li>
+ <li>Create a lagg interface using the two network interfaces</li>
+ <li>Bind the lagg interface to an IP address, preferably with DHCP</li>
+</ol>
+
+<p>All of this is configured in my <code>rc.conf</code>:</p>
+
+<pre><code>
+wlans_iwn0="wlan0" # <- wlan0 device should use the iwn driver
+ifconfig_wlan0="WPA" # <- wlan0 should use WPA (wpa_supplicant) to connect to wireless SSIDs
+create_args_wlan0="wlanaddr 5c:26:0a:06:c1:d6" # <- wlan0 MAC address is set to em0 device MAC address
+ifconfig_em0="up" # <- enable em0 (ethernet) device
+cloned_interfaces="lagg0" # <- create cloned interface lagg0
+ifconfig_lagg0="up laggproto failover laggport em0 laggport wlan0 DHCP" # <- configure lagg0 interface to act as a failover lagg protocol over em0 and wlan0
+</code></pre>
+
+<p>
+ In practice, the preferred device is <code>em0</code>, or my ethernet NIC.
+ FreeBSD will always try to use that first. If it's disconnected, such as when
+ the laptop is removed from the dock, the wireless device (<code>wlan0</code>)
+ will take over. This transition happens instantly, and without interrupting
+ traffic; active transactions aren't cut short for example.
+</p>
+
+<h2>Sleeping on Lid Close Except When Docked</h2>
+
+<p>
+ This is an easy one. You can use <code>sysctl</code> to configure what happens
+ when a laptop lid is closed. I wanted the lid closing while undocked to
+ suspend (put the laptop to sleep). When it's docked however, I don't use the
+ internal display and wanted to be able to shut the lid and leave it shut. If you read <code>ACPI(4)</code> in the manual, you'll find this little passage:
+</p>
+
+<pre>
+<blockquote>
+hw.acpi.lid_switch_state
+ Suspend state (S1-S5) to enter when the lid switch (i.e., a
+ notebook screen) is closed. Default is "NONE" (do nothing).
+</blockquote>
+<pre>
+
+<p>I changed this value a long time ago so closing the lid suspends the laptop. You can check with <code>sysctl</code>:</p>
+
+<pre>
+<code>
+$ sysctl hw.acpi.lid_switch_state
+hw.acpi.lid_switch_state: S3
+</code>
+</pre>
+
+<p>Now, if I wanted to disable this functionality, I would just change this parameter as root:</p>
+
+<pre>
+<code>
+$ doas sysctl hw.acpi.lid_switch_state=NONE
+hw.acpi.lid_switch_state: NONE -> NONE
+</code>
+</pre>
+
+This change takes effect immediately. I can open and close the lid and nothing happens but turning off the screen. Awesome.
+
+<h2>Swapping Primary Display Outputs (Also Nvidia Screen-Tearing)</h2>
+
+<h2>Switching Default Sound Device</h2>
+
+<h2>Putting It All Together (Scripts Are Glue)</h2>
+
+<h2>What I Didn't Have to Do</h2>
+
+usb devices, battery/charging