mirror of https://github.com/qwc/backive.git
Introducing a better interface
Goal is to distinguish between udev input only and a gui for notifications.
This commit is contained in:
parent
dfff4af38f
commit
e5e7f7326a
|
@ -34,12 +34,16 @@ func main() {
|
||||||
env[pair[0]] = pair[1]
|
env[pair[0]] = pair[1]
|
||||||
log.Println(e)
|
log.Println(e)
|
||||||
}
|
}
|
||||||
|
message := map[string]interface{}{}
|
||||||
|
|
||||||
|
message["request"] = "udev"
|
||||||
|
message["data"] = env
|
||||||
|
|
||||||
c, err := net.Dial("unix", "/var/local/backive/backive.sock")
|
c, err := net.Dial("unix", "/var/local/backive/backive.sock")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Could not instantiate unix socket. Aborting")
|
log.Fatalln("Could not instantiate unix socket. Aborting")
|
||||||
}
|
}
|
||||||
jsonstr, err := json.Marshal(env)
|
jsonstr, err := json.Marshal(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln("Could not convert to json. Aborting")
|
log.Fatalln("Could not convert to json. Aborting")
|
||||||
}
|
}
|
||||||
|
|
10
events.go
10
events.go
|
@ -65,8 +65,14 @@ func (eh *EventHandler) process() {
|
||||||
}
|
}
|
||||||
sdata := string(bytes.Trim(data, "\x00"))
|
sdata := string(bytes.Trim(data, "\x00"))
|
||||||
//log.Println(sdata)
|
//log.Println(sdata)
|
||||||
env := map[string]string{}
|
var message map[string]interface{}
|
||||||
errjson := json.Unmarshal([]byte(sdata), &env)
|
errjson := json.Unmarshal([]byte(sdata), &message)
|
||||||
|
var env = map[string]string{}
|
||||||
|
if message["request"] == "udev" {
|
||||||
|
for k, v := range message["data"].(map[string]interface{}) {
|
||||||
|
env[k] = v.(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
if errjson != nil {
|
if errjson != nil {
|
||||||
log.Fatal(errjson)
|
log.Fatal(errjson)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue