skratchdot / open-golang

Open a file, directory, or URI using the OS's default application for that object type. Optionally, you can specify an application to use.
MIT License
783 stars 65 forks source link

It doesn't open file if I run my script from systemctl #14

Open vsile opened 6 years ago

vsile commented 6 years ago

I use next service file;

[Unit] Description=Goserver

[Service] Type=simple Restart=always RestartSec=3

Environment=GOPATH=/home/user/goserver/ Environment=BROWSER=gvfs-open WorkingDirectory=/home/user ExecStart=/usr/bin/go run /home/user/goserver/totalmanager.go

[Install] WantedBy=multi-user.target

The script with open-golang is inside totalmanager.go

If I run my script "go run goserver/totalmanager.go" it works!

But if I use "sudo systemctl start totalmanager.service" it doesn't work! May be something wrong with Environment?

xiegeo commented 6 years ago

I have not tried this myself, but try:

[Service]
User=user

to start the service as your user, so it knows who to open the link for.