From 2c54df832c714db419b8d1b3a50bc2f14863083d Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Tue, 5 May 2026 19:47:01 +0200 Subject: [PATCH] Use the hash instead of ID to get the Status Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- internal/guard/client.go | 6 +++--- internal/guard/device.go | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/guard/client.go b/internal/guard/client.go index 6f331ac..a6fb0ba 100644 --- a/internal/guard/client.go +++ b/internal/guard/client.go @@ -29,7 +29,7 @@ func ListDevices() ([]Device, error) { } d, err := parseLine(line) if err == nil { - d.Permanent = rules[d.VidPid] == d.Status + d.Permanent = rules[d.Hash] == d.Status devices = append(devices, d) } } @@ -47,8 +47,8 @@ func listRules() map[string]Status { continue } d, err := parseLine(line) - if err == nil { - rules[d.VidPid] = d.Status + if err == nil && d.Hash != "" { + rules[d.Hash] = d.Status } } return rules diff --git a/internal/guard/device.go b/internal/guard/device.go index 89a99b5..f4a747d 100644 --- a/internal/guard/device.go +++ b/internal/guard/device.go @@ -20,6 +20,7 @@ type Device struct { Name string Status Status VidPid string + Hash string Permanent bool } @@ -57,6 +58,7 @@ func parseLine(line string) (Device, error) { Name: name, Status: status, VidPid: extractUnquoted(rest, "id"), + Hash: extractField(rest, "hash"), }, nil }