generated from Serpentiel/template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: change config schema, add new option
- Loading branch information
1 parent
38f6eca
commit 12a6d26
Showing
4 changed files
with
78 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
# An array of input sources to cycle through when the Globe key is pressed once. | ||
primary_input_sources: | ||
- com.apple.keylayout.US | ||
- com.apple.keylayout.Russian | ||
# Double press | ||
double_press: | ||
# Maximum delay between two presses of the Globe key for them to be considered as a double press | ||
maximum_delay: 250 | ||
|
||
# An array of input sources to cycle through when the Globe key is double pressed. | ||
additional_input_sources: | ||
- com.apple.keylayout.Finnish | ||
# Input sources | ||
input_sources: | ||
# Primary input sources | ||
# This is used when the Globe key has been pressed once | ||
primary: | ||
- com.apple.keylayout.US | ||
- com.apple.keylayout.Russian | ||
|
||
# Additional input sources | ||
# This is used when the Globe key has been double pressed | ||
additional: | ||
- com.apple.keylayout.Finnish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Package eventhandler encapsulates logic to handle keyboard events. | ||
package eventhandler | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
// intGet returns the value of the key as int. | ||
func intGet(k string) int { | ||
result, ok := viper.Get(k).(int) | ||
if !ok { | ||
logger.Fatalw("config key type is not int", "key", k) | ||
} | ||
|
||
return result | ||
} | ||
|
||
// interfaceSliceGet returns the value of the key as []interface{}. | ||
func interfaceSliceGet(k string) []interface{} { | ||
result, ok := viper.Get(k).([]interface{}) | ||
if !ok { | ||
logger.Fatalw("config key type is not []interface{}", "key", k) | ||
} | ||
|
||
return result | ||
} | ||
|
||
// stringSlicesGet returns the value of the key as []string. | ||
func stringSliceGet(k string) []string { | ||
val := interfaceSliceGet(k) | ||
|
||
result := make([]string, len(val)) | ||
|
||
for i, v := range val { | ||
cv, ok := v.(string) | ||
if !ok { | ||
logger.Fatalw("config key type is not string", "key", fmt.Sprintf("%s.%d", k, i)) | ||
} | ||
|
||
result[i] = cv | ||
} | ||
|
||
return result | ||
} |