Pipe operator not working in deflisten? #1213
-
I am sure I am missing something huge here but I can't figure out what. I am trying to build a bar for niri. I want to grab some streaming even data with the Concretely, Can somebody please enlighten me? I am stuck and I really want to get eww working. Thanks! Minimalist use case:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
The pipe operator only does something special when the command line is interpreted by a shell (e.g. bash, zsh, fish) and EWW doesn't run the command through a shell. To get that to work you can wrap the command line with a call to bash like this:
|
Beta Was this translation helpful? Give feedback.
-
I assume that the command (deflisten win_id :initial "-" `bash -c "niri msg -j event-stream | while read -r line; do echo "$line" | grep WindowFocusChanged; done"`) It would be advisable to create a script to make it easier and more understandable when changing something. Create a new file called window_focus_changed.sh #!/usr/bin/env bash
niri msg -j event-stream | {
while read -r line; do
echo "$line" | grep WindowFocusChanged
done
} Then just give them the necessary permissions with (deflisten win_id :initial "-" `./path/to/window_focus_changed.sh`) |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot to both of you for your help. Both solutions work but I marked the one from @SylvAbdomen as answer because it is more concise. You made my Sunday, thanks ! |
Beta Was this translation helpful? Give feedback.
Is there an advantage to doing it this over using the
--line-buffered
option?grep by itself does work well for long running streams.
For example one of my scripts has this:
This outputs the lines immediately as they are matched instead of the normal buffering that grep will do.