upload
This commit is contained in:
119
local/bin/fehbg
Executable file
119
local/bin/fehbg
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Wrapper for nitrogen, which uses feh but save config to nitrogen save file
|
||||
# needed for nitrogen by feh replacement
|
||||
source ~/.config/colorizer/colorizer.conf
|
||||
|
||||
NITROGEN_FILE="$HOME/.config/nitrogen/bg-saved.cfg"
|
||||
|
||||
if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
|
||||
mb-wall "${2}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [[ "$1" == "default" ]];then
|
||||
feh --bg-fill /usr/share/backgrounds/marek-piwnicki-FgagFhxW4Sc-unsplash.jpg
|
||||
sd "file=.*$" "file=/usr/share/backgrounds/marek-piwnicki-FgagFhxW4Sc-unsplash.jpg" "$NITROGEN_FILE"
|
||||
else
|
||||
# jeśli restore to tylo przywróć i przerwij
|
||||
if [[ "${1:-}" == "--restore" ]]; then
|
||||
wp="$(awk -F '=' '/file/{print $2}' "$HOME/.config/nitrogen/bg-saved.cfg"|tail -1)"
|
||||
feh --bg-fill ${wp}
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [[ "$wall2themes" == "yes" ]];then
|
||||
notify-send.sh -t 5000 -i ~/.config/mabox/wpicon_wide.png --replace-file=/tmp/colorize_notid "Mabox Auto theming in progress..." "\n\nPlease wait... a few seconds...\n\n"
|
||||
fi
|
||||
ARGS="$*"
|
||||
#notify-send.sh "All ARGS" "\n\n$ARGS"
|
||||
|
||||
# TU translacja opcji z nitrogenowych na opcje feh
|
||||
# NITROGEN | FEH |
|
||||
# --set-centered | --bg-center |
|
||||
#
|
||||
# REPLACE ARGS
|
||||
|
||||
ARGS="${ARGS/ --save/}"
|
||||
ARGS="${ARGS/--set-centered/--bg-center}"
|
||||
ARGS="${ARGS/--set-scaled/--bg-scale}"
|
||||
ARGS="${ARGS/--set-tiled/--bg-tile}"
|
||||
ARGS="${ARGS/--set-zoom-fill/--bg-fill}"
|
||||
wallp="${ARGS##* }"
|
||||
|
||||
if [[ -f "${wallp}" ]];then
|
||||
feh ${ARGS}
|
||||
sd "file=.*$" "file=${wallp}" "$NITROGEN_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
readonly bg_path="$(awk -F '=' '/file/{print $2}' "$HOME/.config/nitrogen/bg-saved.cfg"|tail -1)"
|
||||
|
||||
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"
|
||||
|
||||
# for Mabox Colorizer
|
||||
WALLPALDIR="$HOME/.cache/colorizer/palettes"
|
||||
mkdir -p "$WALLPALDIR"
|
||||
|
||||
read WALLPATH<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | tail -1| cut -d'=' -f2) # full path to wallpaper file
|
||||
|
||||
# GENERATE ICON 52x32
|
||||
|
||||
magick ${WALLPATH} -resize 104x64^ -gravity center -extent 96x56 -bordercolor '#FFFFFF' -border 3 \
|
||||
-bordercolor '#222222' -border 1 ~/.config/mabox/wpicon_wide.png
|
||||
|
||||
# GENERATE ICON SQUARE
|
||||
magick ${WALLPATH} -resize 64x64^ -gravity center -extent 58x58 -bordercolor white -border 2 \
|
||||
-bordercolor grey60 -border 1 ~/.config/mabox/wpicon.png
|
||||
#killall -SIGUSR1 tint2
|
||||
tint2-send refresh-execp mb-t2wall
|
||||
|
||||
# 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
|
||||
ext="${WALLPATH##*.}"
|
||||
#notify-send.sh "Extension" "$ext"
|
||||
|
||||
if [ ! -f "$WALLPALDIR/${NAME}.clr" ]; then
|
||||
if [ "$ext" == "avif" ];then
|
||||
magick ${WALLPATH} -resize 25% /tmp/out.jpg
|
||||
magick /tmp/out.jpg -colors 12 -unique-colors txt:- |grep -v '^#'| awk '{print substr($3,1,7)}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$NAME.clr"
|
||||
else
|
||||
magick ${WALLPATH} -resize 25% -colors 12 -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
|
||||
THUMBDIR="$HOME/.cache/colorizer/thumbs"
|
||||
mkdir -p ${THUMBDIR}
|
||||
THUMB="${THUMBDIR}/${NAME}.png"
|
||||
if [[ ! -f "$THUMB" ]]; then
|
||||
magick ${WALLPATH} -resize 270x150^ -gravity center -extent 266x146 -bordercolor '#DDDDDD' -border 2 ${THUMB}
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$1" != "default" ]];then
|
||||
# AUTOTHEMING - generate themes after wallpaper is changed
|
||||
|
||||
if [[ "$wall2themes" == "yes" ]];then
|
||||
w2theme colorize
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user