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]
|
||||
log.Println(e)
|
||||
}
|
||||
message := map[string]interface{}{}
|
||||
|
||||
message["request"] = "udev"
|
||||
message["data"] = env
|
||||
|
||||
c, err := net.Dial("unix", "/var/local/backive/backive.sock")
|
||||
if err != nil {
|
||||
log.Fatalln("Could not instantiate unix socket. Aborting")
|
||||
}
|
||||
jsonstr, err := json.Marshal(env)
|
||||
jsonstr, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
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"))
|
||||
//log.Println(sdata)
|
||||
env := map[string]string{}
|
||||
errjson := json.Unmarshal([]byte(sdata), &env)
|
||||
var message map[string]interface{}
|
||||
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 {
|
||||
log.Fatal(errjson)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue