notify-send: minha versão, muito mais simples.
This commit is contained in:
parent
ec64cd77f9
commit
2e9101c142
88
notify-send
88
notify-send
|
@ -1,81 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Shell script to redirect notify-send calls to herbe. The purpose is to ignore
|
|
||||||
# options passed to notify-send.
|
|
||||||
#
|
|
||||||
# Option parser generated by getoptions
|
|
||||||
# URL: https://github.com/ko1nksm/getoptions
|
|
||||||
# LICENSE: Creative Commons Zero v1.0 Universal
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf '%s\n' "${0##*/}: notify-send replacement for herbe" "accepts but ignores all notify-send options."
|
cat <<-EOF
|
||||||
|
notify-send replacement for herbe; accepts but ignores all notify-send options.
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
REST=''
|
while [ $# -gt 0 ]; do
|
||||||
parse() {
|
case "$1" in
|
||||||
OPTIND=$(($#+1))
|
-?|--help) usage ;;
|
||||||
while [ $# -gt 0 ] && OPTARG=; do
|
-[aAutichr]|--[aueichr]*) shift ;;
|
||||||
case $1 in
|
-[pwe]|--[pwt]*) ;;
|
||||||
--?*=*) OPTARG=$1; shift
|
*) herbe "$1" ;;
|
||||||
eval 'set -- "${OPTARG%%\=*}" "${OPTARG#*\=}"' ${1+'"$@"'}
|
esac
|
||||||
;;
|
shift
|
||||||
-[utich]?*) OPTARG=$1; shift
|
done
|
||||||
eval 'set -- "${OPTARG%"${OPTARG#??}"}" "${OPTARG#??}"' ${1+'"$@"'}
|
|
||||||
;;
|
|
||||||
-[!-]?*) OPTARG=$1; shift
|
|
||||||
eval 'set -- "${OPTARG%"${OPTARG#??}"}" "-${OPTARG#??}"' ${1+'"$@"'}
|
|
||||||
OPTARG= ;;
|
|
||||||
esac
|
|
||||||
case $1 in
|
|
||||||
-u | --urgency)
|
|
||||||
[ $# -le 1 ] && set -- "$1" required && break
|
|
||||||
OPTARG=$2
|
|
||||||
_=$OPTARG
|
|
||||||
shift ;;
|
|
||||||
-t | --expire-time)
|
|
||||||
[ $# -le 1 ] && set -- "$1" required && break
|
|
||||||
OPTARG=$2
|
|
||||||
_=$OPTARG
|
|
||||||
shift ;;
|
|
||||||
-i | --icon)
|
|
||||||
[ $# -le 1 ] && set -- "$1" required && break
|
|
||||||
OPTARG=$2
|
|
||||||
_=$OPTARG
|
|
||||||
shift ;;
|
|
||||||
-c | --category)
|
|
||||||
[ $# -le 1 ] && set -- "$1" required && break
|
|
||||||
OPTARG=$2
|
|
||||||
_=$OPTARG
|
|
||||||
shift ;;
|
|
||||||
-h | --hint)
|
|
||||||
[ $# -le 1 ] && set -- "$1" required && break
|
|
||||||
OPTARG=$2
|
|
||||||
_=$OPTARG
|
|
||||||
shift ;;
|
|
||||||
-? | --help)
|
|
||||||
usage
|
|
||||||
exit 0 ;;
|
|
||||||
--) shift
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
REST="${REST} \"\${$(($OPTIND-$#))}\""
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
break ;;
|
|
||||||
[-]?*) set -- "$1" unknown && break ;;
|
|
||||||
*) REST="${REST} \"\${$(($OPTIND-$#))}\""
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
[ $# -eq 0 ] && return 0
|
|
||||||
case $2 in
|
|
||||||
unknown) echo "unrecognized option '$1'" ;;
|
|
||||||
noarg) echo "option '$1' doesn't allow an argument" ;;
|
|
||||||
required) echo "option '$1' requires an argument" ;;
|
|
||||||
pattern) echo "option '$1' does not match the pattern ($3)" ;;
|
|
||||||
*) echo "option '$1' validation error: $2"
|
|
||||||
esac >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
parse "$@"
|
|
||||||
eval set -- "$REST"
|
|
||||||
herbe "$@" &
|
|
||||||
|
|
Loading…
Reference in New Issue