Add option to hide modkey text (#194)

* adds option to hide modkeys text

* Update i3lock.1

* Rename variable to `show_modkey_text`

* Keep style consistent

Co-authored-by: Raymond Li <hi@raymond.li>
This commit is contained in:
Alexis Coudert 2021-01-15 03:08:38 +01:00 committed by GitHub
parent e565e207fa
commit 9f774c84be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -369,6 +369,10 @@ Sets the string to be shown while acquiring pointer and keyboard focus. Defaults
.B \-\-lockfailedtext="text"
Sets the string to be shown after failing to acquire pointer and keyboard focus. Defaults to "lock failed!".
.TP
.B \-\-no-modkeytext
Hides the modkey indicator (Num, Caps Lock ...)
.TP
.B \-\-radius
The radius of the circle. Defaults to 90.

View File

@ -92,14 +92,18 @@ char greetercolor[9] = "000000ff";
/* int defining which display the lock indicator should be shown on. If -1, then show on all displays.*/
int screen_number = 0;
/* default is to use the supplied line color, 1 will be ring color, 2 will be to use the inside color for ver/wrong/etc */
int internal_line_source = 0;
/* bool for showing the clock; why am I commenting this? */
/* refresh rate in seconds, default to 1s */
float refresh_rate = 1.0;
bool show_clock = false;
bool slideshow_enabled = false;
bool always_show_clock = false;
bool show_indicator = false;
float refresh_rate = 1.0;
bool show_modkey_text = true;
/* there's some issues with compositing - upstream removed support for this, but we'll allow people to supply an arg to enable it */
bool composite = false;
@ -576,13 +580,15 @@ static void input_done(void) {
else if (strcmp(mod_name, XKB_MOD_NAME_LOGO) == 0)
mod_name = "Super";
char *tmp;
if (modifier_string == NULL) {
if (asprintf(&tmp, "%s", mod_name) != -1)
if (show_modkey_text) {
char *tmp;
if (modifier_string == NULL) {
if (asprintf(&tmp, "%s", mod_name) != -1)
modifier_string = tmp;
} else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) {
free(modifier_string);
modifier_string = tmp;
} else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) {
free(modifier_string);
modifier_string = tmp;
}
}
}
@ -1459,6 +1465,7 @@ int main(int argc, char *argv[]) {
{"locktext", required_argument, NULL, 516},
{"lockfailedtext", required_argument, NULL, 517},
{"greetertext", required_argument, NULL, 518},
{"no-modkeytext", no_argument, NULL, 519},
// fonts
{"time-font", required_argument, NULL, 520},
@ -1768,6 +1775,9 @@ int main(int argc, char *argv[]) {
break;
case 518:
greeter_text = optarg;
break;
case 519:
show_modkey_text = false;
break;
// Font stuff