-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvis
executable file
·30 lines (25 loc) · 1.07 KB
/
vis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
get_and_sort_wal_colors () {
# read wal colors in
mapfile -t wal_colors < "$1"
for i in "${!wal_colors[@]}"; do
curr_color=${wal_colors[i]}
r=$((16#${curr_color:1:2}))
g=$((16#${curr_color:3:2}))
b=$((16#${curr_color:5:2}))
# use brightness scale for later sorting (from here http://alienryderflex.com/hsp.html)
n=$(echo "sqrt(0.299*$r^2+0.114*$b^2+0.587*$g^2)" | bc -l)
comp_c[$i]="$i $n"
done
IFS=$'\n' sorted_c=($(sort -n -k2,2 <<<"${comp_c[*]}")); unset IFS
for element in "${sorted_c[@]}"; do
idx=$(echo "$element" | cut -f1 -d" ")
echo ${wal_colors[$idx]}
done
}
# send colorscheme to $CONFIG/vis/colors/pywal
[ -f $XDG_CONFIG_HOME/vis/config ] && get_and_sort_wal_colors "$HOME/.cache/wal/colors" > "$XDG_CONFIG_HOME/vis/colors/pywal" || \
[ -f $HOME/.config/vis/config ] && get_and_sort_wal_colors "$HOME/.cache/wal/colors" > "$HOME/.config/vis/colors/pywal"
PATH="/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/"
# run vis
vis