2

I'm following this tutorial (Creating my own systemd service files on Fedora 16(x86_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?

3
  • You should use code blocks (you can use the <pre> tag, or indent four spaces) so your snippets are more readable. Commented Sep 10, 2015 at 21:19
  • 1
    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
    Commented Sep 11, 2015 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. Commented Sep 11, 2015 at 19:48

2 Answers 2

3

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.

3
  • 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? Commented Sep 11, 2015 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. Commented Sep 11, 2015 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
    Commented Sep 12, 2015 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .