ir-keytable: Smarter keytable location handling
cover ir-keytable: Smarter keytable location handling
Hello,
this patchset will improve the keytable location handling of ir-keytable. In controst to the default install location (/etc/rc_keymaps) Debian and Ubuntu installed the shipped keymaps into /lib/udev/rc_keymaps (just like keyboard keymaps are installed into /lib/udev/keymaps). If a keymap needs to be modified it's supposed to go into /etc/rc_keymaps.
The current ir-keytable program knows only about a single default keytable directory. This patchset makes ir-keytable aware of a system and user keytable directory. The user directory is searched first, followed by a the system directory if no file was found.
Mauro, are you OK with committing?
Thanks,
Gregor
Gregor Jasny (3):
keytable: Make udev rules dir configurable
keytable: Preinstall keytables relative to sysconfdir
keytable: first search table in userdir, then in systemdir
configure.ac | 15 +++++++++++---- utils/keytable/Makefile.am | 8 ++++---- utils/keytable/keytable.c | 30 +++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.10
PATCH 1/3 keytable: Make udev rules dir configurable
--- configure.ac | 7 +++++-- utils/keytable/Makefile.am | 1 - 2 files changed, 5 insertions(+), 3 deletions(-)
configure.ac +5 -2
@@ -145,13 +145,16 @@ AC_ARG_WITH(libv4l2subdir, AS_HELP_STRING(--with-libv4l2subdir=DIR,set libv4l2 l AC_ARG_WITH(libv4lconvertsubdir, AS_HELP_STRING(--with-libv4lconvertsubdir=DIR,set libv4lconvert library subdir [default=libv4l]), libv4lconvertsubdir=$withval, libv4lconvertsubdir="libv4l") +AC_ARG_WITH(udevdir, AS_HELP_STRING(--with-udevdir=DIR,set udev directory [default=/lib/udev]), + udevdir=$withval, udevdir="/lib/udev") + libv4l1privdir="$libdir/$libv4l1subdir" libv4l2privdir="$libdir/$libv4l2subdir" libv4l2plugindir="$libv4l2privdir/plugins" libv4lconvertprivdir="$libdir/$libv4lconvertsubdir" rootetcdir="/etc" -rootlibdir="/lib" +udevrulesdir="$udevdir/rules.d" pkgconfigdir="$libdir/pkgconfig" AC_SUBST(libv4l1privdir)
@@ -159,7 +162,7 @@ AC_SUBST(libv4l2privdir) AC_SUBST(libv4l2plugindir) AC_SUBST(libv4lconvertprivdir) AC_SUBST(rootetcdir) -AC_SUBST(rootlibdir) +AC_SUBST(udevrulesdir) AC_SUBST(pkgconfigdir) AC_DEFINE_UNQUOTED([V4L_UTILS_VERSION], ["$PACKAGE_VERSION"], [v4l-utils version string])
utils/keytable/Makefile.am +0 -1
@@ -1,4 +1,3 @@ -udevrulesdir="/lib/udev/rules.d" rootetcdir="/etc" bin_PROGRAMS = ir-keytable
Signature · 1 line
1.7.10
PATCH 2/3 keytable: Preinstall keytables relative to sysconfdir
In reply to Gregor Jasny--- configure.ac | 5 +++-- utils/keytable/Makefile.am | 5 ++--- utils/keytable/keytable.c | 7 ++----- 3 files changed, 7 insertions(+), 10 deletions(-)
configure.ac +3 -2
@@ -153,7 +153,7 @@ libv4l2privdir="$libdir/$libv4l2subdir" libv4l2plugindir="$libv4l2privdir/plugins" libv4lconvertprivdir="$libdir/$libv4lconvertsubdir" -rootetcdir="/etc" +keytablesystemdir="$sysconfdir/rc_keymaps" udevrulesdir="$udevdir/rules.d" pkgconfigdir="$libdir/pkgconfig"
@@ -161,7 +161,7 @@ AC_SUBST(libv4l1privdir) AC_SUBST(libv4l2privdir) AC_SUBST(libv4l2plugindir) AC_SUBST(libv4lconvertprivdir) -AC_SUBST(rootetcdir) +AC_SUBST(keytablesystemdir) AC_SUBST(udevrulesdir) AC_SUBST(pkgconfigdir)
@@ -170,6 +170,7 @@ AC_DEFINE_DIR([LIBV4L1_PRIV_DIR], [libv4l1privdir], [libv4l1 private lib directo AC_DEFINE_DIR([LIBV4L2_PRIV_DIR], [libv4l2privdir], [libv4l2 private lib directory]) AC_DEFINE_DIR([LIBV4L2_PLUGIN_DIR], [libv4l2plugindir], [libv4l2 plugin directory]) AC_DEFINE_DIR([LIBV4LCONVERT_PRIV_DIR], [libv4lconvertprivdir], [libv4lconvert private lib directory]) +AC_DEFINE_DIR([IR_KEYTABLE_SYSTEM_DIR], [keytablesystemdir], [ir-keytable preinstalled tables directory]) # options
utils/keytable/Makefile.am +2 -3
@@ -1,8 +1,7 @@ -rootetcdir="/etc" - bin_PROGRAMS = ir-keytable man_MANS = ir-keytable.1 -nobase_rootetc_DATA = rc_maps.cfg $(srcdir)/rc_keymaps/* +sysconf_DATA = rc_maps.cfg +keytablesystem_DATA = $(srcdir)/rc_keymaps/* udevrules_DATA = 70-infrared.rules ir_keytable_SOURCES = keytable.c parse.h
utils/keytable/keytable.c +2 -5
@@ -28,9 +28,6 @@#include "parse.h" -/* Default place where the keymaps will be stored */ -#define CFGDIR "/etc/rc_keymaps" -struct input_keymap_entry_v2 {#define KEYMAP_BY_INDEX (1 << 0)u_int8_t flags;
@@ -1516,8 +1513,8 @@ int main(int argc, char *argv[])if (cur->fname[0 ] =='/' || ((cur->fname[0 ] =='.' ) &&strchr (cur->fname,'/' ))) { fname = cur->fname; }else { - fname =malloc (strlen (cur->fname) +strlen (CFGDIR ) +2 ); -strcpy (fname,CFGDIR ); + fname =malloc (strlen (cur->fname) +strlen (IR_KEYTABLE_SYSTEM_DIR ) +2 ); +strcpy (fname,IR_KEYTABLE_SYSTEM_DIR );strcat (fname,"/" );strcat (fname, cur->fname); }
Signature · 1 line
1.7.10
PATCH 3/3 keytable: first search table in userdir, then in systemdir
In reply to Gregor Jasny--- configure.ac | 5 ++++- utils/keytable/Makefile.am | 2 ++ utils/keytable/keytable.c | 27 +++++++++++++++++++++------ 3 files changed, 27 insertions(+), 7 deletions(-)
configure.ac +4 -1
@@ -153,7 +153,8 @@ libv4l2privdir="$libdir/$libv4l2subdir" libv4l2plugindir="$libv4l2privdir/plugins" libv4lconvertprivdir="$libdir/$libv4lconvertsubdir" -keytablesystemdir="$sysconfdir/rc_keymaps" +keytablesystemdir="$udevdir/rc_keymaps" +keytableuserdir="$sysconfdir/rc_keymaps" udevrulesdir="$udevdir/rules.d" pkgconfigdir="$libdir/pkgconfig"
@@ -162,6 +163,7 @@ AC_SUBST(libv4l2privdir) AC_SUBST(libv4l2plugindir) AC_SUBST(libv4lconvertprivdir) AC_SUBST(keytablesystemdir) +AC_SUBST(keytableuserdir) AC_SUBST(udevrulesdir) AC_SUBST(pkgconfigdir)
@@ -171,6 +173,7 @@ AC_DEFINE_DIR([LIBV4L2_PRIV_DIR], [libv4l2privdir], [libv4l2 private lib directo AC_DEFINE_DIR([LIBV4L2_PLUGIN_DIR], [libv4l2plugindir], [libv4l2 plugin directory]) AC_DEFINE_DIR([LIBV4LCONVERT_PRIV_DIR], [libv4lconvertprivdir], [libv4lconvert private lib directory]) AC_DEFINE_DIR([IR_KEYTABLE_SYSTEM_DIR], [keytablesystemdir], [ir-keytable preinstalled tables directory]) +AC_DEFINE_DIR([IR_KEYTABLE_USER_DIR], [keytableuserdir], [ir-keytable user defined tables directory]) # options
utils/keytable/Makefile.am +2 -0
@@ -10,6 +10,8 @@ ir_keytable_LDFLAGS = $(ARGP_LIBS) EXTRA_DIST = 70-infrared.rules rc_keymaps gen_keytables.pl ir-keytable.1 rc_maps.cfg # custom target +install-data-local: + $(install_sh) -d "$(DESTDIR)$(keytableuserdir)" sync-with-kernel: @if [ ! -f $(KERNEL_DIR)/include/linux/input.h ]; then \
utils/keytable/keytable.c +21 -6
@@ -194,7 +194,6 @@ static error_t parse_keyfile(char *fname, char **table) fin =fopen (fname,"r" );if (!fin) { -perror ("opening keycode file" );return errno; }
@@ -1512,15 +1511,31 @@ int main(int argc, char *argv[]) cur->fname);if (cur->fname[0 ] =='/' || ((cur->fname[0 ] =='.' ) &&strchr (cur->fname,'/' ))) { fname = cur->fname; + rc =parse_keyfile (fname, &name); +if (rc <0 ) { +fprintf (stderr,"Can't load %s table\n" , fname); +return -1 ; + } }else { - fname =malloc (strlen (cur->fname) +strlen (IR_KEYTABLE_SYSTEM_DIR ) +2 ); -strcpy (fname,IR_KEYTABLE_SYSTEM_DIR ); + fname =malloc (strlen (cur->fname) +strlen (IR_KEYTABLE_USER_DIR ) +2 ); +strcpy (fname,IR_KEYTABLE_USER_DIR );strcat (fname,"/" );strcat (fname, cur->fname); + rc =parse_keyfile (fname, &name); +if (rc !=0 ) { + fname =malloc (strlen (cur->fname) +strlen (IR_KEYTABLE_SYSTEM_DIR ) +2 ); +strcpy (fname,IR_KEYTABLE_SYSTEM_DIR ); +strcat (fname,"/" ); +strcat (fname, cur->fname); + rc =parse_keyfile (fname, &name); + } +if (rc !=0 ) { +fprintf (stderr,"Can't load %s table from %s or %s\n" , cur->fname,IR_KEYTABLE_USER_DIR ,IR_KEYTABLE_SYSTEM_DIR ); +return -1 ; + } } - rc =parse_keyfile (fname, &name); -if (rc <0 || !keys.next) { -fprintf (stderr,"Can't load %s table or empty table\n" , fname); +if (!keys.next) { +fprintf (stderr,"Empty table %s\n" , fname);return -1 ; } clear =1 ;
Signature · 1 line
1.7.10