gnome-terminal
is a user GUI application and it requires a display server user session up and running first and then, the service launching it will require certain environment variables set and/or proper authentication/permissions granted.
You can specify those environment variables in a system service by for example setting the address to the display server, but that can change and you might need to set it again and there is more to launching a GUI user application from systemd
than just specifying those variables, so this is not recommended and a user service is the way to go IMO.
Therefore, you need to setup your service as a user-service in order to interact with your user-session environment by default as the environment variables like $DISPLAY
will be automatically inherited by a user service.
To do that you need to, first, place your unit/service file either under /usr/lib/systemd/user/
or under ~/.config/systemd/user/
in your user's home.
Then, inform systemd
about it without needing to reboot like so:
systemctl --user daemon-reload
Then, enable and start and manage it with the --user
flag and without sudo
like so:
systemctl --user enable unit-name
And:
systemctl --user start unit-name
You will always need to use the --user
flag to manage it from now on ... for example:
systemctl --user status unit-name
Or:
systemctl --user restart unit-name
Or:
systemctl --user stop unit-name
Notice:
You don't need to specify a user/group for the user service as it will run as your current logged-in user by default.
You might, also, want to change Restart=always
to Restart=on-failure
to avoid running multiple instances of your script if status reporting is not set from your script as it appears.
You might, as well, want to change WantedBy=multi-user.target
under [Install]
section to WantedBy=default.target
or similar graphical user target.