Skip to content

Commit

Permalink
Refactor -k flag as Bool to toggle keyboard mode on-demand / exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
trinitronx committed Jul 25, 2023
1 parent aeeb4e4 commit 830edef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Usage of nwg-drawer:
GTK theme name, eg. "Adwaita-dark"
-is int
Icon Size (default 64)
-k string
Set GTK layer shell keyboard interactivity: 'exclusive' or 'on-demand' (or: 'e', 'o') (default "exclusive")
-k
Set GTK layer shell keyboard interactivity to "on-demand" mode (default "exclusive")
-lang string
force lang, e.g. "en", "pl"
-nocats
Expand Down
14 changes: 3 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func defaultStringIfBlank(s, fallback string) string {
var cssFileName = flag.String("s", "drawer.css", "Styling: css file name")
var targetOutput = flag.String("o", "", "name of the Output to display the drawer on (sway only)")
var displayVersion = flag.Bool("v", false, "display Version information")
var keyboard = flag.String("k", "exclusive", "Set GTK layer shell keyboard interactivity: 'exclusive' or 'on-demand' (or: 'e', 'o')")
var keyboard = flag.Bool("k", false, "Set GTK layer shell keyboard interactivity to 'on-demand' mode")
var overlay = flag.Bool("ovl", false, "use OVerLay layer")
var gtkTheme = flag.String("g", "", "GTK theme name")
var gtkIconTheme = flag.String("i", "", "GTK icon theme name")
Expand Down Expand Up @@ -387,19 +387,11 @@ func main() {
layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_RIGHT, *marginRight)
layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_BOTTOM, *marginBottom)

if (*keyboard) == "" {
log.Warnf("Empty string passed to -k: %s)", *keyboard)
log.Warn("Setting GTK layer shell keyboard mode to default: exclusive")
layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE)
} else if (*keyboard)[0] == 'e' {
log.Info("Setting GTK layer shell keyboard mode to: exclusive")
layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE)
} else if (*keyboard)[0] == 'o' {
if *keyboard {
log.Info("Setting GTK layer shell keyboard mode to: on-demand")
layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND)
} else {
log.Warnf("Invalid option passed to -k: %s)", *keyboard)
log.Warn("Setting GTK layer shell keyboard mode to default: exclusive")
log.Info("Setting GTK layer shell keyboard mode to default: exclusive")
layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE)
}

Expand Down

0 comments on commit 830edef

Please sign in to comment.