Last active
October 4, 2021 07:21
-
-
Save jsynowiec/9184371 to your computer and use it in GitHub Desktop.
[Thinkpad Series 3 docking station scripts] Thinkpad "docking scripts" for Series 3 docking station enabling or disabling both external displays on acpi events (https://www.kernel.org/doc/Documentation/laptops/thinkpad-acpi.txt). Only one pair of events should be used - check which ones (IBM/LENOVO/HKEY) acpid daemon receives. #thinkpad #linux #…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-dock | |
# This is called when the Thinkpad docks in a series 3 docking station | |
event=ibm/hotkey HKEY 00000080 00004010 | |
action=/etc/acpi/thinkpad-dock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-dock | |
# This is called when the Thinkpad docks in a series 3 docking station | |
event=ibm/hotkey IBM0068:00 00000080 00004010 | |
action=/etc/acpi/thinkpad-dock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-dock-lenovo | |
# This is called when the Thinkpad docks in a series 3 docking station | |
event=ibm/hotkey LEN0068:00 00000080 00004010 | |
action=/etc/acpi/thinkpad-dock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# /etc/acpi/thinkpad-dock.sh | |
int_mon="LVDS1" | |
ext_mon_1="HDMI2" | |
ext_mon_2="HDMI3" | |
xowner=$(who | grep '(:0)' | awk 'BEGIN { FS = "[ \t\n]+" } { print $1}') | |
em_test=$(sudo DISPLAY=:0.0 -u $xowner xrandr | grep $ext_mon_1 | grep " connected") | |
if [ -n "$em_test" ]; then | |
# two-step because Intel HD can handle only two heads | |
sudo DISPLAY=:0.0 -u $xowner xrandr --output $ext_mon_1 --auto --primary --output $int_mon --off | |
sudo DISPLAY=:0.0 -u $xowner xrandr --output $ext_mon_2 --auto --right-of $ext_mon_1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-undock | |
# This is called when the Thinkpad undocks from a series 3 docking station | |
event=ibm/hotkey IBM0068:00 00000080 00004011 | |
action=/etc/acpi/thinkpad-undock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-undock | |
# This is called when the Thinkpad undocks from a series 3 docking station | |
event=ibm/hotkey HKEY 00000080 00004011 | |
action=/etc/acpi/thinkpad-undock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/acpi/events/thinkpad-undock-lenovo | |
# This is called when the Thinkpad undocks from a series 3 docking station | |
event=ibm/hotkey LEN0068:00 00000080 00004011 | |
action=/etc/acpi/thinkpad-undock.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# /etc/acpi/thinkpad-undock.sh | |
int_mon="LVDS1" | |
ext_mon_1="HDMI2" | |
ext_mon_2="HDMI3" | |
xowner=$(who | grep '(:0)' | awk 'BEGIN { FS = "[ \t\n]+" } { print $1}') | |
em_test=$(sudo DISPLAY=:0.0 -u $xowner xrandr | grep $ext_mon_1 | grep " disconnected") | |
if [ -n "$em_test" ]; then | |
sudo DISPLAY=:0.0 -u $xowner xrandr --output $ext_mon_2 --off | |
sudo DISPLAY=:0.0 -u $xowner xrandr --output $int_mon --auto --primary --output $ext_mon_1 --off | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment