fix(apps): improve Thunar and Mako integration
Some checks failed
Check / eval-and-lint (push) Has been cancelled
Some checks failed
Check / eval-and-lint (push) Has been cancelled
This commit is contained in:
@@ -9,8 +9,20 @@ if (($# == 0)); then
|
||||
fi
|
||||
|
||||
# Find the first notification whose 'summary' matches the regex in $1
|
||||
notification_id=$(makoctl list | grep -F "$1" | head -n1 | sed -E 's/^Notification ([0-9]+):.*/\1/')
|
||||
output=$(makoctl list)
|
||||
|
||||
if [[ -n $notification_id ]]; then
|
||||
makoctl dismiss -n $notification_id
|
||||
if [[ $output == "["* ]] || [[ $output == "{"* ]]; then
|
||||
# JSON format (mako 1.8+)
|
||||
# Structure is usually an array of notifications or a wrapper object
|
||||
notification_id=$(echo "$output" | jq -r --arg pat "$1" '
|
||||
if type == "array" then .
|
||||
else .notifications // .data[0] // [] end
|
||||
| .[] | select((.summary // .["summary-text"] // "") | contains($pat)) | .id' | head -n1)
|
||||
else
|
||||
# Human format (older mako)
|
||||
notification_id=$(echo "$output" | grep -F "$1" | head -n1 | sed -E 's/^Notification ([0-9]+):.*/\1/')
|
||||
fi
|
||||
|
||||
if [[ "$notification_id" =~ ^[0-9]+$ ]]; then
|
||||
makoctl dismiss -n "$notification_id"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user