On Arch Linux, I am trying to create a systemd service which runs this Bash script:
#!/bin/bash
/bin/xbindkeys &
/bin/setxkbmap -layout gb
With some online guidance I then made a file named myfirst.service
in /etc/systemd/system
to store my service. Here are the contents of the file:
[Unit]
Description=Command Service
[Service]
ExecStart=/etc/startupjobscript
User=user1
Type=oneshot
Restart=on-abort
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
The service is supposed to execute /etc/startupjobscript
, which is the Bash script. After this I enabled and started the service with:
systemctl enable myfirst
systemctl start myfirst
But for some reason it doesn't work and shows that it has failed to load and run at all.
EDIT: here is what sudo systemctl status myfirst give me:
Warning: The unit file, source configuration file or drop-ins of myfirst.service changed on >disk. Run 'systemctl daemon-reload' to reload units.
● myfirst.service - Command Service
Loaded: loaded (/etc/systemd/system/myfirst.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-08-26 21:07:02 BST; 15min18min ago
Process: 332 ExecStart=/etc/startupjobscript (code=exited, status=255/EXCEPTION)
Main PID: 332 (code=exited, status=255/EXCEPTION)
Aug 26 21:07:01 archlinux systemd[1]: Starting Command Service...
Aug 26 21:07:02 archlinux startupjobscript[337]: Cannot open display "default display"
Aug 26 21:07:02 archlinux systemd[1]: myfirst.service: Main process exited, code=exited, sta>status=255/EXCEPTION
Aug 26 21:07:02 archlinux systemd[1]: myfirst.service: Failed with result 'exit-code'.
Aug 26 21:07:02 archlinux systemd[1]: Failed to start Command Service.