I’m using timedatectl
to watch for ntp changes. The following is the code:
args = ["sh", "-c", "timedatectl --monitor timesync-status"]
# Start process
pid, stdin_fd, stdout_fd, stderr_fd = GLib.spawn_async(
args,
flags=GLib.SpawnFlags.DO_NOT_REAP_CHILD,
standard_output=True,
standard_error=True
# Create IOChannel for stdout
stdout_channel = GLib.IOChannel.unix_new(stdout_fd)
stdout_channel.set_encoding(None) # Read raw bytes
stdout_channel.add_watch(GLib.IO_IN | GLib.IO_HUP, lambda *args: print("changed"))
)
But it only prints “changed” once
The actual command I intend to use here is timedatectl --monitor timesync-status | grep --line-buffered "Poll interval" | awk '{print $3}' fflush()
which outputs either 0s or something else. I tried with this command but got same results