diff --git a/main.go b/main.go index fa5349a..51a18b5 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "log/slog" "os" "os/signal" + "time" "github.com/godbus/dbus/v5" "github.com/holoplot/go-evdev" @@ -49,6 +50,7 @@ func main() { input.Close() }() + var lastOn time.Time // Start listening for PTT key slog.Info("Starting event listener", "version", Version) for !done { @@ -62,10 +64,12 @@ func main() { } if ev.Code == evdev.KEY_F24 && ev.Value == 1 { slog.Info("PTT ON") + lastOn = time.Now() obj.Call("net.sourceforge.mumble.Mumble.startTalking", 0) } if ev.Code == evdev.KEY_F24 && ev.Value == 0 { - slog.Info("PTT OFF") + speakDuration := time.Since(lastOn).String() + slog.Info("PTT OFF", "duration", speakDuration) obj.Call("net.sourceforge.mumble.Mumble.stopTalking", 0) } }