kopia lustrzana https://github.com/abourget/shuttle-go
Disable xinput automatically..
rodzic
e4e55249cc
commit
29ec7d3fd7
|
@ -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
|
||||
----
|
||||
|
|
4
main.go
4
main.go
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue