ghettoptt/main.go

41 lines
766 B
Go
Raw Normal View History

2024-03-09 19:34:21 +00:00
package main
import (
"fmt"
"os"
"github.com/godbus/dbus/v5"
"github.com/holoplot/go-evdev"
)
func main() {
conn, err := dbus.ConnectSessionBus()
if err != nil {
panic(err)
}
defer conn.Close()
obj := conn.Object("net.sourceforge.mumble.mumble", "/")
// Start reading input events
input, err := evdev.OpenWithFlags("/dev/input/event1", os.O_RDONLY)
if err != nil {
panic(err)
}
for {
ev, err := input.ReadOne()
if err != nil {
panic(err)
}
if ev.Code == evdev.KEY_F24 && ev.Value == 1 {
fmt.Printf("PTT ON!\n")
obj.Go("net.sourceforge.mumble.Mumble.startTalking", 0, nil)
}
if ev.Code == evdev.KEY_F24 && ev.Value == 0 {
fmt.Printf("PTT OFF!\n")
obj.Go("net.sourceforge.mumble.Mumble.stopTalking", 0, nil)
}
}
}