2

I'm following this tutorial (https://kezhong.wordpress.com/2011/11/19/creating-my-own-systemd-service-files-on-fedora-16x86_64/) to add a new systemd .service, but it doesn't work, i did step by step correct with some modifications to my scope.

My conkystart.service:

[Unit]
Description=Service to start conky at boot
After=graphical.target multi-user.target

[Service]
Type=simple
ExecStart=/usr/local/bin/conkystart.service

[Install]
WantedBy=multi-user.target

My simple script:

!#/bin/bash

sleep && conky;

Nothing it does'nt work. Some advice guys? What's wrong here?

  • You should use code blocks (you can use the <pre> tag, or indent four spaces) so your snippets are more readable. – Klaatu von Schlacker Sep 10 '15 at 21:19
  • your simple script doesn't work. !#/bin/bash is the invalid shebang. should be #!/bin/bash. sleep && conky; fails with sleep: missing operand Try 'sleep --help' for more information.. Why do you use sleep? – Evgeny Vereshchagin Sep 11 '15 at 15:30
  • @EvgenyVereshchagin the "!#/bin/bash" was a simple write error, in my script is correct "#!/bin/bash". And i'm using sleep because the script i'm using to initialize in mate-session-properties is it. I'm newbie in shell script. – Fabricio Araujo Sep 11 '15 at 19:48
2

You can't use this approach for conky. These scripts are run before the GUI is loaded and before you log in. Your service is loaded and attempts to execute conky, which promptly exits because there are no available X screens.

This sort of thing should be done via the autorun settings of whatever desktop environment or window manager you are using. Many common desktop environments will run the program described by any .desktop files in ~/.config/autostart. For example, to run conky create a file called ~/.config/autostart/conky.desktop with the following contents:

[Desktop Entry]
Type=Application
Exec=/usr/bin/conky
X-GNOME-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name[en_US]=conky
Comment[en_US]=
X-GNOME-Autostart-Delay=0
1

conky is an application that you probably want your user to launch (since it appears on your desktop). Launching it with systemd makes is a system process; systemd doesn't know where to put conky, or who to run it as.

What desktop environment are you using? there is usually an autostart function in a desktop's configuration, in which you can start user-processes once logged in.

  • I use mate in debian 8, and it works alright with a startup script in matesessionproperties, i'll like to put it in systemd to study how systemd works and to practice with a exercise. It Isn't possible? – Fabricio Araujo Sep 11 '15 at 1:42
  • I think it might be a better idea to just make a script that logs something to a file. For instance, rather than launching a graphical application like conky, try just echo "$USER $(date)" > /tmp/sysd-test.log or whatever. This way, you get to see that your systemd script worked, but you don't run into the nuances of which user is doing what. – Klaatu von Schlacker Sep 11 '15 at 1:49
  • 1
    conky needs to run inside an X display, and systemd services don't have any of the environment variables set to allow conky to find the X display. ($DISPLAY and $XAUTHORITY, for example) While technically possible to script around this by dynamically finding existing X sessions, it's probably not a great place to start for learning how to write systemd service units. – jsbillings Sep 12 '15 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.