From cf5a17ed96a1ab81318d37332a0f61ee817db941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teo=20Klestrup=20R=C3=B6ijezon?= Date: Wed, 7 Feb 2018 00:50:46 +0100 Subject: [PATCH] libinput-gestures: init at 2.32 xf86-input-synaptics is unmaintained, and touchegg doesn't work with the latest synaptics driver or libinput. Ideally DEs would implement this themselves, but at least KDE/Plasma doesn't (yet) 0002-paths.patch was contributed by @peterhoeg. --- .../0001-hardcode-name.patch | 13 +++++ .../libinput-gestures/0002-paths.patch | 43 +++++++++++++++ .../libinput-gestures/default.nix | 54 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 112 insertions(+) create mode 100644 pkgs/tools/inputmethods/libinput-gestures/0001-hardcode-name.patch create mode 100644 pkgs/tools/inputmethods/libinput-gestures/0002-paths.patch create mode 100644 pkgs/tools/inputmethods/libinput-gestures/default.nix diff --git a/pkgs/tools/inputmethods/libinput-gestures/0001-hardcode-name.patch b/pkgs/tools/inputmethods/libinput-gestures/0001-hardcode-name.patch new file mode 100644 index 000000000000..b694fcabbd0d --- /dev/null +++ b/pkgs/tools/inputmethods/libinput-gestures/0001-hardcode-name.patch @@ -0,0 +1,13 @@ +diff --git a/libinput-gestures b/libinput-gestures +index f337ba3..fe56d66 100755 +--- a/libinput-gestures ++++ b/libinput-gestures +@@ -6,7 +6,7 @@ from collections import OrderedDict + from pathlib import Path + from distutils.version import LooseVersion as Version + +-PROG = Path(sys.argv[0]).stem ++PROG = "libinput-gestures" + + # Conf file containing gesture commands. + # Search first for user file then system file. diff --git a/pkgs/tools/inputmethods/libinput-gestures/0002-paths.patch b/pkgs/tools/inputmethods/libinput-gestures/0002-paths.patch new file mode 100644 index 000000000000..c6ee123db8b6 --- /dev/null +++ b/pkgs/tools/inputmethods/libinput-gestures/0002-paths.patch @@ -0,0 +1,43 @@ +diff --git a/libinput-gestures b/libinput-gestures +index f337ba3..5f5b05d 100755 +--- a/libinput-gestures ++++ b/libinput-gestures +@@ -75,17 +75,13 @@ def get_libinput_vers(): + 'Return the libinput installed version number string' + # Try to use newer libinput interface then fall back to old + # (depreciated) interface. +- res = run(('libinput', '--version'), check=False) ++ res = run(('@libinput@', '--version'), check=False) + return res.strip() if res else run(('libinput-list-devices', '--version')) + + # Libinput changed the way in which it's utilities are called + libvers = get_libinput_vers() +-if Version(libvers) >= Version('1.8'): +- cmd_debug_events = 'libinput debug-events' +- cmd_list_devices = 'libinput list-devices' +-else: +- cmd_debug_events = 'libinput-debug-events' +- cmd_list_devices = 'libinput-list-devices' ++cmd_debug_events = '@libinput@ debug-events' ++cmd_list_devices = '@libinput@ list-devices' + + def get_devices_list(): + 'Get list of devices and their attributes (as a dict) from libinput' +@@ -187,7 +183,7 @@ class COMMAND_internal(COMMAND): + + def run(self): + 'Get list of current workspaces and select next one' +- stdout = run(('wmctrl', '-d'), check=False) ++ stdout = run(('@wmctrl@', '-d'), check=False) + if not stdout: + # This command can fail on GNOME when you have only a single + # dynamic workspace using Xorg (probably a GNOME bug) so let's +@@ -220,7 +216,7 @@ class COMMAND_internal(COMMAND): + + # Switch to desired workspace + if index >= minindex and index < maxindex: +- run(('wmctrl', '-s', str(index))) ++ run(('@wmctrl@', '-s', str(index))) + + # Table of gesture handlers + handlers = OrderedDict() diff --git a/pkgs/tools/inputmethods/libinput-gestures/default.nix b/pkgs/tools/inputmethods/libinput-gestures/default.nix new file mode 100644 index 000000000000..e58cabc6791a --- /dev/null +++ b/pkgs/tools/inputmethods/libinput-gestures/default.nix @@ -0,0 +1,54 @@ +{ lib, stdenv, fetchFromGitHub, makeWrapper, + libinput, wmctrl, + xdotool ? null, + extraUtilsPath ? lib.optional (xdotool != null) xdotool +}: +stdenv.mkDerivation rec { + pname = "libinput-gestures"; + version = "2.32"; + name = "${pname}-${version}"; + + src = fetchFromGitHub { + owner = "bulletmark"; + repo = "libinput-gestures"; + rev = version; + sha256 = "1by6sabx0s8sd9w5675gc26q7yccxnxxsjg4dqlb6nbs0vcg81s7"; + }; + patches = [ + ./0001-hardcode-name.patch + ./0002-paths.patch + ]; + + nativeBuildInputs = [ makeWrapper ]; + + postPatch = + '' + substituteInPlace libinput-gestures-setup --replace /usr/ / + + substituteInPlace libinput-gestures \ + --replace /etc "$out/etc" \ + --subst-var-by libinput "${libinput}/bin/libinput" \ + --subst-var-by wmctrl "${wmctrl}/bin/wmctrl" + ''; + installPhase = + '' + runHook preInstall + ${stdenv.shell} libinput-gestures-setup -d "$out" install + runHook postInstall + ''; + postFixup = + '' + rm "$out/bin/libinput-gestures-setup" + substituteInPlace "$out/share/applications/libinput-gestures.desktop" --replace "/usr" "$out" + chmod +x "$out/share/applications/libinput-gestures.desktop" + wrapProgram "$out/bin/libinput-gestures" --prefix PATH : "${lib.makeBinPath extraUtilsPath}" + ''; + + meta = with stdenv.lib; { + homepage = https://github.com/bulletmark/libinput-gestures; + description = "Gesture mapper for libinput"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ teozkr ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7c3ac92d4b55..f008566ec422 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9929,6 +9929,8 @@ with pkgs; graphviz = graphviz-nox; }; + libinput-gestures = callPackage ../tools/inputmethods/libinput-gestures {}; + libisofs = callPackage ../development/libraries/libisofs { }; libisoburn = callPackage ../development/libraries/libisoburn { };