mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-08-09 17:41:12 +10:00
A rewrite of notify-log.
This commit is contained in:
+37
-7
@@ -2,10 +2,40 @@
|
|||||||
|
|
||||||
logfile=$1
|
logfile=$1
|
||||||
|
|
||||||
dbus-monitor "interface='org.freedesktop.Notifications'" |\
|
declare -a MSGBUF
|
||||||
grep --line-buffered "string" |\
|
STATE=off
|
||||||
grep --line-buffered -e method -e ":" -e '""' -e urgency -e notify -v |\
|
MSGTIME=
|
||||||
grep --line-buffered '.*(?=string)|(?<=string).*' -oPi |\
|
|
||||||
grep --line-buffered -v "sender-pid" |\
|
printbuf() {
|
||||||
grep --line-buffered -v '^\s*$' |\
|
JOINED=$( echo "${MSGBUF[@]}" | sed 's/,$//' )
|
||||||
xargs -I '{}' echo {} >> "$logfile"
|
printf "%s\n%s\n" "--- ${MSGTIME} ---" "${JOINED}"
|
||||||
|
}
|
||||||
|
|
||||||
|
procmsg() {
|
||||||
|
if [[ "${1}" =~ member=Notify$ ]]; then
|
||||||
|
STATE=on
|
||||||
|
MSGTIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||||
|
MSGBUF=()
|
||||||
|
elif [[ "${1}" =~ member=NotificationClosed$ ]]; then
|
||||||
|
STATE=off
|
||||||
|
printbuf
|
||||||
|
else
|
||||||
|
if [[ "${STATE}" == "on" ]]; then
|
||||||
|
if [[ "${1}" =~ ^string ]]; then
|
||||||
|
case "${1}" in
|
||||||
|
"string \"\"") ;;
|
||||||
|
"string \"urgency\"") ;;
|
||||||
|
"string \"sender-pid\"") ;;
|
||||||
|
*)
|
||||||
|
MSGBUF+=$( echo -n "${1}," )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus-monitor "interface='org.freedesktop.Notifications'" | \
|
||||||
|
while read -r line; do
|
||||||
|
procmsg "$line" >> "$logfile"
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user