libinput has many options - let's support an important one.
Closed this issue ยท 12 comments
I don't know about you (you - as in anyone reading this) but the first thing I do on any laptop is enable tap-to-click.
Perhaps, without making this app too complex, this should be an option in the GUI.
Thanks for consideration, and if you don't mind @johanmalm I might take a look if you think this is a necessary option.
I'll await your response before proceeding :^)
Anyone else post your opinion either way.
Things to consider :
- does the machine have a touchpad?
- if so is it enabled?
- if not, how do we hide that option, or do we just make it insensitive?
Thanks for reading.
Things to consider :
- does the machine have a touchpad?
- if so is it enabled?
- if not, how do we hide that option, or do we just make it insensitive?
does the machine have a touchpad? >> if it has a battery then it's likely not a desktop
if so is it enabled? >> maybe the kernel knows?
if not, how do we hide that option, or do we just make it insensitive? >> probably just make that entry insensitive.
@Consolatis in IRC also mentioned that keyboard layout might be handy in *tweaks. Might be a bit more interesting (as in difficult) to add that capability. Really (IMHO), keyboard layout should be a distro thing, or at least wlroots, and all the other keyboard options, model, variant, rules.
Iโm easy.
labwc sets tap-enabled by default ๐
Setting the keyboard layout is a good idea - but might a lot harder to do.
Hmm.. my rough attempt to find keyboard layouts - just need to confirm the general location of evdev.lst
. Might give someone some ideas ๐
#include <stdio.h>
#include <glib.h>
#include <glib/gprintf.h>
#define MAXLN 255
FILE *fp;
char buf[MAXLN];
const char *lt = "! layout";
const char *vt = "! variant";
const char *evdev = "/etc/X11/xkb/rules/evdev.lst";
guint l = 8;
guint v = 9;
/**
* get the line number of the layout and the variant as to find
* all the layouts as they are between these two comments
*/
int
get_ln(const char *s, int i) {
int ret, x;
fp = fopen(evdev, "r");
if (fp == NULL) {
perror("Error opening file");
exit (EXIT_FAILURE);
}
x = 1;
while (fgets(buf, MAXLN, fp)) {
if (g_ascii_strncasecmp(buf, s, i) != 0) {
x += 1;
continue;
}
ret = x;
}
fclose(fp);
return ret;
}
/**
* iterate through all the layouts
*/
void
get_layouts(void) {
int n = 0; /* line count */
int y = get_ln(lt, l) + 1; /* line no of "! layout" */
int z = get_ln(vt, v) -2 ; /* line no of "! variant" */
int w = y + z;
fp = fopen(evdev, "r");
if (fp == NULL) {
perror("Error opening file");
exit (EXIT_FAILURE);
}
while (fgets(buf, MAXLN, fp)) {
n += 1;
if (n < y) {
continue;
}
if (n > z) {
break;
}
if ((n >= y) && (n <= w)) {
g_printf("%s", buf);
}
}
fclose(fp);
}
int
main(void) {
get_layouts();
return 0;
}
edit: remove new line
Good find. On my machine it's at /usr/share/X11/xkb/rules/evdev.lst
Good find. On my machine it's at
/usr/share/X11/xkb/rules/evdev.lst
same for me (Debian).
Yeah I think slack puts it in the legacy location, and symlinks /usr/share/X11/xkb
so I think we could safely assume that evdev.lst
can be found at /usr/share/X11/xkb/rules/evdev.lst
. A simple test for that to catch errors would be simple.
hello
can confirm also Void Linux evdev.lst is in /usr/share/X11/xkb/rules
thanks @01micko for pointing me here.
Just getting back to adding keyboard layout, we should probably support 2 layouts as an option
- a combobox with the layouts
gtk_widget_set_sensitive (main_layout, TRUE)
- beside that a second combobox with the layouts, with
sensitive
set toFALSE
gtk_widget_set_sensitive (second_layout, FALSE)
- a
checkbox
with the blurb "Check for second layout", and when checked sets the second comboboxsensitive
toTRUE
and when that is set toTRUE
the variableXKB_DEFAULT_OPTIONS=grp:alt_shift_toggle
is set
I plan to work on this soon.
That would limit the possible layouts to 2. It would also waste screen-space when there is only a single layout required (this is not that much of an issue though).
Could we instead add a button like Add layout
(or a +
sign) which creates a new combobox with all the layouts (+ a Remove this layout
/ -
button)? And if multiple layouts are set, we could automatically add the toggle env var.
That would limit the possible layouts to 2. It would also waste screen-space when there is only a single layout required (this is not that much of an issue though).
Could we instead add a button like
Add layout
(or a+
sign) which creates a new combobox with all the layouts (+ aRemove this layout
/-
button)? And if multiple layouts are set, we could automatically add the toggle env var.
Sure, shouldn't be much different.
Simplified version (at least I think it's simpler ๐)
#define _POSIX_C_SOURCE 200809L
#include <glib.h>
#include <stdbool.h>
#include <stdio.h>
void
print_layouts(const char *filename)
{
bool in_layout_section = false;
char *line = NULL;
size_t len = 0;
FILE *fp = fopen(filename, "r");
if (!fp) {
perror("Error opening file");
exit (EXIT_FAILURE);
}
while (getline(&line, &len, fp) != -1) {
char *p = strrchr(line, '\n');
if (p) {
*p = '\0';
}
if (line[0] == '\0') {
continue;
} else if (line[0] == '!') {
in_layout_section = g_ascii_strncasecmp(line, "! layout", len) == 0;
} else if (in_layout_section) {
printf("%s\n", line);
}
}
free(line);
fclose(fp);
}
int
main(void)
{
print_layouts("/usr/share/X11/xkb/rules/evdev.lst");
return 0;
}
It works ;-)