hid/main.go
lordwelch 0b2415ac40 cleaned up some code
handle delays better
add ability to have comments
add defaults to keymaps
2018-11-04 23:59:13 -08:00

43 lines
860 B
Go

package main
import (
"flag"
"fmt"
"os"
"time"
"timmy.narnian.us/hid/ghid"
)
func main() {
var (
SHORTCUT string
)
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
fmt.Println(hid.KeymapPath)
file, err := os.OpenFile("/dev/hidg0", os.O_APPEND|os.O_WRONLY, 0755)
if err != nil {
panic(err)
}
hid.Hidg0 = file
defer file.Close()
hid.Write(os.Stdin)
if err != nil {
panic(err)
}
fmt.Println("Success!")
}