Created
August 1, 2023 18:31
-
-
Save callemo/9c1f60387ad58aaf28126e4ffd5180f8 to your computer and use it in GitHub Desktop.
Dock and undock your OpenBSD laptop
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 | |
# dock: switches between external and internal displays. | |
prefix="${0##*/}:" | |
log() { echo "$prefix" "$@" >&2; } | |
fatal() { log "$@"; exit 1; } | |
int='eDP-1' | |
mode='1920x1080' | |
[ "$(uname)" = OpenBSD ] || fatal 'not running in OpenBSD' | |
ext="$(xrandr | awk '$2 == "connected" && $1 != "'$int'" { print $1 }')" | |
[ -n "$ext" ] || fatal 'not connected to an external display' | |
case "$0" in | |
*undock) | |
log "undocking from external $ext" | |
xrandr --output "$int" --auto --output "$ext" --off | |
xinput set-prop /dev/wsmouse 'Device Accel Constant Deceleration' 1 | |
;; | |
*) | |
log "docking to external $ext" | |
xrandr --output "$ext" --mode "$mode" --output "$int" --off | |
xinput set-prop /dev/wsmouse 'Device Accel Constant Deceleration' 3 | |
xinput set-button-map /dev/wsmouse 1 2 3 5 4 7 6 | |
;; | |
esac | |
pgrep cwm && pkill -HUP cwm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment