nitrogen wrapper upd

This commit is contained in:
Daniel Napora 2023-01-18 23:53:23 +01:00
parent 0f71cd37ef
commit 34eaf6e7ed

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/bash
# #
# Wrapper for nitrogen, so LightDM wallpaper is synced. # Wrapper for nitrogen, so LightDM wallpaper is synced.
# #
@ -24,20 +24,32 @@ dbus-send \
string:BackgroundFile \ string:BackgroundFile \
variant:string:"$bg_path" variant:string:"$bg_path"
# Mabox Colorizer # for Mabox Colorizer
# Generate wallpaper color palette WALLPALDIR="$HOME/.cache/colorizer/palettes"
WALLPALDIR="$HOME/.config/colormenu/palettes/wallp"
mkdir -p "$WALLPALDIR" mkdir -p "$WALLPALDIR"
read WALLPATH<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/} read WALLPATH<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | cut -d'=' -f2) # full path to wallpaper file
if [ ! -f "$WALLPALDIR/$WALLPAPER.clr" ]; then
convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr"
# Wallpaper history :)
echo ${WALLPATH} >> $HOME/.cache/colorizer/.wallpaper_history
## get filename for palette and thumbnails
NAME=${WALLPATH////_}
if [[ "${NAME}" =~ ^_home_.* ]]; then
n=${#HOME}
((n++))
NAME=${NAME:${n}}
fi
if [ ! -f "$WALLPALDIR/${NAME}.clr" ]; then
convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$NAME.clr"
fi fi
# GENERATE THUMBNAIL # GENERATE THUMBNAIL
THUMBDIR="$HOME/.config/mabox/wallthumbs" THUMBDIR="$HOME/.cache/colorizer/thumbs"
mkdir -p ${THUMBDIR} mkdir -p ${THUMBDIR}
THUMB="${THUMBDIR}/${WALLPAPER}.png" THUMB="${THUMBDIR}/${NAME}.png"
if [[ ! -f "$THUMB" ]]; then if [[ ! -f "$THUMB" ]]; then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi fi