Add duration to log
This commit is contained in:
parent
4ebf6dd715
commit
c3b35cdd2d
6
main.go
6
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/holoplot/go-evdev"
|
"github.com/holoplot/go-evdev"
|
||||||
@ -49,6 +50,7 @@ func main() {
|
|||||||
input.Close()
|
input.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var lastOn time.Time
|
||||||
// Start listening for PTT key
|
// Start listening for PTT key
|
||||||
slog.Info("Starting event listener", "version", Version)
|
slog.Info("Starting event listener", "version", Version)
|
||||||
for !done {
|
for !done {
|
||||||
@ -62,10 +64,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
if ev.Code == evdev.KEY_F24 && ev.Value == 1 {
|
if ev.Code == evdev.KEY_F24 && ev.Value == 1 {
|
||||||
slog.Info("PTT ON")
|
slog.Info("PTT ON")
|
||||||
|
lastOn = time.Now()
|
||||||
obj.Call("net.sourceforge.mumble.Mumble.startTalking", 0)
|
obj.Call("net.sourceforge.mumble.Mumble.startTalking", 0)
|
||||||
}
|
}
|
||||||
if ev.Code == evdev.KEY_F24 && ev.Value == 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)
|
obj.Call("net.sourceforge.mumble.Mumble.stopTalking", 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user