os/arch panel-notify: refactor

This commit is contained in:
Henrik Lissner 2016-11-20 20:42:29 -05:00
parent 050870c4ce
commit 3cfd9f0d43

View file

@ -1,36 +1,29 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CWD=$(cd $(dirname $0) && pwd -P) CWD=$(dirname $0)
if [[ -t 0 ]]; then
if [ -t 0 ] if (( $# == 0 )); then
then
if [ "$#" -eq 0 ]
then
>&2 echo "Usage: panel_update.sh [LEMON_TO_UPDATE]" >&2 echo "Usage: panel_update.sh [LEMON_TO_UPDATE]"
exit 1 exit 1
fi fi
case "$1" in case $1 in
:*) LEMON="$CWD/lemons/${1#?}" :*) LEMON="$CWD/lemons/${1#?}"
if [ ! -f "$LEMON" ] if [[ ! -f $LEMON ]]; then
then
>&2 echo "Couldn't find that lemon ($1)" >&2 echo "Couldn't find that lemon ($1)"
exit 2 exit 2
fi fi
. $CWD/panel-config . "$CWD/panel-config"
pkill -f "bash \./lemons/${1#?}" pkill -f "[bd]ash .+/lemons/${1#?}"
pushd "$CWD" >/dev/null "$LEMON" > "$PANEL_FIFO" &
$LEMON > "$PANEL_FIFO" &
popd >/dev/null
;; ;;
*) echo "$@" | $0 *) echo "$@" | $0
;; ;;
esac esac
else else
. $CWD/panel-config . $CWD/panel-config
while read -r line while read -r line; do
do
echo "$line" > "$PANEL_FIFO" & echo "$line" > "$PANEL_FIFO" &
done done
fi fi