From 37c9c2d5204e2c6deac3b07120aba404373ab1a7 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Sun, 23 Jul 2023 19:39:41 -0600 Subject: [PATCH 1/6] Add --keyboard/-k flag to set GTK layer shell keyboard mode (default: exclusive) --- main.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 426d138..1850cf3 100644 --- a/main.go +++ b/main.go @@ -118,6 +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: 'none', 'exclusive' or 'on-demand' (or 'n', 'e' or 'o')") 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") @@ -386,7 +387,21 @@ func main() { layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_RIGHT, *marginRight) layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_BOTTOM, *marginBottom) - layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE) + 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' { + log.Info("Setting GTK layer shell keyboard mode to: on-demand") + layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND) + } else if (*keyboard)[0] == 'n' { + log.Info("Setting GTK layer shell keyboard mode to: none") + layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_NONE) + } else { + log.Warnf("Invalid option passed to --keyboard: %s)", *keyboard) + log.Warn("Setting GTK layer shell keyboard mode to default: exclusive") + layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_EXCLUSIVE) + } + } win.Connect("destroy", func() { From f85356bdc77169db772a889354a6dc85b8cd497f Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Sun, 23 Jul 2023 20:30:14 -0600 Subject: [PATCH 2/6] Drop keyboard mode: 'none' b/c it doesn't make sense with this app to not have keyboard input at all --- main.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/main.go b/main.go index 1850cf3..edcbb94 100644 --- a/main.go +++ b/main.go @@ -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: 'none', 'exclusive' or 'on-demand' (or 'n', 'e' or 'o')") +var keyboard = flag.String("k", "exclusive", "Set GTK layer shell keyboard interactivity: 'exclusive' or 'on-demand' (or: 'e', 'o')") 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") @@ -393,9 +393,6 @@ func main() { } else if (*keyboard)[0] == 'o' { log.Info("Setting GTK layer shell keyboard mode to: on-demand") layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND) - } else if (*keyboard)[0] == 'n' { - log.Info("Setting GTK layer shell keyboard mode to: none") - layershell.SetKeyboardMode(win, layershell.LAYER_SHELL_KEYBOARD_MODE_NONE) } else { log.Warnf("Invalid option passed to --keyboard: %s)", *keyboard) log.Warn("Setting GTK layer shell keyboard mode to default: exclusive") From d88d9795d1a55b76d23bf5a8fddc002f80d8a797 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Sun, 23 Jul 2023 22:22:41 -0600 Subject: [PATCH 3/6] Document --keyboard/-k flag in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index abe4a77..19b26fd 100644 --- a/README.md +++ b/README.md @@ -72,6 +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") -lang string force lang, e.g. "en", "pl" -nocats From 6bbfbea1a8e56fbb2cd5101f46572811a3d44a04 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Sun, 23 Jul 2023 22:45:16 -0600 Subject: [PATCH 4/6] Handle empty string passed to --keyboard/-k flag --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index edcbb94..8f37125 100644 --- a/main.go +++ b/main.go @@ -387,7 +387,11 @@ func main() { layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_RIGHT, *marginRight) layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_BOTTOM, *marginBottom) - if (*keyboard)[0] == 'e' { + if (*keyboard) == "" { + log.Warnf("Empty string passed to --keyboard: %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' { From aeeb4e4890b8929054745db1dd9dfd3f4c9c3af7 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Sun, 23 Jul 2023 22:49:52 -0600 Subject: [PATCH 5/6] Fix warn messages for short -k flag --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 8f37125..2447648 100644 --- a/main.go +++ b/main.go @@ -388,7 +388,7 @@ func main() { layershell.SetMargin(win, layershell.LAYER_SHELL_EDGE_BOTTOM, *marginBottom) if (*keyboard) == "" { - log.Warnf("Empty string passed to --keyboard: %s)", *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' { @@ -398,7 +398,7 @@ func main() { 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 --keyboard: %s)", *keyboard) + log.Warnf("Invalid option 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) } From 830edefa22f6e581812e1cf3292c2c0d88bffb97 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Mon, 24 Jul 2023 20:41:59 -0600 Subject: [PATCH 6/6] Refactor -k flag as Bool to toggle keyboard mode on-demand / exclusive --- README.md | 4 ++-- main.go | 14 +++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 19b26fd..619d76f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.go b/main.go index 2447648..a4778ca 100644 --- a/main.go +++ b/main.go @@ -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") @@ -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) }