mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
added --fn parameter to set font at run time
This commit is contained in:
parent
fb82daea9c
commit
bdfdf559b4
@ -71,7 +71,7 @@ static enum layout_id layers[] = {
|
|||||||
#include "keymap.mobintl.h"
|
#include "keymap.mobintl.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
static const char *fc_font_pattern = "Monospace 16";
|
static const char *default_font = "Monospace 15";
|
||||||
|
|
||||||
static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[],
|
static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[],
|
||||||
keys_arabic[],
|
keys_arabic[],
|
||||||
|
17
main.c
17
main.c
@ -347,7 +347,7 @@ usage(char *argv0)
|
|||||||
fprintf(stderr, " -o - Print press keys to standard output\n");
|
fprintf(stderr, " -o - Print press keys to standard output\n");
|
||||||
fprintf(stderr, " -l - Comma separated list of layers\n");
|
fprintf(stderr, " -l - Comma separated list of layers\n");
|
||||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||||
fprintf(stderr, " -fn [font] - Set font (Xft, e.g: DejaVu Sans:bold:size=20)\n");
|
fprintf(stderr, " -fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -355,6 +355,7 @@ main(int argc, char **argv) {
|
|||||||
/* parse command line arguments */
|
/* parse command line arguments */
|
||||||
int i;
|
int i;
|
||||||
char *layer_names_list = NULL;
|
char *layer_names_list = NULL;
|
||||||
|
const char *fc_font_pattern = NULL;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
uint32_t height = KBD_PIXEL_HEIGHT;
|
uint32_t height = KBD_PIXEL_HEIGHT;
|
||||||
|
|
||||||
@ -365,10 +366,10 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
for (i = 1; argv[i]; i++) {
|
for (i = 1; argv[i]; i++) {
|
||||||
if (!strcmp(argv[i], "-v")) {
|
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
||||||
printf("wvkbd-%s", VERSION);
|
printf("wvkbd-%s", VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (!strcmp(argv[i], "-h")) {
|
} else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "--help"))) {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (!strcmp(argv[i], "-l")) {
|
} else if (!strcmp(argv[i], "-l")) {
|
||||||
@ -387,6 +388,8 @@ main(int argc, char **argv) {
|
|||||||
height = atoi(argv[++i]);
|
height = atoi(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-D")) {
|
} else if (!strcmp(argv[i], "-D")) {
|
||||||
debug = true;
|
debug = true;
|
||||||
|
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||||
|
fc_font_pattern = estrdup(argv[++i]);
|
||||||
} else if (!strcmp(argv[i], "-o")) {
|
} else if (!strcmp(argv[i], "-o")) {
|
||||||
keyboard.print = true;
|
keyboard.print = true;
|
||||||
} else {
|
} else {
|
||||||
@ -396,6 +399,10 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fc_font_pattern) {
|
||||||
|
fc_font_pattern = default_font;
|
||||||
|
}
|
||||||
|
|
||||||
/* connect to compositor */
|
/* connect to compositor */
|
||||||
display = wl_display_connect(NULL);
|
display = wl_display_connect(NULL);
|
||||||
if (display == NULL) {
|
if (display == NULL) {
|
||||||
@ -452,5 +459,9 @@ main(int argc, char **argv) {
|
|||||||
while (wl_display_dispatch(display) != -1 && run_display) {
|
while (wl_display_dispatch(display) != -1 && run_display) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fc_font_pattern != default_font) {
|
||||||
|
free((void*) fc_font_pattern);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user