summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-04-22 16:14:09 -0600
committerGitHub <noreply@github.com>2019-04-22 16:14:09 -0600
commitf403cc07021d75f54752584ead2f53f5dc50b673 (patch)
tree2596b61eb26f59208f40689364c9cc63c0b3e67f
parent98e5afe364776d06017579e14f972be6f65fbb8b (diff)
parent4971afb52d03640aaf3e24b3cdbb7d901cbfbbc1 (diff)
Merge pull request #73 from jeremiah-miller/add-hide-keyboard-layout
Add hide keyboard layout option
-rw-r--r--include/swaylock.h1
-rw-r--r--main.c11
-rw-r--r--render.c3
-rw-r--r--swaylock.1.scd4
4 files changed, 17 insertions, 2 deletions
diff --git a/include/swaylock.h b/include/swaylock.h
index 23e3408..8bb8089 100644
--- a/include/swaylock.h
+++ b/include/swaylock.h
@@ -54,6 +54,7 @@ struct swaylock_args {
bool show_caps_lock_text;
bool show_caps_lock_indicator;
bool show_keyboard_layout;
+ bool hide_keyboard_layout;
bool show_failed_attempts;
bool daemonize;
};
diff --git a/main.c b/main.c
index 7af227c..63ba56c 100644
--- a/main.c
+++ b/main.c
@@ -550,6 +550,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
{"tiling", no_argument, NULL, 't'},
{"no-unlock-indicator", no_argument, NULL, 'u'},
{"show-keyboard-layout", no_argument, NULL, 'k'},
+ {"hide-keyboard-layout", no_argument, NULL, 'K'},
{"show-failed-attempts", no_argument, NULL, 'F'},
{"version", no_argument, NULL, 'v'},
{"bs-hl-color", required_argument, NULL, LO_BS_HL_COLOR},
@@ -607,6 +608,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
"Display the given image.\n"
" -k, --show-keyboard-layout "
"Display the current xkb layout while typing.\n"
+ " -K, --hide-keyboard-layout "
+ "Hide the current xkb layout while typing.\n"
" -L, --disable-caps-lock-text "
"Disable the Caps Lock text.\n"
" -l, --indicator-caps-lock "
@@ -700,7 +703,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
optind = 1;
while (1) {
int opt_idx = 0;
- c = getopt_long(argc, argv, "c:deFfhi:kLlnrs:tuvC:", long_options,
+ c = getopt_long(argc, argv, "c:deFfhi:kKLlnrs:tuvC:", long_options,
&opt_idx);
if (c == -1) {
break;
@@ -744,6 +747,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
state->args.show_keyboard_layout = true;
}
break;
+ case 'K':
+ if (state) {
+ state->args.hide_keyboard_layout = true;
+ }
+ break;
case 'L':
if (state) {
state->args.show_caps_lock_text = false;
@@ -1063,6 +1071,7 @@ int main(int argc, char **argv) {
.show_caps_lock_indicator = false,
.show_caps_lock_text = true,
.show_keyboard_layout = false,
+ .hide_keyboard_layout = false,
.show_failed_attempts = false
};
wl_list_init(&state.images);
diff --git a/render.c b/render.c
index 4538f22..6d65b96 100644
--- a/render.c
+++ b/render.c
@@ -156,7 +156,8 @@ void render_frame(struct swaylock_surface *surface) {
}
xkb_layout_index_t num_layout = xkb_keymap_num_layouts(state->xkb.keymap);
- if (state->args.show_keyboard_layout || num_layout > 1) {
+ if (!state->args.hide_keyboard_layout &&
+ (state->args.show_keyboard_layout || num_layout > 1)) {
xkb_layout_index_t curr_layout = 0;
// advance to the first active layout (if any)
diff --git a/swaylock.1.scd b/swaylock.1.scd
index 6588258..62e4bc7 100644
--- a/swaylock.1.scd
+++ b/swaylock.1.scd
@@ -55,6 +55,10 @@ Locks your Wayland session.
Force displaying the current xkb layout while typing, even if only one layout
is configured.
+*-K, --hide-keyboard-layout*
+ Force hiding the current xkb layout while typing, even if more than one layout
+ is configured or the show-keyboard-layout option is set.
+
*-L, --disable-caps-lock-text*
Disable the Caps Lock Text.