I finally bought myself a dock for the thinkpad I use as my main computer. After using the new dock for some time I noticed that the screen would be stuck displaying black after leaving the system locked for a longer time. Looking around I found dockd which fixes that problem and automates the switching of display layouts.
Here’s how I installed it.
Install and Configuration
Add the repository and install dockd. Ref
wget -q -O - http://libthinkpad.github.io/repo/thinkpads.gpg.key | sudo apt-key add - echo "deb [arch=amd64] https://libthinkpad.github.io/repo/apt/ /" | sudo tee /etc/apt/sources.list.d/thinkpads.list sudo apt update sudo apt install dockd
Next configure your system in both docked and undocked modes.
First put your thinkpad in the dock. Configure your screens using e.g.
xrandr, then run the following command.
sudo dockd --config docked
Next, undock the thinkpad and configure the screen again. E.g.
xrandr --auto. Then again run the following command.
sudo dockd --config undocked
For me, the dockd daemon did no start automatically. Likely this is because I use i3 as my default window manager.
Add the following line to the end of your
exec --no-startup-id dockd --daemon
dockd helpfully provides hook-scripts you can use for things you want to happen when you dock or undock.
For example, toggling the wifi. When I’m connected to my dock I can just use my ethernet cable that is connected to it.
On my system, I can use
nmcli to interact with the network components. Here’s what my hook-scripts look like.
#!/bin/bash # This hook is executed when the laptop is docked into a dockd. # Here you can do stuff such as disabling WiFi, switching input profiles, # switching keyboard layouts etc. # SCRIPT EXECUTES AS NON ROOT! nmcli radio wifi off exit
#!/bin/bash # This hook is executed when the laptop is docked into a dockd. # Here you can do stuff such as disabling WiFi, switching input profiles, # switching keyboard layouts etc. # SCRIPT EXECUTES AS NON ROOT! nmcli radio wifi on exit