Added password mode

This commit is contained in:
Scoopta 2019-10-22 21:19:57 -07:00
parent 9e96c9ee6a
commit 4bdd94a90e
2 changed files with 23 additions and 1 deletions

View File

@ -65,6 +65,7 @@ static void print_usage(char** argv) {
printf("--allow-markup\t-m\tAllows pango markup\n");
printf("--cache-file\t-k\tSets the cache file to use\n");
printf("--term\t\t-t\tSpecifies the terminal to use when running in a term\n");
printf("--password\t-P\tRuns in password mode\n");
exit(0);
}
@ -270,6 +271,12 @@ int main(int argc, char** argv) {
.flag = NULL,
.val = 't'
},
{
.name = "password",
.has_arg = optional_argument,
.flag = NULL,
.val = 'P'
},
{
.name = NULL,
.has_arg = 0,
@ -292,8 +299,9 @@ int main(int argc, char** argv) {
char* allow_markup = NULL;
char* cache_file = NULL;
char* terminal = NULL;
char* password_char = "false";
char opt;
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nimk:t:", opts, NULL)) != -1) {
while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nimk:t:P::", opts, NULL)) != -1) {
switch(opt) {
case 'h':
print_usage(argv);
@ -351,6 +359,9 @@ int main(int argc, char** argv) {
case 't':
terminal = optarg;
break;
case 'P':
password_char = optarg;
break;
}
}
@ -459,6 +470,12 @@ int main(int argc, char** argv) {
if(terminal != NULL) {
map_put(config, "term", terminal);
}
if(password_char == NULL || (password_char != NULL && strcmp(password_char, "false") != 0)) {
if(password_char == NULL) {
password_char = "*";
}
map_put(config, "password_char", password_char);
}
gtk_init(&argc, &argv);

View File

@ -463,6 +463,7 @@ void wofi_init(struct map* config) {
cache_file = map_get(config, "cache_file");
config_dir = map_get(config, "config_dir");
terminal = map_get(config, "term");
char* password_char = map_get(config, "password_char");
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(window);
@ -500,6 +501,10 @@ void wofi_init(struct map* config) {
gtk_widget_set_name(entry, "input");
gtk_entry_set_placeholder_text(GTK_ENTRY(entry), prompt);
gtk_container_add(GTK_CONTAINER(outer_box), entry);
if(password_char != NULL) {
gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
gtk_entry_set_invisible_char(GTK_ENTRY(entry), password_char[0]);
}
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_widget_set_name(scroll, "scroll");