marguerite / linux-bing-wallpaper

set Bing Wallpaper of the Day as your Linux Desktop's wallpaper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to start from systemd

timxx opened this issue · comments

Can not run with systemctl --user start bing-wallpaper.service as README mentioned

status from systemctl --user status bing-wallpaper.service

Process: 1389 ExecStart=/workspace/projects/linux-bing-wallpaper/bing-wallpaper zh-CN true (code=exited, status=2)
Main PID: 1389 (code=exited, status=2)

Mar 04 18:27:47 ooxx systemd[476]: bing-wallpaper.service: Service hold-off time over, scheduling restart.
Mar 04 18:27:47 ooxx systemd[476]: bing-wallpaper.service: Scheduled restart job, restart counter is at 5.
Mar 04 18:27:47 ooxx systemd[476]: Stopped Bing Wallpaper of the Day as your Linux Desktop's wallpaper.
Mar 04 18:27:47 ooxx systemd[476]: bing-wallpaper.service: Start request repeated too quickly.
Mar 04 18:27:47 ooxx systemd[476]: bing-wallpaper.service: Failed with result 'exit-code'.
Mar 04 18:27:47 ooxx systemd[476]: Failed to start Bing Wallpaper of the Day as your Linux Desktop's wallpaper.

logs from journalctl --user-unit bing-wallpaper.service

Mar 04 18:27:45 ooxx systemd[476]: Started Bing Wallpaper of the Day as your Linux Desktop's wallpaper.
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: panic: strconv.ParseBool: parsing "": invalid syntax
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: goroutine 1 [running]:
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: main.check(0x6d76e0, 0xc420086d20)
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: /workspace/projects/linux-bing-wallpaper/bing-wallpaper.go:26 +0x4a
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: main.detect_de(0x92b9bcca1072ffa6, 0x8)
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: /workspace/projects/linux-bing-wallpaper/bing-wallpaper.go:57 +0x522
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: main.main()
Mar 04 18:27:45 ooxx bing-wallpaper[1359]: /workspace/projects/linux-bing-wallpaper/bing-wallpaper.go:359 +0x74
Mar 04 18:27:45 ooxx systemd[476]: bing-wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mar 04 18:27:45 ooxx systemd[476]: bing-wallpaper.service: Failed with result 'exit-code'.
Mar 04 18:27:46 ooxx systemd[476]: bing-wallpaper.service: Service hold-off time over, scheduling restart.
Mar 04 18:27:46 ooxx systemd[476]: bing-wallpaper.service: Scheduled restart job, restart counter is at 1.
Mar 04 18:27:46 ooxx systemd[476]: Stopped Bing Wallpaper of the Day as your Linux Desktop's wallpaper.

It seems that go can't get XDG_CURRENT_DESKTOP env when starts from systemd because I do have that env (XDG_CURRENT_DESKTOP=XFCE), it works when run the binary directly. LoL

OS: ArchLinux x64 with xfce4 desktop

can you please add:
log.Println(os.Getenv(“XDG_CURRENT_DESKTOP”))

before:

de := strings.ToLower(os.Getenv("XDG_CURRENT_DESKTOP"))

run go build again, then the systemd service to check what the log say?

I am on KF5, and it’s good...

I add log.Println("hello" + os.Getenv("XDG_CURRENT_DESKTOP") + ">>"),
and grep the log

Mar 04 20:43:22 ooxx bing-wallpaper[1633]: 2018/03/04 20:43:22 hello>>

My systemd version is 237.64... Tested serveral other env, all is empty. LoL

Found a solution from ArchWiki