Only react to last `dbus-monitor` event within a group

谁都会走 提交于 2019-12-11 21:25:40

问题


I'm writing a script to react to dbus-monitor but there are a group of 17 events logged in 8/100th of a second. I don't want to react to all 17 events. Only the last event assuming another event doesn't occur within a second or two.

I'm not sure how to code this in bash though?

Sample event log (condensed with grep):

$ cat "dbus-monitor-plugin.txt" | grep time= | grep xrandr
method call time=1538331767.151461 sender=:1.59 -> destination=:1.11 serial=1242 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.151706 sender=:1.59 -> destination=:1.11 serial=1248 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.152338 sender=:1.59 -> destination=:1.11 serial=1252 path=/org/freedesktop/ColorManager/devices/xrandr_Sony_SONY_TV___00_16843009_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.152597 sender=:1.59 -> destination=:1.11 serial=1255 path=/org/freedesktop/ColorManager/devices/xrandr_eDP_1_1_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.152606 sender=:1.59 -> destination=:1.11 serial=1256 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.156892 sender=:1.59 -> destination=:1.11 serial=1263 path=/org/freedesktop/ColorManager/devices/xrandr_Sony_SONY_TV___00_16843009_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.157062 sender=:1.59 -> destination=:1.11 serial=1264 path=/org/freedesktop/ColorManager/devices/xrandr_eDP_1_1_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.157095 sender=:1.59 -> destination=:1.11 serial=1267 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.157699 sender=:1.59 -> destination=:1.11 serial=1271 path=/org/freedesktop/ColorManager/devices/xrandr_Sony_SONY_TV___00_16843009_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.157707 sender=:1.59 -> destination=:1.11 serial=1272 path=/org/freedesktop/ColorManager/devices/xrandr_eDP_1_1_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.158672 sender=:1.59 -> destination=:1.11 serial=1280 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.158788 sender=:1.59 -> destination=:1.11 serial=1284 path=/org/freedesktop/ColorManager/devices/xrandr_Sony_SONY_TV___00_16843009_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.158954 sender=:1.59 -> destination=:1.11 serial=1286 path=/org/freedesktop/ColorManager/devices/xrandr_eDP_1_1_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.159344 sender=:1.59 -> destination=:1.11 serial=1289 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.159867 sender=:1.59 -> destination=:1.11 serial=1295 path=/org/freedesktop/ColorManager/devices/xrandr_Sony_SONY_TV___00_16843009_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.159946 sender=:1.59 -> destination=:1.11 serial=1296 path=/org/freedesktop/ColorManager/devices/xrandr_eDP_1_1_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll
method call time=1538331767.159979 sender=:1.59 -> destination=:1.11 serial=1299 path=/org/freedesktop/ColorManager/devices/xrandr_Toshiba_America_Info_Systems_Inc_TSB_TV_rick_1000; interface=org.freedesktop.DBus.Properties; member=GetAll

来源:https://stackoverflow.com/questions/52581787/only-react-to-last-dbus-monitor-event-within-a-group

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!