0
0
Fork 0
mirror of https://github.com/stronk-dev/Tokyo-Night-Linux.git synced 2024-10-17 20:58:16 -04:00
tokyo-night-linux/.config/polybar/pwidgets/scripts/pywal.sh
2021-07-18 11:26:12 +02:00

54 lines
1,007 B
Bash
Executable file

#!/usr/bin/env bash
# Color files
PFILE="$HOME/.config/polybar/pwidgets/colors.ini"
RFILE="$HOME/.config/polybar/pwidgets/scripts/rofi/colors.rasi"
# Get colors
pywal_get() {
wal -i "$1" -q -t
}
# Change colors
change_color() {
# polybar
sed -i -e "s/bg = #.*/bg = ${BG}/g" $PFILE
sed -i -e "s/fg = #.*/fg = ${FG}/g" $PFILE
sed -i -e "s/fga = #.*/fga = ${RFG}/g" $PFILE
sed -i -e "s/ac = #.*/ac = ${AC}/g" $PFILE
# rofi
cat > $RFILE <<- EOF
/* colors */
* {
al: #00000000;
bg: ${BG}FF;
fg: ${RFG}FF;
ac: ${AC}FF;
}
EOF
}
# Main
if [[ -f "/usr/bin/wal" ]]; then
if [[ "$1" ]]; then
pywal_get "$1"
# Source the pywal color file
. "$HOME/.cache/wal/colors.sh"
BG=`printf "%s\n" "$background"`
FG=`printf "%s\n" "$foreground"`
RFG=`printf "%s\n" "$color8"`
AC=`printf "%s\n" "$color1"`
change_color
else
echo -e "[!] Please enter the path to wallpaper. \n"
echo "Usage : ./pywal.sh path/to/image"
fi
else
echo "[!] 'pywal' is not installed."
fi