| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | |
| 4 | has() { command -v "$1" >/dev/null 2>&1; } |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | notify() { |
| 10 | has notify-send || return 0 |
| 11 | local key=$1 icon=$2 summary=$3 body=${4:-} value=${5:-} |
| 12 | local idfile="${XDG_RUNTIME_DIR:-/tmp}/dotfiles-notify-$key" |
| 13 | local args=(-a "sway" -i "$icon" -t 1500 -p) |
| 14 | [[ -n $value ]] && args+=(-h "int:value:$value") |
| 15 | [[ -s $idfile ]] && args+=(-r "$(cat "$idfile")") |
| 16 | notify-send "${args[@]}" "$summary" "$body" >"$idfile" 2>/dev/null || true |
| 17 | } |
| 18 | |
| 19 | |
| 20 | menu() { |
| 21 | wofi --dmenu --insensitive --prompt "$1" --cache-file /dev/null "${@:2}" |
| 22 | } |