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

use grep to filter out pointer events #279

Merged
merged 2 commits into from
Sep 25, 2022
Merged

Conversation

ces42
Copy link
Contributor

@ces42 ces42 commented Sep 24, 2022

On my computer moving the cursor with the touchpad or scrolling would generated quite high (~10%) cpu usage from fusuma. It seems like this is due to the large amount of output generated by libinput debug-events. Removing all of the POINTER_MOTION and POINTER_SCROLL_FINGER events with grep fixed that for me (I guess grep is much more cpu-efficient than ruby...).

I already wrote this code for use on my computer so I wasn't sure it was necessary to open an issue before creating this PR

  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rspec and bundle exec rubocop.
    This doesn't introduce any rubocop complaints but rspec needs to be updated (I don't know ruby and don't really have an idea how to do it)

  • Update code documentation if necessary. Not necessary (I think)

@ces42 ces42 changed the title use grep to filter out pointer events [WIP] use grep to filter out pointer events Sep 24, 2022
lib/fusuma/libinput_command.rb Outdated Show resolved Hide resolved
lib/fusuma/libinput_command.rb Outdated Show resolved Hide resolved
@iberianpig
Copy link
Owner

Hi @ces42, thank you so much for your nice pull request!

The failing RSpec, it should probably pass your tests with the following code

diff --git a/spec/lib/libinput_command_spec.rb b/spec/lib/libinput_command_spec.rb
index 949184f..3ecc8f1 100644
--- a/spec/lib/libinput_command_spec.rb
+++ b/spec/lib/libinput_command_spec.rb
@@ -132,8 +132,12 @@ module Fusuma
         end

         it 'should call dummy events' do
-          expect(Process).to receive(:spawn).with('dummy_debug_events',
-                                                  { out: @dummy_io, in: '/dev/null' }).once
+          th = double(Thread, pid: 'dummy pid')
+          expect(Open3).to receive(:pipeline_start).with(
+            ['dummy_debug_events'],
+            ['grep -v POINTER_ --line-buffered'],
+            { out: @dummy_io, in: '/dev/null' }
+          ).once.and_return([th])
           subject
         end
       end

@ces42
Copy link
Contributor Author

ces42 commented Sep 24, 2022

I think this is ready now

@ces42 ces42 marked this pull request as ready for review September 24, 2022 23:26
@iberianpig iberianpig self-requested a review September 25, 2022 12:51
@iberianpig iberianpig changed the title [WIP] use grep to filter out pointer events use grep to filter out pointer events Sep 25, 2022
@iberianpig iberianpig merged commit 84cbfb2 into iberianpig:master Sep 25, 2022
@iberianpig
Copy link
Owner

@ces42 Thank you for your contribution!

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

Successfully merging this pull request may close these issues.

2 participants