Created
July 28, 2016 08:25
-
-
Save fpytloun/8b8d3c623f1ed5d1aaa50899096f629c to your computer and use it in GitHub Desktop.
Setup Lenovo USB keyboard
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/bash | |
# | |
# Setup Lenovo USB keyboard with trackpoint | |
# Systemd users: | |
# /etc/udev/rules.d/99-lenovo-kbd.rules: | |
# ACTION=="add", ATTR{idVendor}=="17ef", ATTR{idProduct}=="6047", TAG+="systemd", ENV{SYSTEMD_WANTS}="udev-lenovo-kbd-attach.service" | |
# /etc/systemd/system/udev-lenovo-kbd-attach.service: | |
# [Service] | |
# Type=oneshot | |
# ExecStart=/usr/local/bin/lenovo_kbd.sh | |
# User=youruser | |
# | |
sleep 1 | |
export DISPLAY=":0.0" | |
export HOME="/home/filip" | |
export XAUTHORITY="$HOME/.Xauthority" | |
log_info() { | |
cat - | logger -p user.info -t `basename $0` | |
} | |
log_error() { | |
cat - | logger -p user.error -t `basename $0` | |
} | |
device_id=$(xinput -list | grep -i 'Lenovo ThinkPad Compact USB Keyboard with TrackPoint' | grep -o id='[0-9].' | grep -o '[0-9].' | head -1) | |
if [ -z $device_id ]; then | |
echo "Device ID not found"|log_error | |
exit 1 | |
fi | |
xinput set-prop $device_id "Device Accel Constant Deceleration" 0.4 2>&1|log_info | |
xinput set-int-prop $device_id "Evdev Wheel Emulation" 8 1 2>&1|log_info | |
xinput set-int-prop $device_id "Evdev Wheel Emulation Button" 8 2 2>&1|log_info | |
xinput set-int-prop $device_id "Evdev Wheel Emulation Axes" 8 6 7 4 5 2>&1|log_info | |
xset r rate 200 20 2>&1|log_info | |
notify-send "External keyboard plugged in" -i gtk-dialog-info -u normal -i keyboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment