Last active
February 8, 2021 14:08
-
-
Save jirib/eacfe5f5d0b7e56ea8e673305d20ef09 to your computer and use it in GitHub Desktop.
LCD setup and laptop kbd setup - disable keyboard if your cat likes to walk or sleep closed to your laptop :D
This file contains hidden or 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
| $ cat ~/bin/lcd_{reset,home} | |
| #!/bin/bash | |
| set -x | |
| set -o pipefail | |
| set -e | |
| EXT_DISPLAY=DP1 | |
| INT_DISPLAY=LVDS1 | |
| lcd_setup() { | |
| local _outputs | |
| local _output | |
| _outputs=$(xrandr -q | tail -n +2 | \ | |
| grep -Po "^((?!${INT_DISPLAY}).)[^ ]+") | |
| for _output in ${_outputs}; do | |
| xrandr --output ${_output} --off | |
| done | |
| xrandr --output ${INT_DISPLAY} --primary --auto | |
| } | |
| kbd_setup() { | |
| local _atkbd | |
| local _master | |
| _atkbd=$(xinput list --short | \ | |
| grep -Po 'AT Translated Set 2 keyboard\s+id=\K(\d+)(?=.*)') | |
| _master=$(xinput list --short | \ | |
| grep -Po 'Virtual core keyboard\s+id=\K(\d+)(?=.*)') | |
| xinput reattach ${_atkbd} ${_master} | |
| } | |
| # main | |
| lcd_setup | |
| kbd_setup | |
| #!/bin/bash | |
| set -x | |
| set -o pipefail | |
| set -e | |
| EXT_DISPLAY=DP1 | |
| INT_DISPLAY=LVDS1 | |
| lcd_setup() { | |
| local _outputs | |
| local _output | |
| _outputs=$(xrandr -q | tail -n +2 | \ | |
| grep -Po "^((?!(${EXT_DISPLAY}|${INT_DISPLAY})).)[^ ]+") | |
| for _output in ${_outputs}; do | |
| xrandr --output ${_output} --off | |
| done | |
| xrandr --output ${EXT_DISPLAY} --primary --auto | |
| xrandr --output ${INT_DISPLAY} --off | |
| } | |
| kbd_setup() { | |
| local _atkbd | |
| local _master | |
| _atkbd=$(xinput list --short | \ | |
| grep -Po 'AT Translated Set 2 keyboard\s+id=\K(\d+)(?=.*)') | |
| # _master=$(xinput list --short | \ | |
| # grep -Po 'Virtual core keyboard\s+id=\K(\d+)(?=.*)') | |
| xinput float ${_atkbd} | |
| } | |
| # main | |
| lcd_setup | |
| kbd_setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment