hid/main.go

43 lines
860 B
Go
Raw Normal View History

package main
import (
2018-10-20 16:49:09 -07:00
"flag"
"fmt"
"os"
"time"
2018-10-29 22:07:51 -07:00
2018-10-20 16:49:09 -07:00
"timmy.narnian.us/hid/ghid"
)
func main() {
var (
2018-10-20 16:49:09 -07:00
SHORTCUT string
)
2018-10-20 16:49:09 -07:00
flag.StringVar(&SHORTCUT, "shortcut", "", "Keymap cycle shortcut")
flag.StringVar(&SHORTCUT, "s", "", "Keymap cycle shortcut")
flag.StringVar(&hid.KeymapPath, "path", os.ExpandEnv("$XDG_CONFIG_HOME"), "Path to config dir default: $XDG_CONFIG_HOME")
flag.StringVar(&hid.KeymapPath, "p", os.ExpandEnv("$XDG_CONFIG_HOME"), "Path to config dir default: $XDG_CONFIG_HOME")
flag.Parse()
hid.KeymapOrder = flag.Args()
hid.ReleaseDelay = time.Duration(10) * time.Millisecond
2018-10-20 16:49:09 -07:00
fmt.Println(hid.KeymapPath)
2018-10-20 16:49:09 -07:00
file, err := os.OpenFile("/dev/hidg0", os.O_APPEND|os.O_WRONLY, 0755)
if err != nil {
panic(err)
}
2018-10-20 16:49:09 -07:00
hid.Hidg0 = file
defer file.Close()
hid.Write(os.Stdin)
2018-10-20 16:49:09 -07:00
if err != nil {
panic(err)
}
fmt.Println("Success!")
}