Created
July 26, 2013 00:30
-
-
Save JoaoFelipe/6085104 to your computer and use it in GitHub Desktop.
Find Asus hotkeys device and print the device path
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
#!/bin/sh -e | |
# Find Asus hotkeys device and print the device path | |
# Author: Joao Felipe Nicolaci Pimentel <[email protected]> | |
# | |
# Copyright (C) 2013 | |
# | |
# Based on findkeyboards | |
# Original Author: Martin Pitt <[email protected]> | |
# | |
# Copyright (C) 2009, Canonical Ltd. | |
# | |
# This program is free software; you can redistribute it and/or modify it | |
# under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, but | |
# WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
# General Public License for more details. | |
# returns OK if $1 contains $2 | |
strstr() { | |
[ "${1#*$2*}" != "$1" ] | |
} | |
# returns OK if $1 contains $2 at the beginning | |
str_starts() { | |
[ "${1#$2*}" != "$1" ] | |
} | |
str_line_starts() { | |
while read a; do str_starts "$a" "$1" && return 0;done | |
return 1; | |
} | |
# print a list of input devices which are keyboard-like | |
keyboard_devices() { | |
# standard AT keyboard | |
for dev in `udevadm trigger --dry-run --verbose --property-match=ID_PATH=platform-asus-nb-wmi`; do | |
walk=`udevadm info --attribute-walk --path=$dev` | |
env=`udevadm info --query=env --path=$dev` | |
# filter out non-event devices, such as the parent input devices which have no devnode | |
if ! echo "$env" | str_line_starts 'DEVNAME='; then | |
continue | |
fi | |
echo -n 'ASUS hotkeys: ' | |
udevadm info --query=name --path=$dev | |
done | |
} | |
keyboard_devices |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment