unifiedremote / Docs

Official API documentation.
147 stars 33 forks source link

os.start not working on linux #44

Open Fabien-Morrow opened 6 months ago

Fabien-Morrow commented 6 months ago

Hi everyone and thanks for this amazing product !

I can't achieve to get os.start() to work.

Update the remote.lua of the Examples/Run remote with this :

--@help Command 1
actions.command1 = function ()
    os.start("firefox");
end

--@help Command 2
actions.command2 = function ()
    os.execute("firefox");
end

Firefox never launches. What I'm doing wrong ?

fabien@TOUR:~$ whereis firefox

firefox: /usr/bin/firefox /usr/lib/firefox /etc/firefox
HalJordan commented 6 months ago

I've been using this, it works on the soft control panel I made for Elite Dangerous to open some of the web based tools for it:

os.execute("xdg-open https://coriolis.io/");

You may need to put in the full path: /usr/bin/firefox

Fabien-Morrow commented 6 months ago

Ok it's definitively not a unified remote issue I've added the server as a systemd service, and I think this setup is responsible of this mess same problem here Too lazy to go deep into the rabbit hole to find what capability I should enable or not. Moreover, adding CapabilityBoundingSet=CAP_SYS_ADMIN for example just broke the service.

I've added unified remote as a service because it crashes sometimes...

Fabien-Morrow commented 6 months ago

I think I've solved the issue : os.start("firefox") returns "no DISPLAY environment variable specified"

This snipped helped me

function os.capture(cmd, raw)
  local f = assert(io.popen(cmd, 'r'))
  local s = assert(f:read('*a'))
  local ex1, ex2, ex3 = f:close()
  return s
end

--@help Command 1
actions.command1 = function ()
    local a,b,c=os.start('firefox')
    print(a,b,c)
end

I've fixed the issue by specifying DISPLAY in my service file

[Unit]
Description=Unified Remote Server
After=syslog.target network.target

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Type=forking
User=fabien
Environment=DISPLAY=:0
#PIDFile=$HOME/.urserver/urserver.pid
ExecStart=/opt/urserver/urserver-start
#ExecStop=/opt/urserver/urserver-stop

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=default.target