birde

Daemon-less notifications without D-Bus. Minimal and lightweight.
Log | Files | Refs | README | LICENSE

notify-send (2254B)


      1 #!/bin/sh
      2 # script comes from https://github.com/dudik/birde/pull/10
      3 # Shell script to redirect notify-send calls to birde. The purpose is to ignore
      4 # options passed to notify-send.
      5 #
      6 # Option parser generated by getoptions
      7 # URL: https://github.com/ko1nksm/getoptions
      8 # LICENSE: Creative Commons Zero v1.0 Universal
      9 
     10 usage() {
     11     printf '%s\n' "${0##*/}: notify-send replacement for birde" "accepts but ignores all notify-send options."
     12 }
     13 
     14 REST=''
     15 parse() {
     16   OPTIND=$(($#+1))
     17   while [ $# -gt 0 ] && OPTARG=; do
     18     case $1 in
     19       --?*=*) OPTARG=$1; shift
     20         eval 'set -- "${OPTARG%%\=*}" "${OPTARG#*\=}"' ${1+'"$@"'}
     21         ;;
     22       -[utich]?*) OPTARG=$1; shift
     23         eval 'set -- "${OPTARG%"${OPTARG#??}"}" "${OPTARG#??}"' ${1+'"$@"'}
     24         ;;
     25       -[!-]?*) OPTARG=$1; shift
     26         eval 'set -- "${OPTARG%"${OPTARG#??}"}" "-${OPTARG#??}"' ${1+'"$@"'}
     27         OPTARG= ;;
     28     esac
     29     case $1 in
     30       -u | --urgency)
     31         [ $# -le 1 ] && set -- "$1" required && break
     32         OPTARG=$2
     33         _=$OPTARG
     34         shift ;;
     35       -t | --expire-time)
     36         [ $# -le 1 ] && set -- "$1" required && break
     37         OPTARG=$2
     38         _=$OPTARG
     39         shift ;;
     40       -i | --icon)
     41         [ $# -le 1 ] && set -- "$1" required && break
     42         OPTARG=$2
     43         _=$OPTARG
     44         shift ;;
     45       -c | --category)
     46         [ $# -le 1 ] && set -- "$1" required && break
     47         OPTARG=$2
     48         _=$OPTARG
     49         shift ;;
     50       -h | --hint)
     51         [ $# -le 1 ] && set -- "$1" required && break
     52         OPTARG=$2
     53         _=$OPTARG
     54         shift ;;
     55       -? | --help)
     56         usage
     57         exit 0 ;;
     58       --) shift
     59         while [ $# -gt 0 ]; do
     60           REST="${REST} \"\${$(($OPTIND-$#))}\""
     61           shift
     62         done
     63         break ;;
     64       [-]?*) set -- "$1" unknown && break ;;
     65       *) REST="${REST} \"\${$(($OPTIND-$#))}\""
     66     esac
     67     shift
     68   done
     69   [ $# -eq 0 ] && return 0
     70   case $2 in
     71     unknown) echo "unrecognized option '$1'" ;;
     72     noarg) echo "option '$1' doesn't allow an argument" ;;
     73     required) echo "option '$1' requires an argument" ;;
     74     pattern) echo "option '$1' does not match the pattern ($3)" ;;
     75     *) echo "option '$1' validation error: $2"
     76   esac >&2
     77   exit 1
     78 }
     79 
     80 parse "$@"
     81 eval set -- "$REST"
     82 birde "$@" &