#!/bin/bash

for DEVICE in /sys/class/input/event*/device/capabilities/key; do
    # If you need documentation on this line you should not be looking at this code.
    # BUT if you insist, we are lookin to see if bit 238 is set, yes really, I know it is vile
    # MEH!
    if cat $DEVICE | egrep -q ".*[4-7c-f][0-9a-f]{3}( [0-9a-f]{1,8}){7}$"; then
        break;
    fi
done

DEVICE=/dev${DEVICE#/sys/class}
DEVICE=${DEVICE%/device/capabilities/key}

echo $DEVICE

#10:08:21.020407: EV_KEY KEY_WLAN (0xee) released
/usr/bin/omsk-f2-detect "$DEVICE" | while read event count
do
    notify-send "Wireless cannot be turned ON or OFF using this key" "To do that, please right click on the network chooser in the upper right corner" -i nm-device-wireless
done
