I'm trying to monitor theme changes using this command:
dbus-monitor --session "interface='org.freedesktop.portal.Settings', member=SettingChanged" | grep -o "uint32 ."
Output right now looks like this:
uint32 0
uint32 0
uint32 1
uint32 1
uint32 0
uint32 0
uint32 1
uint32 1
This output comes from theme toggling. The theme notification shows up twice for some reason. Now I want to pipe it to uniq
so I only remain with a single entry like so:
uint32 0
uint32 1
uint32 0
uint32 1
However appending uniq
at the end does not produce any output anymore.
dbus-monitor --session "interface='org.freedesktop.portal.Settings', member=SettingChanged" | grep -o "uint32 ." | uniq
From man uniq
:
Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output).
uniq
needs to buffer at least the last output line to be able to detect adjacent lines, I don't see any reason why it could not buffer it and pass it along the pipeline. I've tried tweaking line buffering as suggested here but the results are still the same for me.
dbus-monitor --session "interface='org.freedesktop.portal.Settings', member=SettingChanged" | grep -o "uint32 ." | stdbuf -oL -i0 uniq
dbus ... | awk 'BEGIN{last=""} $2!=last; {last=$2}'
uniq
and addedawk ...
. There is no output just like withuniq
. I've toggled the button a few times to let initial values settle in.stdbuf -oL -i0 uniq
. Updated the question to reflect that.