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. 27
      .local/bin/acejuice-interval
  3. 33
      .local/bin/acejuice-pulse

@ -41,7 +41,9 @@ mkdir -p "$_pipe_dir"
NPIPE_IN="$_pipe_dir/main.sock" NPIPE_IN="$_pipe_dir/main.sock"
unset _pipe_dir 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=$$ PID_SELF=$$
@ -159,7 +161,8 @@ while read -r line; do
msg_cmd_colon "${line% "$content"}" "${content}" msg_cmd_colon "${line% "$content"}" "${content}"
;; ;;
*) *)
printf "%s\n" "$line" :
#printf "%s\n" "$line"
;; ;;
esac esac
done < "$NPIPE_IN" done < "$NPIPE_IN"

@ -2,16 +2,33 @@
set -e set -e
__send_cmd () { while [ $# -gt 0 ] ; do
printf "%s %s\n" "$1" "$2" > "$NPIPE_OUT" case "$1" in
} "--socket")
_pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice" _pipe_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice"
mkdir -p "$_pipe_dir" mkdir -p "$_pipe_dir"
NPIPE_OUT="$_pipe_dir/main.sock" NPIPE_OUT="$_pipe_dir/main.sock"
unset _pipe_dir 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 () {
if [ -n "$NPIPE_OUT" ]; then
printf "%s %s\n" "$1" "$2" > "$NPIPE_OUT"
else
printf "%s %s\n" "$1" "$2"
fi
}
mkfifo "$NPIPE_IN" 2> /dev/null || printf "fifo already present\n"
cycle=0 cycle=0

@ -13,6 +13,15 @@ while [ $# -gt 0 ] ; do
"--no-value") "--no-value")
no_value=1 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") "--icon")
case $2 in case $2 in
"ascii"|""|"--"*) "ascii"|""|"--"*)
@ -114,14 +123,34 @@ __send(){
;; ;;
esac esac
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}" 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 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 else
while read -r line ; do while read -r line ; do
__send $line __send $line

Loading…
Cancel
Save