Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libinput-gestures: init at 2.32 #34687

Merged
merged 2 commits into from Feb 27, 2018
Merged

Conversation

nightkr
Copy link
Member

@nightkr nightkr commented Feb 6, 2018

Motivation for this change

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)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@@ -0,0 +1,35 @@
{lib, stdenv, fetchFromGitHub, bash, fakeroot, libinput, xdotool, makeWrapper}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You don't need bash as you can use stdenv.shell
  2. Please add space after { and before }.

sha256 = "1by6sabx0s8sd9w5675gc26q7yccxnxxsjg4dqlb6nbs0vcg81s7";
};

buildInputs = [ bash fakeroot makeWrapper ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be nativeBuildInputs (and bash should go ref the comment above)

installPhase =
''
mkdir -p $out
fakeroot -- bash libinput-gestures-setup -d "$out" install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need fakeroot?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just patch that out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I was a moron and it's not required. Removing it now.

''
mkdir -p $out
fakeroot -- bash libinput-gestures-setup -d "$out" install
mv $out/usr/bin $out/bin-unwrapped
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you call makeWrapper/wrapProgram later, it will take care of renaming instead you having to define your own scheme.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used that at first, but the config files are discovered depending on argv[0]. Using wrapProgram means it will look for {/etc,~/.config}/.libinput-gestures-wrapped.conf, rather than {/etc,~/.config}/libinput-gestures.conf.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapProgram takes an --argv SOME_NAME argument that should deal with that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like wrapProgram already sets --argv0. I tried setting it manually, but that still didn't work.

mkdir -p $out
fakeroot -- bash libinput-gestures-setup -d "$out" install
mv $out/usr/bin $out/bin-unwrapped
mv $out/usr/share $out/share
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixupPhase will handle this for you, you don't need to do it manually

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem to happen for me, unless I'm missing something.

rmdir $out/usr
mkdir $out/bin
sed -i "s,/usr/bin/,,g" $out/share/applications/*.desktop
makeWrapper $out/bin-unwrapped/libinput-gestures $out/bin/libinput-gestures --prefix PATH : ${lib.makeBinPath [ libinput xdotool ]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use wrapProgram instead of makeWrapper it will handle the renaming for you.

mkdir $out/bin
sed -i "s,/usr/bin/,,g" $out/share/applications/*.desktop
makeWrapper $out/bin-unwrapped/libinput-gestures $out/bin/libinput-gestures --prefix PATH : ${lib.makeBinPath [ libinput xdotool ]}
makeWrapper $out/bin-unwrapped/libinput-gestures-setup $out/bin/libinput-gestures-setup --prefix PATH : ${lib.makeBinPath [ ]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of prefixing with an empty list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, I forgot to remove this after finding out that -setup is pretty much useless in NixOS anyway.

makeWrapper $out/bin-unwrapped/libinput-gestures-setup $out/bin/libinput-gestures-setup --prefix PATH : ${lib.makeBinPath [ ]}
'';

meta = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change this to meta = with stdenv.lib; { ...

meta = {
homepage = https://github.com/bulletmark/libinput-gestures;
description = "Gesture mapper for libinput";
license = stdenv.lib.licenses.gpl3Plus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... you can get rid of the stdenv.lib. part here

homepage = https://github.com/bulletmark/libinput-gestures;
description = "Gesture mapper for libinput";
license = stdenv.lib.licenses.gpl3Plus;
platforms = stdenv.lib.platforms.linux;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@nightkr
Copy link
Member Author

nightkr commented Feb 19, 2018

@peterhoeg I believe I've dealt with all your feedback now.
The only remaining concern is the manual renaming, which I can't seem to get rid of; even with wrapProgram --argv0 it still thinks that it's called .libinput-gestures-wrapped rather than libinput-gestures.

@peterhoeg
Copy link
Member

Super, for the last item, just patch this line: https://github.com/bulletmark/libinput-gestures/blob/master/libinput-gestures#L13 instead of using --argv0.

rmdir "$out/usr"
mkdir "$out/bin"
substituteInPlace "$out/share/applications/libinput-gestures.desktop" --replace "/usr" "$out"
chmod +x "$out/share/applications/libinput-gestures.desktop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.desktop files without a shebang shouldn't be executable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but KDE doesn't seem to. If it's not there then running kioclient5 exec result/share/applications/libinput-gestures.desktop gives the following confirmation prompt:

image

Clicking Continue fails with the following message:

image

Since /nix/store is read-only. If libinput-gestures.desktop is executable then everything works fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, Firefox seems to install its .desktop file, which also causes it to become marked executable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. I was surprised too when I found out.


nativeBuildInputs = [ makeWrapper ];

installPhase =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you don't have to install manually, move the clean-up to the postInstall phase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything after invoking libinput-gestures-setup?

@nightkr
Copy link
Member Author

nightkr commented Feb 20, 2018

@peterhoeg Done.

@peterhoeg
Copy link
Member

Have a look at this: peterhoeg@c2d6711

I made some changes:

a) This is a python program so use python3Packages.buildPythonApplication which means the shebang is fixed for us (yours doesn't actually work without python3 in the global environment)

b) Patch the paths to the various programs

c) Patch the installation path to avoid the shuffling from /usr

d) Add a reference to wmctrl

e) Make it look for the default config file in the correct place

f) Drop the reference to xdotool which isn't used

@nightkr
Copy link
Member Author

nightkr commented Feb 20, 2018

a) Fair enough. I didn't know buildPython{Package,Application} was compatible with packages that didn't use distutils/setuptools. Good to know!

b,c) Fair enough. Personally I prefer wrapping over patching since it doesn't need to be maintained when the underlying package changes.

d) Good catch. Didn't think about that since I don't use libinput-gestures to manage my workspaces.

e) Nice, though we probably want to add a way to override the default config file. Maybe an argument?

f) xdotool is used for the default backwards/forwards gestures, and is the primary way that I use libinput-gestures.

I guess d and f mean that it makes more sense to let the user add more tools to the path themselves (another argument?), than to hardcode a few blessed utilities into the package.

@peterhoeg
Copy link
Member

peterhoeg commented Feb 20, 2018 via email

@nightkr
Copy link
Member Author

nightkr commented Feb 20, 2018

We should include the ones that are necessary for the operation. Which ones are optional?

The config file allows you to map gestures to arbitrary commands. The default configuration (https://github.com/bulletmark/libinput-gestures/blob/master/libinput-gestures.conf) uses xdotool for three-finger swipes to the left and right, as well as for pinches.

@peterhoeg
Copy link
Member

The way I read the config file, it uses wmctrl using the _internal command (which is what we substitute for a full path name) for most things as it works on both wayland and X whereas xdotool is X only.

If somebody wants to do more, they can always wrap it accordingly.

@peterhoeg
Copy link
Member

I just realized that meta.maintainers is missing - you don't want to add yourself as maintainer?

@nightkr
Copy link
Member Author

nightkr commented Feb 22, 2018

I wasn't sure since I'm not in maintainers.nix, but I suppose I can add myself to there.

@peterhoeg
Copy link
Member

Sure, just add a separate commit for that.

@peterhoeg
Copy link
Member

@teozkr, any chance you can get the last bits in within the next couple of days so this can make it into 18.03 ?

@nightkr
Copy link
Member Author

nightkr commented Feb 26, 2018 via email

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.
@nightkr
Copy link
Member Author

nightkr commented Feb 26, 2018

Set myself as maintainer and merged most of your suggestions.

I'm still leaving in xdotool by default since a) it's used by the default configuration and b) most users are presumably still using X11. That said, I made it optional, and added an argument for adding more utilities to $PATH.

Seems to build fine for me, going to try it out on my laptop in a moment and report back with the results.

@nightkr
Copy link
Member Author

nightkr commented Feb 26, 2018

Can confirm that it works fine on my laptop.

@peterhoeg peterhoeg merged commit 953b394 into NixOS:master Feb 27, 2018
@peterhoeg
Copy link
Member

Thanks for your patience @teozkr! Looking forward to the next PR. ;-)

@nightkr
Copy link
Member Author

nightkr commented Feb 27, 2018

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants