scripts(caway): removed as i don't use it anymore
This commit is contained in:
1 parent
6edf27f1c0
commit
512bcd8d95
1 file changed
-91
@@ -305,97 +305,6 @@ fi
|
||||
ln -sf "$HOME/.cache/wal/cava-colors" "$HOME/dotfiles/cava/config" || true
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Cava visulizer #
|
||||
# #
|
||||
######################################
|
||||
|
||||
caway() {
|
||||
|
||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
||||
BARS=8;
|
||||
FRAMERATE=60;
|
||||
EQUILIZER=1;
|
||||
# Get script options
|
||||
while getopts 'b:f:m:eh' flag; do
|
||||
case "${flag}" in
|
||||
b) BARS="${OPTARG}" ;;
|
||||
f) FRAMERATE="${OPTARG}" ;;
|
||||
e) EQUILIZER=0 ;;
|
||||
h)
|
||||
echo "caway usage: caway [ options ... ]"
|
||||
echo "where options include:"
|
||||
echo
|
||||
echo " -b <integer> (Number of bars to display. Default 8)"
|
||||
echo " -f <integer> (Framerate of the equilizer. Default 60)"
|
||||
echo " -e (Disable equilizer. Default enabled)"
|
||||
echo " -h (Show help message)"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
bar="▁▂▃▄▅▆▇█"
|
||||
dict="s/;//g;"
|
||||
i=0 # creating "dictionary" to replace char with bar + thin space " "
|
||||
while [ $i -lt ${#bar} ]
|
||||
do
|
||||
dict="${dict}s/$i/${bar:$i:1} /g;"
|
||||
i=$((i=i+1))
|
||||
done
|
||||
dict="${dict}s/.$//;" # Remove last extra thin space
|
||||
clean_create_pipe() {
|
||||
if [ -p $1 ]; then
|
||||
unlink $1
|
||||
fi
|
||||
mkfifo $1
|
||||
}
|
||||
kill_pid_file() {
|
||||
if [[ -f $1 ]]; then
|
||||
while read pid; do
|
||||
{ kill "$pid" && wait "$pid"; } 2>/dev/null
|
||||
done < $1
|
||||
fi
|
||||
}
|
||||
cava_waybar_pid="/tmp/cava_waybar_pid" # PID of the cava process and while loop launched from the script
|
||||
cava_waybar_pipe="/tmp/cava_waybar.fifo" # Clean pipe for cava
|
||||
clean_create_pipe $cava_waybar_pipe
|
||||
cava_waybar_config="/tmp/cava_waybar_config" # Custom cava config
|
||||
echo "
|
||||
[general]
|
||||
mode = normal
|
||||
framerate = $FRAMERATE
|
||||
bars = $BARS
|
||||
|
||||
[output]
|
||||
method = raw
|
||||
raw_target = $cava_waybar_pipe
|
||||
data_format = ascii
|
||||
ascii_max_range = 7
|
||||
" > $cava_waybar_config
|
||||
|
||||
playerctl_waybar_pipe="/tmp/playerctl_waybar.fifo" # Clean pipe for playerctl
|
||||
clean_create_pipe $playerctl_waybar_pipe
|
||||
playerctl -a metadata --format '{"tooltip": "{{playerName}} : {{markup_escape(artist)}} - {{markup_escape(title)}}", "alt": "{{status}}", "class": "{{status}}"}' -F > "$playerctl_waybar_pipe" & # playerctl output into playerctl_waybar_pipe
|
||||
while read -r line; do # Read the playerctl o/p via its fifo pipe
|
||||
kill_pid_file $cava_waybar_pid # Kill the cava process to stop the input to cava_waybar_pipe
|
||||
echo "$line" | jq --unbuffered --compact-output
|
||||
# If the class says "Playing" and equilizer is enabled
|
||||
# then show the cava equilizer
|
||||
if [[ $EQUILIZER == 1 && $(echo $line | jq -r '.class') == 'Playing' ]]; then
|
||||
sleep 2 # Show the playing title for 2 seconds
|
||||
cava -p $cava_waybar_config >$cava_waybar_pipe & # cava output into cava_waybar_pipe
|
||||
echo $! > $cava_waybar_pid # Save the PID of child process
|
||||
while read -r cmd2; do # Read the cava o/p via its fifo pipe
|
||||
echo "$line" | jq --arg a $(echo $cmd2 | sed "$dict") '.text = $a' --unbuffered --compact-output # Change the "text" key to bars
|
||||
done < $cava_waybar_pipe & # Do this fifo read in background
|
||||
echo $! >> $cava_waybar_pid # Save the while loop PID into the file as well
|
||||
fi
|
||||
done < $playerctl_waybar_pipe
|
||||
}
|
||||
|
||||
|
||||
######################################
|
||||
# #
|
||||
# Cursor Zoom #
|
||||
|
||||
Reference in new issue
Block a user