elkowar / eww

ElKowars wacky widgets
https://elkowar.github.io/eww
MIT License
8.9k stars 369 forks source link

[BUG] Start daemon on user session #179

Open hiukky opened 3 years ago

hiukky commented 3 years ago

Describe the bug

I think we need a little bit of information about how the eww daemon and lifecycle works. I tried some settings to start the daemon with the system but I always get the error https://github.com/elkowar/eww/blob/master/src/application_lifecycle.rs#L13-L16.

Expected behaviour

Even to start with Sway a simple exec starting the daemon and opening the windows requires time until the server starts, a simple command resolves, but the initial idea now was to run the eww together with the login and when loading the WM just open the windows once the server has started. but I needed to understand this cycle.

Additional context

Logs with systemd

May 21 20:51:52 flate bash [6163]: ┏━━━━━━━━━━━━━━━━━━━━━━━┓ May 21 20:51:52 flate bash [6163]: ┃Initializing eww daemon┃ May 21 20:51:52 flate bash [6163]: ┗━━━━━━━━━━━━━━━━━━━━━━━┛ May 21 20:51:52 flate bash [6163]: May 21 20:51:52 flate bash [6163]: 2021-05-21T23: 51: 52.108Z INFO eww :: server> Loading paths: config-dir: /home/hiukky/.config/eww, ipc-socket: / run / user / 1001 / eww-server_L2hvbWUvaGl1a2t5> May 21 20:51:52 flate bash [6163]: 2021-05-21T23: 51: 52.109Z INFO eww :: server> Shutting down eww daemon ... May 21 20:51:52 flate bash [6163]: 2021-05-21T23: 51: 52.109Z ERROR eww :: server> Failed to send application shutdown event to workers: Failed to send exit lifecycle event May 21 20:51:52 flate bash [6163]: Caused by: May 21 20:51:52 flate bash [6163]: channel closed May 21 20:51:52 flate systemd [619]: eww.service: Deactivated successfully.

elkowar commented 3 years ago

Can you try running the daemon with --debug to see if there is any more output? I'm assuming that eww is failing to start the GTK stuff before a graphical session has been started. What eww does is it first initializes a gtk application lifecycle, then initializes it's own daemon, where it creates the IPC socket, and so on. If it just fails immediately, that looks to me like gtk is just failing out of nowhere

hiukky commented 3 years ago

@elkowar I had run it with --debug but as the service was not starting, the logs were always the one from the previous session. Looking at your explanation, maybe using systemd for this is not the best option. I will try https://help.gnome.org/admin/system-admin-guide/stable/autostart-applications.html.en with autostart keeping in mind that GTK and session material are already started when running eww.

wiredmatt commented 3 years ago

Hello, I was struggling with the same, my solution:

dependencies: crontab or any job scheduler that allows running on boot / startup / login

crontab -e 

contents:

@reboot  DISPLAY=:0 && /path/to/script #(must be absolute, using ~ or $HOME didn't work for me).

/path/to/script contents:

#!/bin/sh

/{ewwLocation}/eww daemon

/{ewwLocation}/eww open bar # In my case I want my status bar to open.

while [ $? -ne 0 ]; do /{ewwLocation}/eww open bar; done # Until that's successful, keep executing it

For obvious reasons you could also add a timeout, say, if after 10 seconds it didn't succeed log the errors to a file and exit the script.

I think this should be in the documentation, I also thought I could just enable it with systemd, and probably most users want something like a status bar when they log in.

Other alternatives: