summaryrefslogtreecommitdiffstats
path: root/system/esekeyd
diff options
context:
space:
mode:
author B. Watson <yalhcru@gmail.com>2020-11-07 09:19:34 +0700
committer Willy Sudiarto Raharjo <willysr@slackbuilds.org>2020-11-07 09:19:34 +0700
commit47a78898453311a5e9a99c9fa5e5a6f0e39c63c5 (patch)
tree8c9ffa1bbc1400decd5577268cbd65bbedc7a7eb /system/esekeyd
parent7a488761668693ab154a8bc76bf5bcc00e128712 (diff)
downloadslackbuilds-47a78898453311a5e9a99c9fa5e5a6f0e39c63c5.tar.gz
slackbuilds-47a78898453311a5e9a99c9fa5e5a6f0e39c63c5.tar.xz
system/esekeyd: Added (multimedia keyboard daemon for Linux).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system/esekeyd')
-rw-r--r--system/esekeyd/README26
-rw-r--r--system/esekeyd/config.snippet22
-rw-r--r--system/esekeyd/doinst.sh11
-rw-r--r--system/esekeyd/esekeyd.SlackBuild100
-rw-r--r--system/esekeyd/esekeyd.info10
-rw-r--r--system/esekeyd/keyboard_detection.diff101
-rw-r--r--system/esekeyd/slack-desc19
7 files changed, 289 insertions, 0 deletions
diff --git a/system/esekeyd/README b/system/esekeyd/README
new file mode 100644
index 0000000000..3c5817bd65
--- /dev/null
+++ b/system/esekeyd/README
@@ -0,0 +1,26 @@
+esekeyd (multimedia keyboard daemon for Linux)
+
+ESE Key Daemon is a multimedia keyboard daemon for Linux. With
+the 2.6 kernel series it can also handle remote controls, as they
+are presented as keyboards. It's a userspace program that polls
+/dev/input/event? interfaces for incoming keypresses, and executes
+commands as defined in its config file.
+
+esekeyd is also useful for keyboards without multimedia keys. Its
+functionality is similar to xbindkeys, but (a) it doesn't require X
+(works in the console), and (b) it doesn't "eat" the keystrokes it
+receives, so you'll want to disable those keycodes in your keymap
+if you don't want applications to react to them (see loadkeys(1) and
+keymaps(5)).
+
+To start using esekeyd, first edit /etc/esekeyd.conf to define your
+keys and the programs that will be run (use "learnkeys" to get
+the names of the keys). Then start the esekeyd daemon by running
+"/usr/sbin/esekeyd /etc/esekeyd.conf" (as root, or as a user in the
+input group). To start esekeyd at boot, just add that command to
+/etc/rc.d/rc.local.
+
+If esekeyd never sees your keystrokes, you may have to explicitly set
+the input device for it to use on the command line (see the esekeyd(1)
+man page). Also, for testing purposes, see the "Simple test" section
+at the end of /etc/esekeyd.conf.
diff --git a/system/esekeyd/config.snippet b/system/esekeyd/config.snippet
new file mode 100644
index 0000000000..4b01f3bce5
--- /dev/null
+++ b/system/esekeyd/config.snippet
@@ -0,0 +1,22 @@
+
+###
+# Simple test: Uncomment the next two lines:
+
+#KEY_87:touch /tmp/esekeyd_works
+#KEY_88:rm -f /tmp/esekeyd_works
+
+# Then start up esekeyd with this config file:
+# esekeyd /etc/esekeyd.conf
+# Then run:
+# watch -n 1 ls /tmp/esekeyd_works
+# Press F11 and F12 to see the file get created and deleted.
+# If you can't use F11 and F12 for some reason, run "keytest" and
+# press e.g. A and Z, change the KEY_ numbers to the ones you see
+# for those keys.
+
+# If nothing happens, you may have to find out which
+# /dev/input/event* device is your keyboard and add that to the
+# esekeyd command line. Try something like:
+# ls -l /dev/input/by-id/*-kbd
+# ...or install and run evtest.
+###
diff --git a/system/esekeyd/doinst.sh b/system/esekeyd/doinst.sh
new file mode 100644
index 0000000000..b1bc6d67f6
--- /dev/null
+++ b/system/esekeyd/doinst.sh
@@ -0,0 +1,11 @@
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
+ rm $NEW
+ fi
+}
+
+config etc/esekeyd.conf.new
diff --git a/system/esekeyd/esekeyd.SlackBuild b/system/esekeyd/esekeyd.SlackBuild
new file mode 100644
index 0000000000..aca4698c74
--- /dev/null
+++ b/system/esekeyd/esekeyd.SlackBuild
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# Slackware build script for esekeyd
+
+# Written by B. Watson (yalhcru@gmail.com)
+
+# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+
+PRGNAM=esekeyd
+VERSION=${VERSION:-1.2.7}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
+elif [ "$ARCH" = "x86_64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+else
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+fi
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$PRGNAM-$VERSION.tar.gz
+cd $PRGNAM-$PRGNAM-$VERSION
+
+# The license is supposed to be GPL3, but it's shipped as a symlink
+# to /usr/share/automake-1.10/COPYING, which doesn't even exist on
+# Slackware 14.2. Use a copy that does exist.
+rm -f COPYING
+cp $( /bin/ls /usr/share/automake-*/COPYING | head -1 ) .
+
+chown -R root:root .
+find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
+ \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
+
+# Typo in man pages.
+sed -i 's,pools,polls,g' doc/*.1
+
+# The keyboard autodetection code is outdated and broken. Patch has
+# been sent upstream and will hopefully be incorporated in the next
+# release.
+patch -p1 < $CWD/keyboard_detection.diff
+
+[ -e configure ] || sh bootstrap
+
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --sysconfdir=/etc \
+ --localstatedir=/var \
+ --mandir=/usr/man \
+ --docdir=/usr/doc/$PRGNAM-$VERSION \
+ --build=$ARCH-slackware-linux
+
+make
+make install-strip DESTDIR=$PKG
+gzip $PKG/usr/man/man?/*.?
+
+# Example config. As shipped, but with all the commands commented out.
+# Also add a simpler example that everyone should be able to use.
+mkdir -p $PKG/etc
+sed 's,^.,#&,' examples/example.conf > $PKG/etc/$PRGNAM.conf.new
+cat $CWD/config.snippet >> $PKG/etc/$PRGNAM.conf.new
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a AUTHORS COPYING ChangeLog NEWS README TODO $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/system/esekeyd/esekeyd.info b/system/esekeyd/esekeyd.info
new file mode 100644
index 0000000000..385c0e8a92
--- /dev/null
+++ b/system/esekeyd/esekeyd.info
@@ -0,0 +1,10 @@
+PRGNAM="esekeyd"
+VERSION="1.2.7"
+HOMEPAGE="https://github.com/burghardt/esekeyd"
+DOWNLOAD="https://github.com/burghardt/esekeyd/archive/esekeyd-1.2.7/esekeyd-esekeyd-1.2.7.tar.gz"
+MD5SUM="e8ba0f4f0bc2080f1a9da17b52f86805"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="B. Watson"
+EMAIL="yalhcru@gmail.com"
diff --git a/system/esekeyd/keyboard_detection.diff b/system/esekeyd/keyboard_detection.diff
new file mode 100644
index 0000000000..97e93bcdce
--- /dev/null
+++ b/system/esekeyd/keyboard_detection.diff
@@ -0,0 +1,101 @@
+diff -Naur esekeyd-esekeyd-1.2.7/src/input.c esekeyd-esekeyd-1.2.7.patched/src/input.c
+--- esekeyd-esekeyd-1.2.7/src/input.c 2010-07-04 16:23:51.000000000 -0400
++++ esekeyd-esekeyd-1.2.7.patched/src/input.c 2020-11-01 20:22:49.777498592 -0500
+@@ -10,6 +10,14 @@
+
+ #include "esekey.h"
+
++#include <dirent.h>
++#define CLASS_DIR "/sys/class/input"
++#define DEV_DIR "/dev/input"
++
++#ifndef PATH_MAX
++# define PATH_MAX 1024
++#endif
++
+ signed char check_handlers (void)
+ {
+ FILE *fp = NULL;
+@@ -45,32 +53,63 @@
+ return 0;
+ }
+
+-signed char find_input_dev (void)
++/* return true if /dev/input/event<devno> is a keyboard.
++ This could also have been done by way of ioctls instead of reading
++ from /sys files. Hopefully the /sys API doesn't change...
++ It's documented thoroughly here:
++ https://unix.stackexchange.com/questions/74903/explain-ev-in-proc-bus-input-devices-data
++ */
++int is_keyboard(int devno)
+ {
+- FILE *fp = NULL;
+- signed char have_evdev = -2;
++ char filename[PATH_MAX + 1];
++ char *buf = NULL;
++ size_t len = 0, caps = 0;
++ size_t wantcaps = (1 << EV_SYN | 1 << EV_KEY | 1 << EV_MSC | 1 << EV_LED | 1 << EV_REP);
++ FILE *fp;
++
++ sprintf(filename, "%s/event%d/device/capabilities/ev", CLASS_DIR, devno);
++ if(!(fp = fopen(filename, "r"))) return 0;
++
++ getline(&buf, &len, fp);
++ fclose(fp);
++ if(!buf) return 0;
+
+- fp = fopen (INPUT_DEVICES, "r");
++ caps = strtol(buf, NULL, 16);
++ free(buf);
+
+- if (!fp)
++ return (caps & wantcaps) == wantcaps;
++}
++
++/* returns the highest-numbered keyboard found. The common case is
++ that the internal keyboard on a laptop is numbered lower than an external
++ keyboard, and we assume that if there's an external, it's the one the
++ user actually uses. If no keyboards are found, returns -1. */
++signed char find_input_dev (void)
++{
++ DIR *dir;
++ struct dirent *entry;
++ int last_kbd = -1;
++ char buf[PATH_MAX + 1];
++
++ dir = opendir(CLASS_DIR);
++ if(!dir) {
++ perror(CLASS_DIR);
+ return -1;
++ }
+
+- while (!feof (fp))
+- {
+- char *buff = NULL;
+- size_t len = 0;
+- short int number = -2;
+- getline (&buff, &len, fp);
+- sscanf (buff, "H: Handlers=kbd event%hu", &number);
+- free (buff);
+- if (number > -1)
+- {
+- have_evdev = number;
+- break;
++ while( (entry = readdir(dir)) ) {
++ sprintf(buf, "%s/%s", CLASS_DIR, entry->d_name);
++ if(strncmp(entry->d_name, "event", 5) == 0) {
++ int devno = atoi(entry->d_name + 5);
++ if(is_keyboard(devno)) {
++ fprintf(stderr, "event%d is a keyboard\n", devno);
++ if(devno > last_kbd) last_kbd = devno;
++ }
+ }
+ }
++ closedir(dir);
+
+- fclose (fp);
++ fprintf(stderr, "Autodetected keyboard: %s/event%d\n", DEV_DIR, last_kbd);
+
+- return have_evdev;
++ return last_kbd;
+ }
diff --git a/system/esekeyd/slack-desc b/system/esekeyd/slack-desc
new file mode 100644
index 0000000000..60a565adc5
--- /dev/null
+++ b/system/esekeyd/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.
+# Line up the first '|' above the ':' following the base package name, and
+# the '|' on the right side marks the last column you can put a character in.
+# You must make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':' except on otherwise blank lines.
+
+ |-----handy-ruler------------------------------------------------------|
+esekeyd: esekeyd (multimedia keyboard daemon for Linux)
+esekeyd:
+esekeyd: ESE Key Daemon is a multimedia keyboard daemon for Linux. With
+esekeyd: the 2.6 kernel series it can also handle remote controls, as they
+esekeyd: are presented as keyboards. It's a userspace program that polls
+esekeyd: /dev/input/event? interfaces for incoming keypresses, and executes
+esekeyd: commands as defined in its config file.
+esekeyd:
+esekeyd: esekeyd is also useful for keyboards without multimedia keys. Its
+esekeyd: functionality is similar to xbindkeys, but it doesn't require X
+esekeyd: (works in the console).