Use XDG_CONFIG_HOME
Remove extra output
This commit is contained in:
parent
be99ea3d81
commit
ef37cc4317
26
main.go
26
main.go
@ -40,7 +40,7 @@ const (
|
||||
func Press(press [8]byte, file io.Writer) {
|
||||
binary.Write(file, binary.BigEndian, press[:])
|
||||
binary.Write(file, binary.BigEndian, [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||
fmt.Println(press)
|
||||
|
||||
fmt.Println([8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ func changeKeymap(r rune, keys map[string]Keys, args Args, hidg0 *os.File, curre
|
||||
//fmt.Println(*currentKeyMap)
|
||||
//fmt.Println(args)
|
||||
kmap := args.ORDER[(*currentKeyMap)]
|
||||
fmt.Println(kmap)
|
||||
|
||||
for keys[kmap][string(r)].Decimal == 0 {
|
||||
Press([8]byte{LCTRL, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00}, hidg0)
|
||||
*currentKeyMap++
|
||||
@ -65,11 +65,13 @@ func changeKeymap(r rune, keys map[string]Keys, args Args, hidg0 *os.File, curre
|
||||
func main() {
|
||||
var (
|
||||
args Args
|
||||
envExists bool
|
||||
env string
|
||||
hidg0 *os.File
|
||||
err error
|
||||
keymapsF []os.FileInfo
|
||||
keys = make(map[string]Keys)
|
||||
cfgPath = "./" //path.Join(os.Getenv("XDG_CONFIG_HOME"), "hid")
|
||||
cfgPath string
|
||||
stdin = bufio.NewReader(os.Stdin)
|
||||
currentKeyMap int
|
||||
flags = map[string]byte{
|
||||
@ -85,12 +87,18 @@ func main() {
|
||||
}
|
||||
)
|
||||
arg.MustParse(&args)
|
||||
env, envExists = os.LookupEnv("XDG_CONFIG_HOME")
|
||||
if !envExists {
|
||||
env = os.Getenv("HOME")
|
||||
}
|
||||
|
||||
cfgPath = path.Join(env, "hid")
|
||||
keymapsF, err = ioutil.ReadDir(cfgPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
//fmt.Println(cfgPath)
|
||||
fmt.Println(keymapsF)
|
||||
|
||||
fmt.Println(cfgPath)
|
||||
|
||||
hidg0, err = os.OpenFile("/dev/hidg0", os.O_WRONLY, os.ModePerm)
|
||||
if err != nil {
|
||||
@ -103,14 +111,14 @@ func main() {
|
||||
)
|
||||
|
||||
ext = path.Ext(file.Name())
|
||||
//fmt.Println(ext)
|
||||
|
||||
if strings.ToLower(ext) == ".json" {
|
||||
var (
|
||||
tmp Keys
|
||||
T *os.File
|
||||
content []byte
|
||||
)
|
||||
//fmt.Println(file.Name())
|
||||
|
||||
T, err = os.Open(file.Name())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -140,7 +148,7 @@ func main() {
|
||||
)
|
||||
|
||||
r, _, err = stdin.ReadRune()
|
||||
fmt.Printf("%s\n", string(r))
|
||||
//fmt.Printf("%s\n", string(r))
|
||||
|
||||
if err == io.EOF {
|
||||
break
|
||||
@ -152,8 +160,6 @@ func main() {
|
||||
changeKeymap(r, keys, args, hidg0, ¤tKeyMap)
|
||||
flag = flags[keys[args.ORDER[currentKeyMap]][string(r)].Modifier]
|
||||
binary.BigEndian.PutUint16(report[:], uint16(keys[args.ORDER[currentKeyMap]][string(r)].Decimal))
|
||||
fmt.Printf("report: % x\n", report)
|
||||
fmt.Println("decimal: ", keys[args.ORDER[currentKeyMap]][string(r)].Decimal)
|
||||
Press([8]byte{flag, 0, report[0], report[1], report[2], report[3], report[4], report[5]}, hidg0)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user