41 lines
607 B
Go
41 lines
607 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
|
|
"github.com/deniswernert/udev"
|
|
)
|
|
|
|
var (
|
|
GitBranch string
|
|
GitCommit string
|
|
|
|
UNotify chan *udev.UEvent
|
|
)
|
|
|
|
func Mon() {
|
|
for {
|
|
uevent := <-UNotify
|
|
|
|
log.Println("UEvent.Action: ", uevent.Action)
|
|
log.Println("UEvent.Devpath: ", uevent.Devpath)
|
|
log.Println("UEvent.Env: ", uevent.Env)
|
|
log.Println()
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
log.Println("MUEvent branch=" + GitBranch + " commit=" + GitCommit)
|
|
UNotify = make(chan *udev.UEvent, 128)
|
|
mon, e := udev.NewMonitor()
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
go Mon()
|
|
mon.Monitor(UNotify)
|
|
for {
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|