Is it possible to determine whether there is a numeric keypad connected to the system? Desktop keyboards typically have numpads, while laptops typically don\'t (though they put
install these packages
sudo apt-get install -y numlockx xdotool x11-utils
then use a script like this
#!/bin/bash
cd
numlockx off &
rm -f s1.sh s2.sh out
echo -e "#\041/bin/bash
sleep 2
xdotool key KP_5 | xev > out
exit 0" >> s1.sh
chmod +x s1.sh
echo -e "#\041/bin/bash
sleep 9
killall -9 xev
sleep 5
xdotool key BackSpace
exit 0" >> s2.sh
chmod +x s2.sh
bash s1.sh &
bash s2.sh
rm -f s1.sh s2.sh
if [[ "$(cat out | grep "keycode 84" | grep "KP_Begin" )" != "" ]]; then
echo "Separated Numpad Detected!"
fi
rm out
exit 0
because KP_Begin
is the keycode for the numpad key KP_5
when numlock isn't active, in a real keyboard with a real keypad.
Tested on 3 PCs, one with a separated keypad e 2 without it.