Added `--socket` parameter in `acejuice-interval` and `acejuice-pulse`, added better handling of fifo warning in all scripts

master
Meliurwen 2 years ago
parent d0fec9c00c
commit 58321d01a4
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 7
      .local/bin/acejuice
  2. 31
      .local/bin/acejuice-interval
  3. 35
      .local/bin/acejuice-pulse

@ -41,7 +41,9 @@ mkdir -p "$_pipe_dir"
NPIPE_IN="$_pipe_dir/main.sock"
unset _pipe_dir
mkfifo "$NPIPE_IN" 2> /dev/null || printf "fifo already present\n"
if ! mkfifo "$NPIPE_IN" 2> /dev/null; then
printf "fifo '%s' already present\n" "$NPIPE_IN" >&2
fi
PID_SELF=$$
@ -159,7 +161,8 @@ while read -r line; do
msg_cmd_colon "${line% "$content"}" "${content}"
;;
*)
printf "%s\n" "$line"
:
#printf "%s\n" "$line"
;;
esac
done < "$NPIPE_IN"

@ -2,16 +2,33 @@
set -e
while [ $# -gt 0 ] ; do
case "$1" in
"--socket")
_pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice"
mkdir -p "$_pipe_dir"
NPIPE_OUT="$_pipe_dir/main.sock"
unset _pipe_dir
if ! mkfifo "$NPIPE_OUT" 2> /dev/null; then
printf "fifo '%s' already present\n" "$NPIPE_OUT" >&2
fi
;;
*)
printf "Parameter not recognized. Aborting...\n"
exit 1
;;
esac
shift
done
__send_cmd () {
printf "%s %s\n" "$1" "$2" > "$NPIPE_OUT"
if [ -n "$NPIPE_OUT" ]; then
printf "%s %s\n" "$1" "$2" > "$NPIPE_OUT"
else
printf "%s %s\n" "$1" "$2"
fi
}
_pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice"
mkdir -p "$_pipe_dir"
NPIPE_OUT="$_pipe_dir/main.sock"
unset _pipe_dir
mkfifo "$NPIPE_IN" 2> /dev/null || printf "fifo already present\n"
cycle=0

@ -13,6 +13,15 @@ while [ $# -gt 0 ] ; do
"--no-value")
no_value=1
;;
"--socket")
_pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice"
mkdir -p "$_pipe_dir"
NPIPE_OUT="$_pipe_dir/main.sock"
unset _pipe_dir
if ! mkfifo "$NPIPE_OUT" 2> /dev/null; then
printf "fifo '%s' already present\n" "$NPIPE_OUT" >&2
fi
;;
"--icon")
case $2 in
"ascii"|""|"--"*)
@ -114,14 +123,34 @@ __send(){
;;
esac
printf ":SET audi %b%s%s%s%s%b%s" "${color}" "${icon}" "${status}" "${lvl}" "${unitsymbol}" "${colend}${colbgend}" "${sep}"
if [ -n "$NPIPE_OUT" ]; then
printf ":SET audi %b%s%s%s%s%b%s" "${color}" "${icon}" "${status}" "${lvl}" "${unitsymbol}" "${colend}${colbgend}" "${sep}" > "$NPIPE_OUT"
else
printf ":SET audi %b%s%s%s%s%b%s" "${color}" "${icon}" "${status}" "${lvl}" "${unitsymbol}" "${colend}${colbgend}" "${sep}"
fi
[ "$newline" = 1 ] && printf "\n" || :
if [ "$newline" = 1 ]; then
if [ -n "$NPIPE_OUT" ]; then
printf "\n" > "$NPIPE_OUT"
else
printf "\n"
fi
fi
}
if [ -t 0 ]; then
printf "running interactivelly"
_pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice"
mkdir -p "$_pipe_dir"
NPIPE_IN="$_pipe_dir/acejuice-pulse.sock"
unset _pipe_dir
if ! mkfifo "$NPIPE_IN" 2> /dev/null; then
printf "fifo '%s' already present\n" "$NPIPE_IN" >&2
fi
while read -r line ; do
__send $line
done < "$NPIPE_IN"
else
while read -r line ; do
__send $line

Loading…
Cancel
Save