static void triggerUdevNotification ( String sysClass ) { File [ ] devices = new File ( "/sys/class/" + sysClass ) . listFiles ( ) ; byte [ ] action = "change" . getBytes ( ) ; for ( File device : devices ) { File uevent = new File ( device , "uevent" ) ; if ( uevent . exists ( ) ) { try { write ( uevent . getAbsolutePath ( ) , action ) ; } catch ( IOException e ) { System . err . println ( "Udev: Failed to write to " + uevent ) ; System . err . println ( " Check that you have permission to access input devices" ) ; if ( ! e . getMessage ( ) . contains ( "Permission denied" ) ) { e . printStackTrace ( ) ; } } } } }
Fires udev notification events for devices of the given type