How to execute a function on button click with mouse movement?












0














I want the system to listen for a button press and then a mouse Right/left/up/down movement. I know which button is pressed by XEV, but I don’t know how to listen for mouse movements and then execute something. Does anyone know how can I do it?










share|improve this question





























    0














    I want the system to listen for a button press and then a mouse Right/left/up/down movement. I know which button is pressed by XEV, but I don’t know how to listen for mouse movements and then execute something. Does anyone know how can I do it?










    share|improve this question



























      0












      0








      0


      1





      I want the system to listen for a button press and then a mouse Right/left/up/down movement. I know which button is pressed by XEV, but I don’t know how to listen for mouse movements and then execute something. Does anyone know how can I do it?










      share|improve this question















      I want the system to listen for a button press and then a mouse Right/left/up/down movement. I know which button is pressed by XEV, but I don’t know how to listen for mouse movements and then execute something. Does anyone know how can I do it?







      linux mouse i3 mouse-gestures






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 1 at 17:53









      Rafael Muynarsk

      377515




      377515










      asked Dec 31 '18 at 12:52









      Bas BakkerBas Bakker

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Considering that you're using Xorg as the default X Window server you can accomplish it installing cnee. A simple bash script that can read the actions of left-clicking the mouse would be:



          #!/bin/bash

          mousedownFunction () {
          echo "mouse down event"
          }

          mouseupFunction () {
          echo "mouse up event"
          }

          cnee --record --mouse |
          while read line; do
          if [ ! -z "$(echo "$line" | awk '/7,4,0,0,1/')" ]; then
          mousedownFunction
          elif [ ! -z "$(echo "$line" | awk '/7,5,0,0,1/')" ]; then
          mouseupFunction
          fi
          done


          The result is:



          enter image description here





          OBS: When you run the command cnee --record --mouse on a terminal window you'll see that it categorizes each mouse action with a specific number. On the script's example 7,4,0,0,1 represents left-click mousedown and 7,5,0,0,1 represents left-click mouseup. But you can capture other actions as well, as middle click, right click, mouse up/down scrolls and mouse movements. You just need to adapt the script to suit your needs.






          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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            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%2f491757%2fhow-to-execute-a-function-on-button-click-with-mouse-movement%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Considering that you're using Xorg as the default X Window server you can accomplish it installing cnee. A simple bash script that can read the actions of left-clicking the mouse would be:



            #!/bin/bash

            mousedownFunction () {
            echo "mouse down event"
            }

            mouseupFunction () {
            echo "mouse up event"
            }

            cnee --record --mouse |
            while read line; do
            if [ ! -z "$(echo "$line" | awk '/7,4,0,0,1/')" ]; then
            mousedownFunction
            elif [ ! -z "$(echo "$line" | awk '/7,5,0,0,1/')" ]; then
            mouseupFunction
            fi
            done


            The result is:



            enter image description here





            OBS: When you run the command cnee --record --mouse on a terminal window you'll see that it categorizes each mouse action with a specific number. On the script's example 7,4,0,0,1 represents left-click mousedown and 7,5,0,0,1 represents left-click mouseup. But you can capture other actions as well, as middle click, right click, mouse up/down scrolls and mouse movements. You just need to adapt the script to suit your needs.






            share|improve this answer




























              0














              Considering that you're using Xorg as the default X Window server you can accomplish it installing cnee. A simple bash script that can read the actions of left-clicking the mouse would be:



              #!/bin/bash

              mousedownFunction () {
              echo "mouse down event"
              }

              mouseupFunction () {
              echo "mouse up event"
              }

              cnee --record --mouse |
              while read line; do
              if [ ! -z "$(echo "$line" | awk '/7,4,0,0,1/')" ]; then
              mousedownFunction
              elif [ ! -z "$(echo "$line" | awk '/7,5,0,0,1/')" ]; then
              mouseupFunction
              fi
              done


              The result is:



              enter image description here





              OBS: When you run the command cnee --record --mouse on a terminal window you'll see that it categorizes each mouse action with a specific number. On the script's example 7,4,0,0,1 represents left-click mousedown and 7,5,0,0,1 represents left-click mouseup. But you can capture other actions as well, as middle click, right click, mouse up/down scrolls and mouse movements. You just need to adapt the script to suit your needs.






              share|improve this answer


























                0












                0








                0






                Considering that you're using Xorg as the default X Window server you can accomplish it installing cnee. A simple bash script that can read the actions of left-clicking the mouse would be:



                #!/bin/bash

                mousedownFunction () {
                echo "mouse down event"
                }

                mouseupFunction () {
                echo "mouse up event"
                }

                cnee --record --mouse |
                while read line; do
                if [ ! -z "$(echo "$line" | awk '/7,4,0,0,1/')" ]; then
                mousedownFunction
                elif [ ! -z "$(echo "$line" | awk '/7,5,0,0,1/')" ]; then
                mouseupFunction
                fi
                done


                The result is:



                enter image description here





                OBS: When you run the command cnee --record --mouse on a terminal window you'll see that it categorizes each mouse action with a specific number. On the script's example 7,4,0,0,1 represents left-click mousedown and 7,5,0,0,1 represents left-click mouseup. But you can capture other actions as well, as middle click, right click, mouse up/down scrolls and mouse movements. You just need to adapt the script to suit your needs.






                share|improve this answer














                Considering that you're using Xorg as the default X Window server you can accomplish it installing cnee. A simple bash script that can read the actions of left-clicking the mouse would be:



                #!/bin/bash

                mousedownFunction () {
                echo "mouse down event"
                }

                mouseupFunction () {
                echo "mouse up event"
                }

                cnee --record --mouse |
                while read line; do
                if [ ! -z "$(echo "$line" | awk '/7,4,0,0,1/')" ]; then
                mousedownFunction
                elif [ ! -z "$(echo "$line" | awk '/7,5,0,0,1/')" ]; then
                mouseupFunction
                fi
                done


                The result is:



                enter image description here





                OBS: When you run the command cnee --record --mouse on a terminal window you'll see that it categorizes each mouse action with a specific number. On the script's example 7,4,0,0,1 represents left-click mousedown and 7,5,0,0,1 represents left-click mouseup. But you can capture other actions as well, as middle click, right click, mouse up/down scrolls and mouse movements. You just need to adapt the script to suit your needs.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 1 at 15:59

























                answered Dec 31 '18 at 18:54









                Rafael MuynarskRafael Muynarsk

                377515




                377515






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491757%2fhow-to-execute-a-function-on-button-click-with-mouse-movement%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Morgemoulin

                    Scott Moir

                    Souastre