TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Running a python script on a raspberry pi

    Raspberry Pi
    2
    23
    2.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      daproduct @Russ
      last edited by

      @Russ
      Hello again Russ. I have the command simply running from the commands.json. The command is just the one you had helped me with previously. The command opens a website, waits for a few seconds, and then its a xdotool command.

      The command I am trying to run is:
      "su - pi -c 'export DISPLAY=0.0; /usr/bin/chromium-browser https://www.yt.com/subscriptions/; sleep 5; xdotool mousemove 300 400; xdotool click 1;'"

      The first its run after startup, nothing happens. If I run the same command again, it executes without issue. I tried to tinker with it this weekend to save some time on diagnostics, but the same issue continues to persist.

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @daproduct
        last edited by Russ

        @daproduct,

        I tested it on my Raspberry Pi, except I used DISPLAY=:0 instead of DISPLAY=0.0.

        "su - pi -c 'export DISPLAY=:0; /usr/bin/chromium-browser https://www.yt.com/subscriptions/; sleep 5; xdotool mousemove 300 400; xdotool click 1;'"
        

        It worked every time after I ran triggercmdagent as root on my Raspberry Pi.

        You wrote, "The first its run after startup, ..." What's startup? Do you mean startup of the triggercmd agent, or startup of the Raspberry Pi?

        Edit: I just realized you're probably having your RPi login automatically as pi, and you've installed the background agent. I'll try that next.

        I tried it and it works every time for me. I installed the background agent with this command:

        /usr/share/triggercmdagent/app/src/installdaemon.sh
        

        I switched the "ground" field to "background" of course, so my entry looks like this:

            {
              "trigger": "Test",
              "command": "su - pi -c 'export DISPLAY=:0; /usr/bin/chromium-browser https://www.yt.com/subscriptions/; sleep 5; xdotool mousemove 300 400; xdotool click 1'",
              "ground": "background",
              "voice": "test",
              "allowParams": "false"
            }
        

        I also added xhost + to the end of my /etc/profile so it's enabled during boot.

        Russell VanderMey

        D 1 Reply Last reply Reply Quote 0
        • D
          daproduct @Russ
          last edited by

          @Russ
          Thank you Russ for looking into it.

          With the startup, I was referring to the RPI starting / booting up from being turned off. I noticed that the issue only happens from the RPI starting up and on the first instance a command is run. The next time a command is run, the command executes without issue. The main problem is the xdotool command not being executed on this first instance. However, the page is loaded.

          Also, I do have TriggerCMD installed as a background agent using that command and I do have xhost+ addeed to the end of the /etc/profile

          1 Reply Last reply Reply Quote 0
          • First post
            Last post