Disable xinput automatically..

pull/5/head
Alexandre Bourget 2017-07-14 18:42:50 -04:00
rodzic e4e55249cc
commit 29ec7d3fd7
3 zmienionych plików z 49 dodań i 2 usunięć

Wyświetl plik

@ -44,11 +44,16 @@ The Shuttle acts as a mouse when you plug it into Ubuntu. Disable it with:
"Mouse2" id=3 [XExtensionKeyboard]
# Disable with:
$ xinput set-int-prop 2 "Device Enabled" 8 0
$ xinput disable 2
Ref: https://unix.stackexchange.com/questions/91075/how-to-disable-keyboard
## Run
With:
sudo shuttle-go /dev/input/by-id/usb-Contour_Design_ShuttlePRO_v2-event-if00
TODO
----

Wyświetl plik

@ -27,6 +27,8 @@ func main() {
os.Exit(10)
}
go disableXInputPointer()
// X-window title change watcher
watcher := NewWindowWatcher()
if err := watcher.Setup(); err != nil {
@ -37,7 +39,7 @@ func main() {
go watcher.Run()
// Virtual keyboard
vk, err := uinput.CreateKeyboard("/dev/uinput", []byte("Shuttle Pro V2"))
vk, err := uinput.CreateKeyboard("/dev/uinput", []byte("Go Virtual Shuttle Pro V2"))
if err != nil {
log.Println("Can't open dev:", err)
}

40
xinput.go 100644
Wyświetl plik

@ -0,0 +1,40 @@
package main
import (
"fmt"
"log"
"os/exec"
"regexp"
"time"
)
var xinputDevices = []*regexp.Regexp{
regexp.MustCompile(`↳ Contour Design ShuttlePRO v2\s+id=(\d)\s`),
}
func disableXInputPointer() {
for {
cnt, err := exec.Command("xinput", "list").Output()
if err != nil {
log.Println("Couldn't list xinput:", err)
goto end
}
for _, dev := range xinputDevices {
matches := dev.FindStringSubmatch(string(cnt))
if matches == nil {
continue
}
id := matches[1]
fmt.Println("Disabling XInput id:", id)
if err := exec.Command("xinput", "disable", id).Run(); err != nil {
log.Println("Couldn't disable xinput device:", err)
goto end
}
}
end:
time.Sleep(60 * time.Second)
}
}