Skip to content

Instantly share code, notes, and snippets.

@CanNuhlar
Created August 7, 2018 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CanNuhlar/8676a09f3addc2c5951c7a9ed33ba95f to your computer and use it in GitHub Desktop.
Save CanNuhlar/8676a09f3addc2c5951c7a9ed33ba95f to your computer and use it in GitHub Desktop.
Created from terminal
# X session startup script: /etc/X11/Xsession.d/55numlockx
# Initial settings
NUMLOCK=auto
# Load configuration
cf=/etc/default/numlockx
[ ! -r $cf ] || . $cf
# Toggle numlock if we're not removed
nlx=/usr/bin/numlockx
[ ! -x $nlx ] || {
case $NUMLOCK in
# 'keep' is an undocumented state (see `man 1 numlockx'), though
# /etc/default/numlockx mentions it; do nothing
keep)
return 0
;;
off|on|toggle)
;;
*)
NUMLOCK=on
if [ -x /usr/sbin/laptop-detect ];then
ltd=/usr/sbin/laptop-detect
else
ltd=/usr/bin/laptop-detect
fi
[ ! -x $ltd ] || ! $ltd || NUMLOCK=off
# Enable numlock for USB keyboard on laptop
if [ -f /bin/udevadm ] ; then
for kbd in `udevadm trigger --dry-run --verbose --property-match=ID_INPUT_KEYBOARD=1` ; do
if udevadm info --query=env --path=$kbd | grep -q '^DEVNAME=' ; then
continue
fi
if udevadm info --query=env --path=$kbd | grep -q '^ID_USB_DRIVER=usbhid' ; then
NUMLOCK=on
fi
done
fi
;;
esac
$nlx $NUMLOCK || :
}
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment