Help with Shell Scripting, and Script to Toggle TouchpadToggle touchpad in HP ProBook 4530sHow to send text...

Meaning of the word "good" in context

Does "boire un jus" tend to mean "coffee" or "juice of fruit"?

Did the Russian Empire have a claim to Sweden? Was there ever a time where they could have pursued it?

Have any large aeroplanes been landed — safely and without damage — in locations that they could not be flown away from?

Why wasn't ASCII designed with a contiguous alphanumeric character order?

Where can I find my serialized Sitecore items?

Hard for me to understand one tip written in "The as-if rule" of cppreference

Automorphisms and epimorphisms of finite groups

Can dual citizens open crypto exchange accounts where U.S. citizens are prohibited?

Is my guitar action too high or is the bridge too high?

What are the children of two Muggle-borns called?

Fully submerged water bath for stove top baking?

What does 5d4 x 10 gp mean?

How to track mail undetectably?

Correct use of the the idiom 'Гнать/Катить бочку'

Is it advisable to inform the CEO about his brother accessing his office?

What was the first science fiction or fantasy multiple choice book?

Subset of knight's move in chess.

Can US Supreme Court justices / judges be "rotated" out against their will?

I just started; should I accept a farewell lunch for a coworker I don't know?

The Lucas argument vs the theorem-provers -- who wins and why?

What does 'in attendance' mean on a death certificate - England?

Installed software from source, how to say yum not to install it from package?

Word ending in "-ine" for rat-like



Help with Shell Scripting, and Script to Toggle Touchpad


Toggle touchpad in HP ProBook 4530sHow to send text to a command and THEN read from terminalInactive cursor with my touchpadHelp with awk / sed shell scriptTouchpad scrolling is very jumpy on Waylandshell shell scripting with oracleHow to disable/enable the touchpad for the Lenovo Yoga 900 13ISK2Shell scripting help text file into arraybind variable and shell scripting with sqlplusHow do I detect whether my terminal has focus in the GUI from a shell script?













0















Why in the world is this not working?



I know that this probably isn't the most elegant solution, but I'm just learning, so I'd appreciate some clarity around this! If you want to offer a more elegant solution, I'm all ears, too, but I'd love to solve this particular problem.



I will be keybinding this script so I can hit it whenever I want.



And here it is!



#!/bin/sh

if [ "synclient | grep TouchpadOff | grep -o -E '[0-9]+'" ]
then
synclient TouchpadOff=0
notify-send "Touchpad Enabled"
else
synclient TouchpadOff=1
notify-send "Touchpad Disabled"
fi









share|improve this question









New contributor



dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    0















    Why in the world is this not working?



    I know that this probably isn't the most elegant solution, but I'm just learning, so I'd appreciate some clarity around this! If you want to offer a more elegant solution, I'm all ears, too, but I'd love to solve this particular problem.



    I will be keybinding this script so I can hit it whenever I want.



    And here it is!



    #!/bin/sh

    if [ "synclient | grep TouchpadOff | grep -o -E '[0-9]+'" ]
    then
    synclient TouchpadOff=0
    notify-send "Touchpad Enabled"
    else
    synclient TouchpadOff=1
    notify-send "Touchpad Disabled"
    fi









    share|improve this question









    New contributor



    dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      0












      0








      0








      Why in the world is this not working?



      I know that this probably isn't the most elegant solution, but I'm just learning, so I'd appreciate some clarity around this! If you want to offer a more elegant solution, I'm all ears, too, but I'd love to solve this particular problem.



      I will be keybinding this script so I can hit it whenever I want.



      And here it is!



      #!/bin/sh

      if [ "synclient | grep TouchpadOff | grep -o -E '[0-9]+'" ]
      then
      synclient TouchpadOff=0
      notify-send "Touchpad Enabled"
      else
      synclient TouchpadOff=1
      notify-send "Touchpad Disabled"
      fi









      share|improve this question









      New contributor



      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      Why in the world is this not working?



      I know that this probably isn't the most elegant solution, but I'm just learning, so I'd appreciate some clarity around this! If you want to offer a more elegant solution, I'm all ears, too, but I'd love to solve this particular problem.



      I will be keybinding this script so I can hit it whenever I want.



      And here it is!



      #!/bin/sh

      if [ "synclient | grep TouchpadOff | grep -o -E '[0-9]+'" ]
      then
      synclient TouchpadOff=0
      notify-send "Touchpad Enabled"
      else
      synclient TouchpadOff=1
      notify-send "Touchpad Disabled"
      fi






      shell-script touchpad






      share|improve this question









      New contributor



      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question









      New contributor



      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question








      edited 4 mins ago









      Jeff Schaller

      47.3k11 gold badges69 silver badges154 bronze badges




      47.3k11 gold badges69 silver badges154 bronze badges






      New contributor



      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 52 mins ago









      dot rosedot rose

      1




      1




      New contributor



      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      dot rose is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          1 Answer
          1






          active

          oldest

          votes


















          1














          When you write



           if [ "some string or other" ]
          then


          the [ operator doesn't run some string or other, it just sees a non-empty string and says that is a true value.



          You want



           if [ "`synclient | grep TouchpadOff | grep -o -E '[0-9]+'`" ] 


          or the more modern



          if [ "$(synclient | grep TouchpadOff | grep -o -E '[0-9]+')" ]


          but there is really no need to see if the command produces a string as grep produces an exit code so



          if synclient | grep TouchpadOff | grep -q -E '[0-9]+'
          then


          should do what you want. I don't know the output format of synclient, but I would expect you could combine the two greps into one without too much effort.





          share


























            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
            });


            }
            });






            dot rose is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f527585%2fhelp-with-shell-scripting-and-script-to-toggle-touchpad%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









            1














            When you write



             if [ "some string or other" ]
            then


            the [ operator doesn't run some string or other, it just sees a non-empty string and says that is a true value.



            You want



             if [ "`synclient | grep TouchpadOff | grep -o -E '[0-9]+'`" ] 


            or the more modern



            if [ "$(synclient | grep TouchpadOff | grep -o -E '[0-9]+')" ]


            but there is really no need to see if the command produces a string as grep produces an exit code so



            if synclient | grep TouchpadOff | grep -q -E '[0-9]+'
            then


            should do what you want. I don't know the output format of synclient, but I would expect you could combine the two greps into one without too much effort.





            share




























              1














              When you write



               if [ "some string or other" ]
              then


              the [ operator doesn't run some string or other, it just sees a non-empty string and says that is a true value.



              You want



               if [ "`synclient | grep TouchpadOff | grep -o -E '[0-9]+'`" ] 


              or the more modern



              if [ "$(synclient | grep TouchpadOff | grep -o -E '[0-9]+')" ]


              but there is really no need to see if the command produces a string as grep produces an exit code so



              if synclient | grep TouchpadOff | grep -q -E '[0-9]+'
              then


              should do what you want. I don't know the output format of synclient, but I would expect you could combine the two greps into one without too much effort.





              share


























                1












                1








                1







                When you write



                 if [ "some string or other" ]
                then


                the [ operator doesn't run some string or other, it just sees a non-empty string and says that is a true value.



                You want



                 if [ "`synclient | grep TouchpadOff | grep -o -E '[0-9]+'`" ] 


                or the more modern



                if [ "$(synclient | grep TouchpadOff | grep -o -E '[0-9]+')" ]


                but there is really no need to see if the command produces a string as grep produces an exit code so



                if synclient | grep TouchpadOff | grep -q -E '[0-9]+'
                then


                should do what you want. I don't know the output format of synclient, but I would expect you could combine the two greps into one without too much effort.





                share













                When you write



                 if [ "some string or other" ]
                then


                the [ operator doesn't run some string or other, it just sees a non-empty string and says that is a true value.



                You want



                 if [ "`synclient | grep TouchpadOff | grep -o -E '[0-9]+'`" ] 


                or the more modern



                if [ "$(synclient | grep TouchpadOff | grep -o -E '[0-9]+')" ]


                but there is really no need to see if the command produces a string as grep produces an exit code so



                if synclient | grep TouchpadOff | grep -q -E '[0-9]+'
                then


                should do what you want. I don't know the output format of synclient, but I would expect you could combine the two greps into one without too much effort.






                share











                share


                share










                answered 1 min ago









                icarusicarus

                6,9411 gold badge16 silver badges33 bronze badges




                6,9411 gold badge16 silver badges33 bronze badges






















                    dot rose is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    dot rose is a new contributor. Be nice, and check out our Code of Conduct.













                    dot rose is a new contributor. Be nice, and check out our Code of Conduct.












                    dot rose is a new contributor. Be nice, and check out our Code of Conduct.
















                    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%2f527585%2fhelp-with-shell-scripting-and-script-to-toggle-touchpad%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

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...