mabox-i18n-files/common/wrappers/nitrogen

53 lines
1.5 KiB
Plaintext
Raw Normal View History

2022-07-12 17:41:03 +02:00
#!/usr/bin/env bash
#
# Wrapper for nitrogen, so LightDM wallpaper is synced.
#
# Copyright (C) 2021 Rafael Cavalcanti - rafaelc.org
# Licensed under GPLv3
set -euo pipefail
/usr/bin/nitrogen "$@"
if [[ "${1:-}" == "--restore" ]]; then
exit $?
fi
readonly bg_path="$(awk -F '=' '/file/{print $2}' "$HOME/.config/nitrogen/bg-saved.cfg")"
dbus-send \
--print-reply \
--system \
--dest=org.freedesktop.Accounts \
/org/freedesktop/Accounts/User$(id -u) \
org.freedesktop.DBus.Properties.Set \
string:org.freedesktop.DisplayManager.AccountsService \
string:BackgroundFile \
variant:string:"$bg_path"
2022-08-14 23:49:44 +02:00
# Mabox Colorizer
2022-07-12 17:41:03 +02:00
# Generate wallpaper color palette
WALLPALDIR="$HOME/.config/colormenu/palettes/wallp"
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"
fi
# GENERATE THUMBNAIL
THUMBDIR="$HOME/.config/mabox/wallthumbs"
mkdir -p ${THUMBDIR}
THUMB="${THUMBDIR}/${WALLPAPER}.png"
if [[ ! -f "$THUMB" ]]; then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi
# auto generate themes
if command -v w2theme &> /dev/null
then
2022-07-19 13:55:03 +02:00
source ~/.config/colorizer/colorizer.conf
if [[ "$wall2themes" == "yes" ]];then
2022-08-14 23:49:44 +02:00
w2theme colorize
2022-07-12 17:41:03 +02:00
fi
fi