From 5d37349e74e1e2f75650ef31c40bb381c5e04e21 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Sun, 11 Sep 2022 17:26:49 +0200 Subject: [PATCH] Added first prototype version of `acejuice-bar` --- .local/bin/acejuice-bar | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 .local/bin/acejuice-bar diff --git a/.local/bin/acejuice-bar b/.local/bin/acejuice-bar new file mode 100755 index 0000000..d341349 --- /dev/null +++ b/.local/bin/acejuice-bar @@ -0,0 +1,69 @@ +#!/bin/sh + +set -e + +_pid_dir="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/acejuice" +mkdir -p "$_pid_dir" +PID_FILE="$_pid_dir/ajuice-bar.pid" +unset _pid_dir + +if [ -f "$PID_FILE" ]; then + while read -r pid; do + ppids="$(ps -o pid= --ppid $pid || :)" + if [ ! -z "$ppids" ]; then + printf "%s\n" "$ppids" | xargs kill -9 + fi + kill -15 $pid || : + done < "$PID_FILE" + + rm "$PID_FILE" +fi + +# PID of this script +printf "%s\n" "$$" >> "$PID_FILE" + +acejuice_monitors() { + _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 + echo + if command -v xrandr > /dev/null; then + __monitor_list="" + OLDIFS="$IFS" + IFS=" +" + for line in $(xrandr --listmonitors); do + case "$line" in + " "[0-9]*) + __monitor_list="$__monitor_list ${line##* }" + ;; + *) + : + ;; + esac + done + IFS="$OLDIFS" + echo "yaaa" + if [ -z "$__monitor_list" ]; then + printf ":MON LIST %s\n" "$__monitor_list" > "$NPIPE_OUT" + fi + unset __monitors_list + fi +} + +acejuice_monitors & +printf "%s\n" "$!" >> "$PID_FILE" + +acejuice-pulse --socket --newline & +printf "%s\n" "$!" >> "$PID_FILE" + +acejuice-interval --socket & +printf "%s\n" "$!" >> "$PID_FILE" + +acejuice | /usr/bin/lemonbar -p +printf "%s\n" "$!" >> "$PID_FILE"