nitrogen wrapper upd

master
Daniel Napora 2023-01-18 23:53:23 +01:00
parent 0f71cd37ef
commit 34eaf6e7ed
1 changed files with 22 additions and 10 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
#
# Wrapper for nitrogen, so LightDM wallpaper is synced.
#
@ -24,20 +24,32 @@ dbus-send \
string:BackgroundFile \
variant:string:"$bg_path"
# Mabox Colorizer
# Generate wallpaper color palette
WALLPALDIR="$HOME/.config/colormenu/palettes/wallp"
# for Mabox Colorizer
WALLPALDIR="$HOME/.cache/colorizer/palettes"
mkdir -p "$WALLPALDIR"
read WALLPATH<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | cut -d'=' -f2)
WALLPAPER=${WALLPATH##*/}
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"
read WALLPATH<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | cut -d'=' -f2) # full path to wallpaper file
# 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
# GENERATE THUMBNAIL
THUMBDIR="$HOME/.config/mabox/wallthumbs"
THUMBDIR="$HOME/.cache/colorizer/thumbs"
mkdir -p ${THUMBDIR}
THUMB="${THUMBDIR}/${WALLPAPER}.png"
THUMB="${THUMBDIR}/${NAME}.png"
if [[ ! -f "$THUMB" ]]; then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi