How can I remotely shutdown Ubuntu using Google Home?Shutting down a computer remotelyHow can I easily set up a Google Cloud Print printer?Google authenticator for Galaxy Nexus with Ubuntu TouchUbuntu Contacts and Google - how to sync?View ubuntu local desktop remotelyRemotely install UbuntuHow do I add my printer to Google Cloudprint?

How to answer to the "We do not want to create any precedent" argument in salary negotiation?

What do you call this when cats hunch their backs and their fur stands on end?

What is the difference between democracy and ochlocracy?

Why do the new Star Trek series have so few episodes in each season?

Why was the "Cave of the Patriarchs" forbidden to Jews?

How can Edward Snowden be denied a jury trial?

Is Bcrypt a hashing algorithm or is my study material wrong?

What happens to extra attacks after you kill your declared target

Paint numbers from 1 to 8 with two colours

instead of pressurizing an entire spacesuit with oxygen could oxygen just pressurize the head and the rest of the body be pressurized with water?

NFL football incentives

What does /r mean in a score?

Countering an uncounterable spell, triggers, and state-based actions

For a command to increase something, should instructions refer to the "+" key or the "=" key?

For which would you expect the liquidity on instrument X to be the greatest: its spot, future, option or swap?

How can an immortal member of the nobility be prevented from taking the throne?

Paint numbers from 1 to 23 with three colours

How could a sequence of random dates be generated, given year interval?

Responsibility for arrangement of elements - frontend or backend?

Pass variable to sed and change backslash to forward slash

Why do some web servers still provide information on vendor and version in the HTTP response headers

Did the Allies reverse the threads on secret microfilm-hiding buttons to thwart the Germans?

How to discourage mundane play?

When to use 8va in musical notation?



How can I remotely shutdown Ubuntu using Google Home?


Shutting down a computer remotelyHow can I easily set up a Google Cloud Print printer?Google authenticator for Galaxy Nexus with Ubuntu TouchUbuntu Contacts and Google - how to sync?View ubuntu local desktop remotelyRemotely install UbuntuHow do I add my printer to Google Cloudprint?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















How can I remotely shutdown Ubuntu using Google Home?
I guess I would need ssh, IFTTT and some android app, but I don't know how to do this. There are a ton on Windows guides, but no guides for Linux and Ubuntu.










share|improve this question
































    0

















    How can I remotely shutdown Ubuntu using Google Home?
    I guess I would need ssh, IFTTT and some android app, but I don't know how to do this. There are a ton on Windows guides, but no guides for Linux and Ubuntu.










    share|improve this question




























      0












      0








      0








      How can I remotely shutdown Ubuntu using Google Home?
      I guess I would need ssh, IFTTT and some android app, but I don't know how to do this. There are a ton on Windows guides, but no guides for Linux and Ubuntu.










      share|improve this question















      How can I remotely shutdown Ubuntu using Google Home?
      I guess I would need ssh, IFTTT and some android app, but I don't know how to do this. There are a ton on Windows guides, but no guides for Linux and Ubuntu.







      remote google






      share|improve this question














      share|improve this question











      share|improve this question




      share|improve this question










      asked May 28 at 11:37









      Oleg BarchukOleg Barchuk

      1




      1























          1 Answer
          1






          active

          oldest

          votes


















          0


















          OK. After some time I got it working.



          I achieved turning off Ubuntu by using IFTTT, Dropbox and inotifywait (inotifywait is a tool that can run scripts or commands when some file or folder changes).



          It looks something like this:
          I ask Google Home to turn off PC -> Google Home asks IFTTT to change file in Dropbox -> inotifywait sees the change in the file and make PC power-off.



          Step by step:



          1. Go to https://www.dropbox.com and register if you don't have account.


          2. Go to https://www.dropbox.com/install
            Download package for ubuntu, install this package by double clicking.


          3. Open Dropbox in apps menu, go through the process of connecting your account.
            Now you should have a "Dropbox" folder in your "Home" folder.
            Create folder "RemoteTurnOff" in "Dropbox" folder.
            Inside "RemoteTurnOff" folder create file "fileToWatch.txt"
            You can do this by going to your apps, open "Text Editor" now choose 3 dots menu, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "fileToWatch.txt"


          4. Inside "RemoteTurnOff" folder create file "script.sh"
            You can do this by going to your apps, open "Text Editor".
            Paste this code to editor:



          #!/bin/sh
          ### BEGIN INIT INFO
          # Provides: filenotifier
          # Required-Start: $remote_fs $syslog
          # Required-Stop: $remote_fs $syslog
          # Default-Start: 2 3 4 5
          # Default-Stop: 0 1 6
          # Short-Description: Something
          # Description: Something else
          ### END INIT INFO
          cd /home/YOUR_USER_NAME/Dropbox/RemoteTurnOff
          inotifywait -e close_write,moved_to,create -m . |
          while read -r directory events filename; do
          if [ "$filename" = "fileToWatch.txt" ]; then
          systemctl poweroff
          fi
          done



          Important: Change YOUR_USER_NAME to your user name.
          If you don't know your user name: open Terminal and type



          whoami


          Now press on 3 dots menu in text editor, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "script.sh"



          1. Right click on script.sh -> Properties -> Permissions -> click on "Allow executing file as program" (it should be checked).

          To be sure it's executable do this:
          Right click on empty space inside RemoteTurnOff folder.
          Choose "Open In Terminal"
          Run this command:



          sudo chmod +x script.sh


          1. You can now test if script works.
            Open RemoteTurnOff folder, right click on empty space, choose "Open in Terminal",
            type:


          ./script.sh




          Don't close the terminal, open "fileToWatch.txt" in editor, type some text, save the changes. Your computer should shutdown.
          If it did shutdown then everything's OK - continue.



          1. Lets make the script run in background on startup.
            Open terminal, past command:


          cd /etc




          past command



          sudo nano rc.local


          You should now be in text editor mode.
          Paste this text to editor:



          #!/bin/sh -e
          sh '/home/YOUR_USER_NAME/Dropbox/RemoteTurnOff/script.sh' &
          exit 0


          You need to change YOUR_USER_NAME to your name (use whoami command in another terminal window to get the name, if you don't know it).
          Don't forget "&" sign at the end of second line!



          Press Ctrl+O to save it. Press Enter to confirm name.
          It should look like this: pic



          Press Ctrl+X to exit text editor mode in terminal.



          Now run this command to make rc.local executable:



          sudo chmod +x rc.local


          Now the script should start at startup in background. Test it: reboot, than go to Dropbox -> RemoteTurnOff open "fileToWatch.txt", paste some text and save. The PC should reboot.
          All hard work is done. Next we'll connect Dropbox to Google Home.



          1. Go to https://ifttt.com/
            Register (it's better to use google account for registration)


          2. Go to https://ifttt.com/services/google_assistant/settings
            Connect to your Google Home. Make sure the status is active.


          3. Go to https://ifttt.com/services/dropbox/settings
            Connect your Dropbox. Make sure the status is active.


          4. On IFTTT site lets create new applet. Click on "My applets" and then on "Create applet".


          5. Press on "+ this", search for "assistant", click on "Google Assistant"


          6. Choose "Say a simple phrase".


          7. On next screen fill in phrase you will use to talk to google home.
            In my case it looks something like this:
            pic
            Then press on "Create trigger"


          8. Press on "+ that"
            Search for "Dropbox", choose "Dropbox".
            On next screen choose third option: "Append to a text file"


          9. Fill info:


          file name -> "fileToWatch.txt"



          content -> "#" (it can be any symbol)



          dropbox folder path -> "RemoteTurnOff/"



          pic



          Click on "Create action".
          It's better to disable notification - it gets annoying.



          Now tell your google home to "turn Off computer".



          I may have forgotten some steps. Please tell me if it didn't work, I'll help you and fix instruction.
          Tested on Ubuntu 18.04 LTS.
          I didn't create question just to answer it. I didn't knew the answer when I created the question.



          To turn PC on using Google Home you don't need to do anything in ubuntu: there is a lot of instructions how to do it using WOL and android. Just type "turn on PC with google home" in google search.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1146814%2fhow-can-i-remotely-shutdown-ubuntu-using-google-home%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


















            OK. After some time I got it working.



            I achieved turning off Ubuntu by using IFTTT, Dropbox and inotifywait (inotifywait is a tool that can run scripts or commands when some file or folder changes).



            It looks something like this:
            I ask Google Home to turn off PC -> Google Home asks IFTTT to change file in Dropbox -> inotifywait sees the change in the file and make PC power-off.



            Step by step:



            1. Go to https://www.dropbox.com and register if you don't have account.


            2. Go to https://www.dropbox.com/install
              Download package for ubuntu, install this package by double clicking.


            3. Open Dropbox in apps menu, go through the process of connecting your account.
              Now you should have a "Dropbox" folder in your "Home" folder.
              Create folder "RemoteTurnOff" in "Dropbox" folder.
              Inside "RemoteTurnOff" folder create file "fileToWatch.txt"
              You can do this by going to your apps, open "Text Editor" now choose 3 dots menu, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "fileToWatch.txt"


            4. Inside "RemoteTurnOff" folder create file "script.sh"
              You can do this by going to your apps, open "Text Editor".
              Paste this code to editor:



            #!/bin/sh
            ### BEGIN INIT INFO
            # Provides: filenotifier
            # Required-Start: $remote_fs $syslog
            # Required-Stop: $remote_fs $syslog
            # Default-Start: 2 3 4 5
            # Default-Stop: 0 1 6
            # Short-Description: Something
            # Description: Something else
            ### END INIT INFO
            cd /home/YOUR_USER_NAME/Dropbox/RemoteTurnOff
            inotifywait -e close_write,moved_to,create -m . |
            while read -r directory events filename; do
            if [ "$filename" = "fileToWatch.txt" ]; then
            systemctl poweroff
            fi
            done



            Important: Change YOUR_USER_NAME to your user name.
            If you don't know your user name: open Terminal and type



            whoami


            Now press on 3 dots menu in text editor, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "script.sh"



            1. Right click on script.sh -> Properties -> Permissions -> click on "Allow executing file as program" (it should be checked).

            To be sure it's executable do this:
            Right click on empty space inside RemoteTurnOff folder.
            Choose "Open In Terminal"
            Run this command:



            sudo chmod +x script.sh


            1. You can now test if script works.
              Open RemoteTurnOff folder, right click on empty space, choose "Open in Terminal",
              type:


            ./script.sh




            Don't close the terminal, open "fileToWatch.txt" in editor, type some text, save the changes. Your computer should shutdown.
            If it did shutdown then everything's OK - continue.



            1. Lets make the script run in background on startup.
              Open terminal, past command:


            cd /etc




            past command



            sudo nano rc.local


            You should now be in text editor mode.
            Paste this text to editor:



            #!/bin/sh -e
            sh '/home/YOUR_USER_NAME/Dropbox/RemoteTurnOff/script.sh' &
            exit 0


            You need to change YOUR_USER_NAME to your name (use whoami command in another terminal window to get the name, if you don't know it).
            Don't forget "&" sign at the end of second line!



            Press Ctrl+O to save it. Press Enter to confirm name.
            It should look like this: pic



            Press Ctrl+X to exit text editor mode in terminal.



            Now run this command to make rc.local executable:



            sudo chmod +x rc.local


            Now the script should start at startup in background. Test it: reboot, than go to Dropbox -> RemoteTurnOff open "fileToWatch.txt", paste some text and save. The PC should reboot.
            All hard work is done. Next we'll connect Dropbox to Google Home.



            1. Go to https://ifttt.com/
              Register (it's better to use google account for registration)


            2. Go to https://ifttt.com/services/google_assistant/settings
              Connect to your Google Home. Make sure the status is active.


            3. Go to https://ifttt.com/services/dropbox/settings
              Connect your Dropbox. Make sure the status is active.


            4. On IFTTT site lets create new applet. Click on "My applets" and then on "Create applet".


            5. Press on "+ this", search for "assistant", click on "Google Assistant"


            6. Choose "Say a simple phrase".


            7. On next screen fill in phrase you will use to talk to google home.
              In my case it looks something like this:
              pic
              Then press on "Create trigger"


            8. Press on "+ that"
              Search for "Dropbox", choose "Dropbox".
              On next screen choose third option: "Append to a text file"


            9. Fill info:


            file name -> "fileToWatch.txt"



            content -> "#" (it can be any symbol)



            dropbox folder path -> "RemoteTurnOff/"



            pic



            Click on "Create action".
            It's better to disable notification - it gets annoying.



            Now tell your google home to "turn Off computer".



            I may have forgotten some steps. Please tell me if it didn't work, I'll help you and fix instruction.
            Tested on Ubuntu 18.04 LTS.
            I didn't create question just to answer it. I didn't knew the answer when I created the question.



            To turn PC on using Google Home you don't need to do anything in ubuntu: there is a lot of instructions how to do it using WOL and android. Just type "turn on PC with google home" in google search.






            share|improve this answer






























              0


















              OK. After some time I got it working.



              I achieved turning off Ubuntu by using IFTTT, Dropbox and inotifywait (inotifywait is a tool that can run scripts or commands when some file or folder changes).



              It looks something like this:
              I ask Google Home to turn off PC -> Google Home asks IFTTT to change file in Dropbox -> inotifywait sees the change in the file and make PC power-off.



              Step by step:



              1. Go to https://www.dropbox.com and register if you don't have account.


              2. Go to https://www.dropbox.com/install
                Download package for ubuntu, install this package by double clicking.


              3. Open Dropbox in apps menu, go through the process of connecting your account.
                Now you should have a "Dropbox" folder in your "Home" folder.
                Create folder "RemoteTurnOff" in "Dropbox" folder.
                Inside "RemoteTurnOff" folder create file "fileToWatch.txt"
                You can do this by going to your apps, open "Text Editor" now choose 3 dots menu, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "fileToWatch.txt"


              4. Inside "RemoteTurnOff" folder create file "script.sh"
                You can do this by going to your apps, open "Text Editor".
                Paste this code to editor:



              #!/bin/sh
              ### BEGIN INIT INFO
              # Provides: filenotifier
              # Required-Start: $remote_fs $syslog
              # Required-Stop: $remote_fs $syslog
              # Default-Start: 2 3 4 5
              # Default-Stop: 0 1 6
              # Short-Description: Something
              # Description: Something else
              ### END INIT INFO
              cd /home/YOUR_USER_NAME/Dropbox/RemoteTurnOff
              inotifywait -e close_write,moved_to,create -m . |
              while read -r directory events filename; do
              if [ "$filename" = "fileToWatch.txt" ]; then
              systemctl poweroff
              fi
              done



              Important: Change YOUR_USER_NAME to your user name.
              If you don't know your user name: open Terminal and type



              whoami


              Now press on 3 dots menu in text editor, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "script.sh"



              1. Right click on script.sh -> Properties -> Permissions -> click on "Allow executing file as program" (it should be checked).

              To be sure it's executable do this:
              Right click on empty space inside RemoteTurnOff folder.
              Choose "Open In Terminal"
              Run this command:



              sudo chmod +x script.sh


              1. You can now test if script works.
                Open RemoteTurnOff folder, right click on empty space, choose "Open in Terminal",
                type:


              ./script.sh




              Don't close the terminal, open "fileToWatch.txt" in editor, type some text, save the changes. Your computer should shutdown.
              If it did shutdown then everything's OK - continue.



              1. Lets make the script run in background on startup.
                Open terminal, past command:


              cd /etc




              past command



              sudo nano rc.local


              You should now be in text editor mode.
              Paste this text to editor:



              #!/bin/sh -e
              sh '/home/YOUR_USER_NAME/Dropbox/RemoteTurnOff/script.sh' &
              exit 0


              You need to change YOUR_USER_NAME to your name (use whoami command in another terminal window to get the name, if you don't know it).
              Don't forget "&" sign at the end of second line!



              Press Ctrl+O to save it. Press Enter to confirm name.
              It should look like this: pic



              Press Ctrl+X to exit text editor mode in terminal.



              Now run this command to make rc.local executable:



              sudo chmod +x rc.local


              Now the script should start at startup in background. Test it: reboot, than go to Dropbox -> RemoteTurnOff open "fileToWatch.txt", paste some text and save. The PC should reboot.
              All hard work is done. Next we'll connect Dropbox to Google Home.



              1. Go to https://ifttt.com/
                Register (it's better to use google account for registration)


              2. Go to https://ifttt.com/services/google_assistant/settings
                Connect to your Google Home. Make sure the status is active.


              3. Go to https://ifttt.com/services/dropbox/settings
                Connect your Dropbox. Make sure the status is active.


              4. On IFTTT site lets create new applet. Click on "My applets" and then on "Create applet".


              5. Press on "+ this", search for "assistant", click on "Google Assistant"


              6. Choose "Say a simple phrase".


              7. On next screen fill in phrase you will use to talk to google home.
                In my case it looks something like this:
                pic
                Then press on "Create trigger"


              8. Press on "+ that"
                Search for "Dropbox", choose "Dropbox".
                On next screen choose third option: "Append to a text file"


              9. Fill info:


              file name -> "fileToWatch.txt"



              content -> "#" (it can be any symbol)



              dropbox folder path -> "RemoteTurnOff/"



              pic



              Click on "Create action".
              It's better to disable notification - it gets annoying.



              Now tell your google home to "turn Off computer".



              I may have forgotten some steps. Please tell me if it didn't work, I'll help you and fix instruction.
              Tested on Ubuntu 18.04 LTS.
              I didn't create question just to answer it. I didn't knew the answer when I created the question.



              To turn PC on using Google Home you don't need to do anything in ubuntu: there is a lot of instructions how to do it using WOL and android. Just type "turn on PC with google home" in google search.






              share|improve this answer




























                0














                0










                0









                OK. After some time I got it working.



                I achieved turning off Ubuntu by using IFTTT, Dropbox and inotifywait (inotifywait is a tool that can run scripts or commands when some file or folder changes).



                It looks something like this:
                I ask Google Home to turn off PC -> Google Home asks IFTTT to change file in Dropbox -> inotifywait sees the change in the file and make PC power-off.



                Step by step:



                1. Go to https://www.dropbox.com and register if you don't have account.


                2. Go to https://www.dropbox.com/install
                  Download package for ubuntu, install this package by double clicking.


                3. Open Dropbox in apps menu, go through the process of connecting your account.
                  Now you should have a "Dropbox" folder in your "Home" folder.
                  Create folder "RemoteTurnOff" in "Dropbox" folder.
                  Inside "RemoteTurnOff" folder create file "fileToWatch.txt"
                  You can do this by going to your apps, open "Text Editor" now choose 3 dots menu, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "fileToWatch.txt"


                4. Inside "RemoteTurnOff" folder create file "script.sh"
                  You can do this by going to your apps, open "Text Editor".
                  Paste this code to editor:



                #!/bin/sh
                ### BEGIN INIT INFO
                # Provides: filenotifier
                # Required-Start: $remote_fs $syslog
                # Required-Stop: $remote_fs $syslog
                # Default-Start: 2 3 4 5
                # Default-Stop: 0 1 6
                # Short-Description: Something
                # Description: Something else
                ### END INIT INFO
                cd /home/YOUR_USER_NAME/Dropbox/RemoteTurnOff
                inotifywait -e close_write,moved_to,create -m . |
                while read -r directory events filename; do
                if [ "$filename" = "fileToWatch.txt" ]; then
                systemctl poweroff
                fi
                done



                Important: Change YOUR_USER_NAME to your user name.
                If you don't know your user name: open Terminal and type



                whoami


                Now press on 3 dots menu in text editor, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "script.sh"



                1. Right click on script.sh -> Properties -> Permissions -> click on "Allow executing file as program" (it should be checked).

                To be sure it's executable do this:
                Right click on empty space inside RemoteTurnOff folder.
                Choose "Open In Terminal"
                Run this command:



                sudo chmod +x script.sh


                1. You can now test if script works.
                  Open RemoteTurnOff folder, right click on empty space, choose "Open in Terminal",
                  type:


                ./script.sh




                Don't close the terminal, open "fileToWatch.txt" in editor, type some text, save the changes. Your computer should shutdown.
                If it did shutdown then everything's OK - continue.



                1. Lets make the script run in background on startup.
                  Open terminal, past command:


                cd /etc




                past command



                sudo nano rc.local


                You should now be in text editor mode.
                Paste this text to editor:



                #!/bin/sh -e
                sh '/home/YOUR_USER_NAME/Dropbox/RemoteTurnOff/script.sh' &
                exit 0


                You need to change YOUR_USER_NAME to your name (use whoami command in another terminal window to get the name, if you don't know it).
                Don't forget "&" sign at the end of second line!



                Press Ctrl+O to save it. Press Enter to confirm name.
                It should look like this: pic



                Press Ctrl+X to exit text editor mode in terminal.



                Now run this command to make rc.local executable:



                sudo chmod +x rc.local


                Now the script should start at startup in background. Test it: reboot, than go to Dropbox -> RemoteTurnOff open "fileToWatch.txt", paste some text and save. The PC should reboot.
                All hard work is done. Next we'll connect Dropbox to Google Home.



                1. Go to https://ifttt.com/
                  Register (it's better to use google account for registration)


                2. Go to https://ifttt.com/services/google_assistant/settings
                  Connect to your Google Home. Make sure the status is active.


                3. Go to https://ifttt.com/services/dropbox/settings
                  Connect your Dropbox. Make sure the status is active.


                4. On IFTTT site lets create new applet. Click on "My applets" and then on "Create applet".


                5. Press on "+ this", search for "assistant", click on "Google Assistant"


                6. Choose "Say a simple phrase".


                7. On next screen fill in phrase you will use to talk to google home.
                  In my case it looks something like this:
                  pic
                  Then press on "Create trigger"


                8. Press on "+ that"
                  Search for "Dropbox", choose "Dropbox".
                  On next screen choose third option: "Append to a text file"


                9. Fill info:


                file name -> "fileToWatch.txt"



                content -> "#" (it can be any symbol)



                dropbox folder path -> "RemoteTurnOff/"



                pic



                Click on "Create action".
                It's better to disable notification - it gets annoying.



                Now tell your google home to "turn Off computer".



                I may have forgotten some steps. Please tell me if it didn't work, I'll help you and fix instruction.
                Tested on Ubuntu 18.04 LTS.
                I didn't create question just to answer it. I didn't knew the answer when I created the question.



                To turn PC on using Google Home you don't need to do anything in ubuntu: there is a lot of instructions how to do it using WOL and android. Just type "turn on PC with google home" in google search.






                share|improve this answer














                OK. After some time I got it working.



                I achieved turning off Ubuntu by using IFTTT, Dropbox and inotifywait (inotifywait is a tool that can run scripts or commands when some file or folder changes).



                It looks something like this:
                I ask Google Home to turn off PC -> Google Home asks IFTTT to change file in Dropbox -> inotifywait sees the change in the file and make PC power-off.



                Step by step:



                1. Go to https://www.dropbox.com and register if you don't have account.


                2. Go to https://www.dropbox.com/install
                  Download package for ubuntu, install this package by double clicking.


                3. Open Dropbox in apps menu, go through the process of connecting your account.
                  Now you should have a "Dropbox" folder in your "Home" folder.
                  Create folder "RemoteTurnOff" in "Dropbox" folder.
                  Inside "RemoteTurnOff" folder create file "fileToWatch.txt"
                  You can do this by going to your apps, open "Text Editor" now choose 3 dots menu, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "fileToWatch.txt"


                4. Inside "RemoteTurnOff" folder create file "script.sh"
                  You can do this by going to your apps, open "Text Editor".
                  Paste this code to editor:



                #!/bin/sh
                ### BEGIN INIT INFO
                # Provides: filenotifier
                # Required-Start: $remote_fs $syslog
                # Required-Stop: $remote_fs $syslog
                # Default-Start: 2 3 4 5
                # Default-Stop: 0 1 6
                # Short-Description: Something
                # Description: Something else
                ### END INIT INFO
                cd /home/YOUR_USER_NAME/Dropbox/RemoteTurnOff
                inotifywait -e close_write,moved_to,create -m . |
                while read -r directory events filename; do
                if [ "$filename" = "fileToWatch.txt" ]; then
                systemctl poweroff
                fi
                done



                Important: Change YOUR_USER_NAME to your user name.
                If you don't know your user name: open Terminal and type



                whoami


                Now press on 3 dots menu in text editor, press "Save as" and find and choose RemoteTurnOff folder. Don't forget to change file name to "script.sh"



                1. Right click on script.sh -> Properties -> Permissions -> click on "Allow executing file as program" (it should be checked).

                To be sure it's executable do this:
                Right click on empty space inside RemoteTurnOff folder.
                Choose "Open In Terminal"
                Run this command:



                sudo chmod +x script.sh


                1. You can now test if script works.
                  Open RemoteTurnOff folder, right click on empty space, choose "Open in Terminal",
                  type:


                ./script.sh




                Don't close the terminal, open "fileToWatch.txt" in editor, type some text, save the changes. Your computer should shutdown.
                If it did shutdown then everything's OK - continue.



                1. Lets make the script run in background on startup.
                  Open terminal, past command:


                cd /etc




                past command



                sudo nano rc.local


                You should now be in text editor mode.
                Paste this text to editor:



                #!/bin/sh -e
                sh '/home/YOUR_USER_NAME/Dropbox/RemoteTurnOff/script.sh' &
                exit 0


                You need to change YOUR_USER_NAME to your name (use whoami command in another terminal window to get the name, if you don't know it).
                Don't forget "&" sign at the end of second line!



                Press Ctrl+O to save it. Press Enter to confirm name.
                It should look like this: pic



                Press Ctrl+X to exit text editor mode in terminal.



                Now run this command to make rc.local executable:



                sudo chmod +x rc.local


                Now the script should start at startup in background. Test it: reboot, than go to Dropbox -> RemoteTurnOff open "fileToWatch.txt", paste some text and save. The PC should reboot.
                All hard work is done. Next we'll connect Dropbox to Google Home.



                1. Go to https://ifttt.com/
                  Register (it's better to use google account for registration)


                2. Go to https://ifttt.com/services/google_assistant/settings
                  Connect to your Google Home. Make sure the status is active.


                3. Go to https://ifttt.com/services/dropbox/settings
                  Connect your Dropbox. Make sure the status is active.


                4. On IFTTT site lets create new applet. Click on "My applets" and then on "Create applet".


                5. Press on "+ this", search for "assistant", click on "Google Assistant"


                6. Choose "Say a simple phrase".


                7. On next screen fill in phrase you will use to talk to google home.
                  In my case it looks something like this:
                  pic
                  Then press on "Create trigger"


                8. Press on "+ that"
                  Search for "Dropbox", choose "Dropbox".
                  On next screen choose third option: "Append to a text file"


                9. Fill info:


                file name -> "fileToWatch.txt"



                content -> "#" (it can be any symbol)



                dropbox folder path -> "RemoteTurnOff/"



                pic



                Click on "Create action".
                It's better to disable notification - it gets annoying.



                Now tell your google home to "turn Off computer".



                I may have forgotten some steps. Please tell me if it didn't work, I'll help you and fix instruction.
                Tested on Ubuntu 18.04 LTS.
                I didn't create question just to answer it. I didn't knew the answer when I created the question.



                To turn PC on using Google Home you don't need to do anything in ubuntu: there is a lot of instructions how to do it using WOL and android. Just type "turn on PC with google home" in google search.







                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered May 30 at 10:40









                Oleg BarchukOleg Barchuk

                1




                1































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f1146814%2fhow-can-i-remotely-shutdown-ubuntu-using-google-home%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

                    Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

                    How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

                    Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü