Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uairctl listen prepends null terminators to every string except the first one #15

Open
ehula opened this issue Nov 21, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@ehula
Copy link

ehula commented Nov 21, 2023

This is a great tool!

I am using it in my waybar, but I am having a problem. I would like to be able to kill waybar and still have uair running in the background, and when I start waybar, I would like to be able to connect to the running uair.

In waybar, if I use the following exec line:
exec = "uair";
then when I kill waybar, uair also is killed. Makes sense.

However, I tried this:
exec = "pgrep -x uair > /dev/null && uairctl listen || nohup uair &";
which I thought would do it, but not quite. When I kill waybar, uair is still running. That's great. I can see output from the terminal using uairctl listen. However, when I restart waybar, I see the output from uairctl listen for about a second, then it disappears from waybar.

@metent
Copy link
Owner

metent commented Nov 24, 2023

I would suggest you to use the line exec = "uairctl listen"; in your polybar config and then create a user service for the 'main' uair instance using your init system. If you're using systemd you may use this service file.

[Unit]
Description=Uair

[Service]
Type=simple
ExecStart=/usr/bin/uair -q

[Install]
WantedBy=default.target

Alternatively, you can start the main instance when your window manager starts, but then the process is unsupervised and you can't start or stop it using your init system.

@haitemura
Copy link

haitemura commented Sep 30, 2024

The real reason why this happens is because uairctl listen prepends null terminators to every string except the first one. This can be observed by piping it into a file. uair does not do this, which is why your script works for the first time when starting waybar.

Here is the output of uairctl listen:
image

And here the output of just uair:
image

(The unicode characters at the end are because of my uair config.)
Waybar is written in C++ and so it thinks all those strings are empty, except for the first one, and it prints nothing.

@metent
Copy link
Owner

metent commented Nov 11, 2024

The real reason why this happens is because uairctl listen prepends null terminators to every string except the first one. This can be observed by piping it into a file. uair does not do this, which is why your script works for the first time when starting waybar.

Good catch! Will release a fix.

@metent metent changed the title problems making uair persistent when killing/starting waybar uairctl listen prepends null terminators to every string except the first one Nov 11, 2024
@metent metent added the bug Something isn't working label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants