How can I run a shell script on input device event

Multi tool use
Multi tool use

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have a USB remote presenter that appears as a keyboard.



Using evtest I can see the input events from the device.



How can I capture those events in a shell script?



I had see some solutions using C but I would prefer something with only bash if possible.



I already tried something with xbindkeys, but my keyboard events were captured as well and I don't want that.



I also read something about udev rules but seems to me that these rules are only useful for plug and unplug events.







share|improve this question


























    up vote
    1
    down vote

    favorite












    I have a USB remote presenter that appears as a keyboard.



    Using evtest I can see the input events from the device.



    How can I capture those events in a shell script?



    I had see some solutions using C but I would prefer something with only bash if possible.



    I already tried something with xbindkeys, but my keyboard events were captured as well and I don't want that.



    I also read something about udev rules but seems to me that these rules are only useful for plug and unplug events.







    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a USB remote presenter that appears as a keyboard.



      Using evtest I can see the input events from the device.



      How can I capture those events in a shell script?



      I had see some solutions using C but I would prefer something with only bash if possible.



      I already tried something with xbindkeys, but my keyboard events were captured as well and I don't want that.



      I also read something about udev rules but seems to me that these rules are only useful for plug and unplug events.







      share|improve this question














      I have a USB remote presenter that appears as a keyboard.



      Using evtest I can see the input events from the device.



      How can I capture those events in a shell script?



      I had see some solutions using C but I would prefer something with only bash if possible.



      I already tried something with xbindkeys, but my keyboard events were captured as well and I don't want that.



      I also read something about udev rules but seems to me that these rules are only useful for plug and unplug events.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 2:49









      Jeff Schaller

      31.2k846105




      31.2k846105










      asked Mar 6 at 1:45









      paulequilibrio

      131115




      131115




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          This example is monitoring taps on touchpad:



          xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad" 
          | grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
          paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
          done


          You can easily modify it for your needs.






          share|improve this answer





























            up vote
            0
            down vote













            @JeffSchaller, thank you for the edits.



            Based on @IporSircer's answer (thanks!), I was able to create the following script:



            #!/bin/bash

            device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
            event_blank='*code 48 (KEY_B), value 1*'
            event_esc='*code 1 (KEY_ESC), value 1*'
            event_f5='*code 63 (KEY_F5), value 1*'
            event_prev='*code 104 (KEY_PAGEUP), value 1*'
            event_next='*code 109 (KEY_PAGEDOWN), value 1*'

            evtest "$device" | while read line; do
            case $line in
            ($event_blank) echo "BLANK SCREEN" ;;
            ($event_f5) echo "F5" ;;
            ($event_esc) echo "ESCAPE" ;;
            ($event_prev) echo "PREVIOUS" ;;
            ($event_next) echo "NEXT" ;;
            esac
            done


            Using evtest I was able to find out the event number /dev/input/event18 for the device, but this number may vary depending on the devices on your system and in which order they were connected



            Because of that I used udevadm info /dev/input/event18 to find out the device's unique id



            S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd


            Finally, using evtest again I was able to catch all events from device to use them on the case statement.






            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "106"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );








               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428399%2fhow-can-i-run-a-shell-script-on-input-device-event%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              This example is monitoring taps on touchpad:



              xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad" 
              | grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
              paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
              done


              You can easily modify it for your needs.






              share|improve this answer


























                up vote
                2
                down vote













                This example is monitoring taps on touchpad:



                xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad" 
                | grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
                paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
                done


                You can easily modify it for your needs.






                share|improve this answer
























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  This example is monitoring taps on touchpad:



                  xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad" 
                  | grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
                  paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
                  done


                  You can easily modify it for your needs.






                  share|improve this answer














                  This example is monitoring taps on touchpad:



                  xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad" 
                  | grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
                  paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
                  done


                  You can easily modify it for your needs.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 6 at 17:05

























                  answered Mar 6 at 7:37









                  Ipor Sircer

                  8,7951920




                  8,7951920






















                      up vote
                      0
                      down vote













                      @JeffSchaller, thank you for the edits.



                      Based on @IporSircer's answer (thanks!), I was able to create the following script:



                      #!/bin/bash

                      device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
                      event_blank='*code 48 (KEY_B), value 1*'
                      event_esc='*code 1 (KEY_ESC), value 1*'
                      event_f5='*code 63 (KEY_F5), value 1*'
                      event_prev='*code 104 (KEY_PAGEUP), value 1*'
                      event_next='*code 109 (KEY_PAGEDOWN), value 1*'

                      evtest "$device" | while read line; do
                      case $line in
                      ($event_blank) echo "BLANK SCREEN" ;;
                      ($event_f5) echo "F5" ;;
                      ($event_esc) echo "ESCAPE" ;;
                      ($event_prev) echo "PREVIOUS" ;;
                      ($event_next) echo "NEXT" ;;
                      esac
                      done


                      Using evtest I was able to find out the event number /dev/input/event18 for the device, but this number may vary depending on the devices on your system and in which order they were connected



                      Because of that I used udevadm info /dev/input/event18 to find out the device's unique id



                      S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd


                      Finally, using evtest again I was able to catch all events from device to use them on the case statement.






                      share|improve this answer
























                        up vote
                        0
                        down vote













                        @JeffSchaller, thank you for the edits.



                        Based on @IporSircer's answer (thanks!), I was able to create the following script:



                        #!/bin/bash

                        device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
                        event_blank='*code 48 (KEY_B), value 1*'
                        event_esc='*code 1 (KEY_ESC), value 1*'
                        event_f5='*code 63 (KEY_F5), value 1*'
                        event_prev='*code 104 (KEY_PAGEUP), value 1*'
                        event_next='*code 109 (KEY_PAGEDOWN), value 1*'

                        evtest "$device" | while read line; do
                        case $line in
                        ($event_blank) echo "BLANK SCREEN" ;;
                        ($event_f5) echo "F5" ;;
                        ($event_esc) echo "ESCAPE" ;;
                        ($event_prev) echo "PREVIOUS" ;;
                        ($event_next) echo "NEXT" ;;
                        esac
                        done


                        Using evtest I was able to find out the event number /dev/input/event18 for the device, but this number may vary depending on the devices on your system and in which order they were connected



                        Because of that I used udevadm info /dev/input/event18 to find out the device's unique id



                        S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd


                        Finally, using evtest again I was able to catch all events from device to use them on the case statement.






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          @JeffSchaller, thank you for the edits.



                          Based on @IporSircer's answer (thanks!), I was able to create the following script:



                          #!/bin/bash

                          device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
                          event_blank='*code 48 (KEY_B), value 1*'
                          event_esc='*code 1 (KEY_ESC), value 1*'
                          event_f5='*code 63 (KEY_F5), value 1*'
                          event_prev='*code 104 (KEY_PAGEUP), value 1*'
                          event_next='*code 109 (KEY_PAGEDOWN), value 1*'

                          evtest "$device" | while read line; do
                          case $line in
                          ($event_blank) echo "BLANK SCREEN" ;;
                          ($event_f5) echo "F5" ;;
                          ($event_esc) echo "ESCAPE" ;;
                          ($event_prev) echo "PREVIOUS" ;;
                          ($event_next) echo "NEXT" ;;
                          esac
                          done


                          Using evtest I was able to find out the event number /dev/input/event18 for the device, but this number may vary depending on the devices on your system and in which order they were connected



                          Because of that I used udevadm info /dev/input/event18 to find out the device's unique id



                          S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd


                          Finally, using evtest again I was able to catch all events from device to use them on the case statement.






                          share|improve this answer












                          @JeffSchaller, thank you for the edits.



                          Based on @IporSircer's answer (thanks!), I was able to create the following script:



                          #!/bin/bash

                          device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
                          event_blank='*code 48 (KEY_B), value 1*'
                          event_esc='*code 1 (KEY_ESC), value 1*'
                          event_f5='*code 63 (KEY_F5), value 1*'
                          event_prev='*code 104 (KEY_PAGEUP), value 1*'
                          event_next='*code 109 (KEY_PAGEDOWN), value 1*'

                          evtest "$device" | while read line; do
                          case $line in
                          ($event_blank) echo "BLANK SCREEN" ;;
                          ($event_f5) echo "F5" ;;
                          ($event_esc) echo "ESCAPE" ;;
                          ($event_prev) echo "PREVIOUS" ;;
                          ($event_next) echo "NEXT" ;;
                          esac
                          done


                          Using evtest I was able to find out the event number /dev/input/event18 for the device, but this number may vary depending on the devices on your system and in which order they were connected



                          Because of that I used udevadm info /dev/input/event18 to find out the device's unique id



                          S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd


                          Finally, using evtest again I was able to catch all events from device to use them on the case statement.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 6 at 14:05









                          paulequilibrio

                          131115




                          131115






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428399%2fhow-can-i-run-a-shell-script-on-input-device-event%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              0yWwc7XGb6zy
                              J9GtIvQB0LFEzxGGKTiJ8pltn,rG dp5ffx5tt N8j iw,dJjfbPY,DdjQMxmTg2uUw1tdtTwIpb Uc9

                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              How many registers does an x86_64 CPU actually have?

                              Displaying single band from multi-band raster using QGIS