Skip to content

Instantly share code, notes, and snippets.

@yorickvP
Last active October 10, 2017 20:33
Show Gist options
  • Save yorickvP/bda03f3551e90bcd740091ebee83a23f to your computer and use it in GitHub Desktop.
Save yorickvP/bda03f3551e90bcd740091ebee83a23f to your computer and use it in GitHub Desktop.
{ pkgs ? (import <nixpkgs> {})
, stdenv ? pkgs.stdenv
, xdotool ? pkgs.xdotool
, makeWrapper ? pkgs.makeWrapper
, wmctrl ? pkgs.wmctrl
, fetchFromGitHub ? pkgs.fetchFromGitHub
, bash ? pkgs.bash
, python3 ? pkgs.python3
, libinput ? pkgs.libinput
, procps ? pkgs.procps
}:
stdenv.mkDerivation rec {
version = "2.16";
name = "libinput-gestures-${version}";
src = fetchFromGitHub {
owner = "bulletmark";
repo = "libinput-gestures";
rev = version;
sha256 = "0ix1ygbrwjvabxpq8g4xcfdjrcc6jq79vxpbv6msaxmjxp6dv17w";
};
patches = [./paths.diff];
buildInputs = with pkgs; [ makeWrapper ];
installFlags = "DESTDIR=$(out)";
preInstall = ''
substituteAllInPlace libinput-gestures.desktop
'';
postInstall = ''
wrapProgram $out/bin/libinput-gestures \
--prefix PATH : "${python3}/bin:${xdotool}/bin:${wmctrl}/bin:${libinput}/bin"
substituteInPlace $out/bin/libinput-gestures-setup \
--replace "DIR=\"/" "DIR=\"$out/"
wrapProgram $out/bin/libinput-gestures-setup \
--prefix PATH : "${procps}/bin:${libinput}/bin"
'';
meta = with stdenv.lib; {
description = "libinput gesture recognition";
license = licenses.gpl3;
maintainers = with maintainers; [ yorickvp ];
};
}
diff --git a/libinput-gestures b/libinput-gestures
index 7c7418e..6395bfd 100755
--- a/libinput-gestures
+++ b/libinput-gestures
@@ -4,7 +4,7 @@
import os, sys, argparse, subprocess, shlex, re, getpass, fcntl
from pathlib import Path
-PROG = Path(sys.argv[0]).name
+PROG = "libinput-gestures"
# Conf file containing gesture commands.
# Search first for user file then system file.
diff --git a/libinput-gestures-setup b/libinput-gestures-setup
index 22be217..5dc000d 100755
--- a/libinput-gestures-setup
+++ b/libinput-gestures-setup
@@ -1,11 +1,11 @@
-#!/bin/bash
+#!/usr/bin/env bash
# User setup script.
# (C) Mark Blakeney, [email protected], Aug 2016.
-PROG="$(basename $0)"
+PROG="libinput-gestures-setup"
NAME=${PROG%-*}
-BINDIR="/usr/bin"
+BINDIR="/bin"
APPDIR="/usr/share/applications"
ICOBAS="/usr/share/icons/hicolor"
ICODIR="$ICOBAS/128x128/apps"
diff --git a/libinput-gestures.desktop b/libinput-gestures.desktop
index 903c14c..13d71f3 100644
--- a/libinput-gestures.desktop
+++ b/libinput-gestures.desktop
@@ -2,7 +2,7 @@
Type=Application
Terminal=false
Name=Libinput Gestures
-Exec=/usr/bin/libinput-gestures
+Exec=@out@/bin/libinput-gestures
Icon=libinput-gestures
Comment=Background application to intercept and action libinput gestures from touchpad.
Categories=GNOME;GTK;System;
@rasendubi
Copy link

@yorickvP do you mind if I polish this a bit and submit to upstream nixpkgs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment