nwg-piotr / nwg-wrapper

Wrapper to display a script output or a text file content on the desktop in sway or other wlroots-based compositors
MIT License
139 stars 8 forks source link

Outputting a continuously running script without interval #15

Open arafatamim opened 2 years ago

arafatamim commented 2 years ago

An example, running the following script currently doesn't output anything.

#!/usr/bin/env sh
dbus-monitor --session "interface='org.freedesktop.Notifications',member='Notify',type='method_call'" | grep "method call"
xPMo commented 2 years ago

How does nwg-wrapper know what to output? The full output to that point? The most recent line? The most recent 10 lines?

However, this should be possible to script around, since nwg-wrapper has --sig_refresh/-sr:

#!/bin/sh
file=$(mktemp -u)
touch "$file.txt" "$file.tmp"
nwg-wrapper -t "$file.txt" -sr 13 "$@" & # other args
nwg_pid=$!
dbus-monitor --session "interface='org.freedesktop.Notifications',member='Notify',type='method_call'" | while read -r line; do
    printf '%s\n' "$line" >> "$file.tmp"
    tail "$file.tmp" > "$file.txt"  # last 10 lines
    kill -13 "$nwg_pid" || break
    cp "$file.txt" "$file.tmp"
done
kill "$nwg_pid"
rm "$file"*

But, I can't get this to work either. I might look more into it, it's a nice idea.