1{ lib, stdenv, fetchFromGitHub, makeWrapper,
2 libinput, wmctrl, python3,
3 coreutils, xdotool ? null,
4 extraUtilsPath ? lib.optional (xdotool != null) xdotool
5}:
6stdenv.mkDerivation rec {
7 pname = "libinput-gestures";
8 version = "2.74";
9
10 src = fetchFromGitHub {
11 owner = "bulletmark";
12 repo = "libinput-gestures";
13 rev = version;
14 sha256 = "sha256-uBABs2FPvF+HO+VSNvz2F0Bc9Ja8ek1ULiu89/wvTv4=";
15 };
16 patches = [
17 ./0001-hardcode-name.patch
18 ./0002-paths.patch
19 ];
20
21 nativeBuildInputs = [ makeWrapper ];
22 buildInputs = [ python3 ];
23
24 postPatch =
25 ''
26 substituteInPlace libinput-gestures-setup --replace /usr/ /
27
28 substituteInPlace libinput-gestures \
29 --replace /etc "$out/etc" \
30 --subst-var-by libinput "${libinput}/bin/libinput" \
31 --subst-var-by wmctrl "${wmctrl}/bin/wmctrl"
32 '';
33 installPhase =
34 ''
35 runHook preInstall
36 ${stdenv.shell} libinput-gestures-setup -d "$out" install
37 runHook postInstall
38 '';
39 postFixup =
40 ''
41 rm "$out/bin/libinput-gestures-setup"
42 substituteInPlace "$out/share/systemd/user/libinput-gestures.service" --replace "/usr" "$out"
43 substituteInPlace "$out/share/applications/libinput-gestures.desktop" --replace "/usr" "$out"
44 chmod +x "$out/share/applications/libinput-gestures.desktop"
45 wrapProgram "$out/bin/libinput-gestures" --prefix PATH : "${lib.makeBinPath ([coreutils] ++ extraUtilsPath)}"
46 '';
47
48 meta = with lib; {
49 homepage = "https://github.com/bulletmark/libinput-gestures";
50 description = "Gesture mapper for libinput";
51 license = licenses.gpl3Plus;
52 platforms = platforms.linux;
53 maintainers = with maintainers; [ teozkr ];
54 };
55}