; ; @ANO_SCRIPT_NAME hotplug_events ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Simple hotplug event example ; ; @ANO_FLAGS_USE_PROTOS [ ] ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2026, Jani Salonen ; All rights reserved. ; ; This example shows how to trigger hotplug events when some hotpluggable ; device is attached or removed from the system. ; ; Currently only FreeBSD's hotplug system is supported. ; main { ; Initialize hotplug notifications if it is enabled. ; hotplug_enabled { hotplug_init (\ cb_attach: "hp_attach", \ cb_detach: "hp_detach", \ cb_notify: "hp_notify") print "Now attach or remove some USB device for example to" \ " see callback doing its\nwork.\n" print "Waiting for inotify events, " } print "press to break.\n" } _HOTPLUG_EVENT_ callback hp_attach (_hnd, _key, _val) { ; Hotplug device attached. ; print "Device attached, details below:\n" dump _hnd dump _key dump _val print "\n" } _HOTPLUG_EVENT_ callback hp_detach (_hnd, _key, _val) { ; Hotplug device detached. ; print "Device detached, details below:\n" dump _hnd dump _key dump _val print "\n" } _HOTPLUG_EVENT_ callback hp_notify (_hnd, _key, _val) { ; Hotplug device notify. ; print "Device notification, details below:\n" dump _hnd dump _key dump _val print "\n" }