dotfiles/eggs/utility/util-scripts/notification_history.sh
2025-05-19 16:47:38 +02:00

34 lines
990 B
Bash
Executable File

#!/usr/bin/env bash
# 1: Either show, remove, mute
if [ "$1" = "mute" ]; then
dunstctl set-paused toggle
exit 0
fi
history=$(dunstctl history | jq ".data[0]" | jq "sort_by(.timestamp.data)")
num_notifications=$(($(echo "$history" | jq "length") -1))
for i in $(seq 0 $(($(echo "$history" | jq "length") -1))); do
id=$(echo $history | jq ".[$i].id.data")
if [ $id -eq 1000 ]; then
continue
fi
echo $1
if [ "$1" = "show" ]; then
dunstctl history-pop $id
else
dunstctl history-rm $id
fi
done_notification=true
sleep 0.1
done
if [[ "$done_notification" != "true" ]]; then
msg=$(if [ "$1" = "show" ]; then echo "display"; else echo "clear"; fi)
dunstify -a System -r 1000 -t 2000 -i $HOME/.config/assets/no-notification.png "Dunsify" "No notifications to $msg."
elif [ "$1" = "remove" ]; then
dunstify -a System -r 1000 -t 2000 -i $HOME/.config/assets/no-notification.png "Dunsify" "Notifications cleared."
fi