Browse Source

Add and implement inputctl.sh, remove touchpad i2c_hid module blacklist

master
Riyyi 6 years ago
parent
commit
b78c0e3ed2
  1. 7
      .config/sxhkd/sxhkdrc
  2. 12
      .config/xorg/xinitrc
  3. 4
      .config/zsh/.zshrc
  4. 130
      .scripts/inputctl.sh
  5. 11
      .scripts/touchscreen.sh
  6. 3
      etc/modprobe.d/blacklist.conf

7
.config/sxhkd/sxhkdrc

@ -45,8 +45,9 @@ XF86Audio{LowerVolume,RaiseVolume,Mute}
mediacontrol.sh {down 5,up 5,toggle}
# Touchpad toggle
# XF86iTouch
XF86HomePage
inputctl.sh -d toggle
# Touchscreen toggle
XF86HomePage
touchscreen.sh
XF86Search
inputctl.sh -s toggle

12
.config/xorg/xinitrc

@ -11,14 +11,12 @@ xrandr --output eDP-1 --mode 3000x2000_48.00 --primary
xset s off
xset -dpms
# Clear all key mappings
setxkbmap -option ''
# Customize keyboard layout
inputctl.sh -k off
inputctl.sh -k on
# Swap capslock with escape
setxkbmap -option caps:swapescape
# Set touchpad toggle key symbol
xmodmap -e "keycode 93 = XF86iTouch"
# Turn off touchscreen
inputctl.sh -s off
# Daemon starting
dunst &

4
.config/zsh/.zshrc

@ -129,10 +129,6 @@ alias nw="$HOME/.scripts/network.sh"
alias vp="$HOME/.scripts/vimplugin.sh"
alias mpvshuffle="$HOME/.scripts/mpv.sh shuffle"
# Laptop
alias offtouchpad='sudo rmmod i2c_hid'
alias ontouchpad="sudo modprobe i2c_hid && $HOME/.scripts/touchscreen.sh 0"
# Other
alias mysql-workbench="GDK_SCALE=1 GDK_DPI_SCALE=1 mysql-workbench 1>/dev/null 2>&1 &; disown"
alias weather="curl -s 'http://wttr.in/dordrecht?q&n&p' | head -n -3"

130
.scripts/inputctl.sh

@ -0,0 +1,130 @@
#!/bin/sh
help() {
B=$(tput bold)
U=$(tput smul)
N=$(tput sgr0)
cat << EOF
${B}NAME${N}
inputctl.sh - input manager
${B}SYNOPSIS${N}
${B}inputctl.sh${N} [${U}OPTION${N}] [${U}ARG${N}]
${B}OPTIONS${N}
${B}-h${N}
Display usage message and exit.
${B}-d${N} [${U}ARG${N}]
Perform action on touchpad.
${B}-k${N} [${U}ARG${N}]
Perform action on keyboard.
${B}-s${N} [${U}ARG${N}]
Perform action on touchscreen.
${B}ARGS${N}
toggle
Toggle input device / keyboard customizations.
on
Enable input device / keyboard customizations.
off
Disable input device / keyboard customizations.
EOF
}
# If no option is provided
[ "$#" -eq 0 ] && help && exit
SCRIPT="$(basename "$0")"
# Option handling
while getopts ':h?d:k:s:' opt; do
case $opt in
h)
help
exit
;;
d)
dev="SYNA3602:00 0911:5288 Touchpad"
;;
k)
dev="Keyboard"
;;
s)
dev="pointer:04F3200A:00 04F3:2373"
;;
:)
echo "$SCRIPT: option requires an argument '$OPTARG'"
echo "Try '$SCRIPT -h' for more information."
exit 1
;;
\?)
echo "$SCRIPT: invalid option '$OPTARG'"
echo "Try '$SCRIPT -h' for more information."
exit 1
;;
esac
done
toggle_device() {
STATUS=$(xinput --list-props "$dev" | awk '/Device Enabled/ { print $4 }')
[ "$STATUS" -eq 1 ] && xinput --disable "$dev" || xinput --enable "$dev"
}
keyboard() {
[ -z "$1" ] && return 1
if [ "$1" = "toggle" ]; then
if setxkbmap -query | grep -q options; then
keyboard "off"
else
keyboard "on"
fi
elif [ "$1" = "on" ]; then
# Swap caps lock with escape
setxkbmap -option caps:swapescape
# Swap left crtl with left alt
# setxkbmap -option ctrl:swap_lalt_lctl
# Set touchpad toggle keyboard symbol
# xmodmap -e "keycode 93 = XF86iTouch"
elif [ "$1" = "off" ]; then
# Clear all key mappings
setxkbmap -option ''
fi
}
shift $((OPTIND - 2))
# Command handling
if [ "$dev" = "Keyboard" ]; then
keyboard "$1"
else
case "$1" in
toggle)
toggle_device
;;
on)
xinput --enable "$dev"
;;
off)
xinput --disable "$dev"
;;
esac
fi
# Useful input diagnostics packages:
# - xinput
# - xev
# - evtest
#
# - setxkbmap -query
# - xmodmap -pke
#
# Kernel 5.1.4 works properly on my hardware with the i2c_hid module

11
.scripts/touchscreen.sh

@ -1,11 +0,0 @@
#!/bin/sh
device="04F3200A:00 04F3:2373"
state=$(xinput --list-props "$device" | grep "Device Enabled" | sed -nr 's/.*:\t([0-9])/\1/p')
if [ "$state" = "0" ] && [ -z "$1" ]; then
xinput --enable "$device"
else
xinput --disable "$device"
fi

3
etc/modprobe.d/blacklist.conf

@ -1,5 +1,2 @@
# Do not load the touchpad module on boot
blacklist i2c_hid
# Disable speck cipher
blacklist speck

Loading…
Cancel
Save