Introducing a better interface

Goal is to distinguish between udev input only and a gui for
notifications.
This commit is contained in:
Marcel Otte 2022-01-07 12:08:25 +01:00
parent dfff4af38f
commit e5e7f7326a
2 changed files with 13 additions and 3 deletions

View File

@ -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")
}

View File

@ -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)
}