From 0fa2536dac830e24bbbdd205f5fd7ca81e1d8da2 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Wed, 18 Jan 2023 23:58:47 +0100 Subject: [PATCH] cache_dir for thumbs and palletes changed --- bin/colorizer | 30 +++++++++++++++++++----------- bin/colorizer-conky | 30 ++++++++++++++++++++++++++---- bin/colorizer-menus | 33 +++++++++++++++++++++++++++++---- bin/colorizer-ob | 39 ++++++++++++++++++++++++++++++--------- bin/colorizer-pyradio | 29 +++++++++++++++++++++++++---- bin/mbclr | 42 +++++++++++++++++++++++++++++++++++++----- bin/w2theme | 35 ++++++++++++++++++++++++++++++++++- 7 files changed, 200 insertions(+), 38 deletions(-) diff --git a/bin/colorizer b/bin/colorizer index 860b539..dc9f9a0 100755 --- a/bin/colorizer +++ b/bin/colorizer @@ -1,7 +1,7 @@ #!/bin/bash # -# colorizer - set of tools for Mabox theming -# Copyright (C) 2022 Daniel Napora +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,8 +50,6 @@ gradient_obtheme=yes # Gradients: change menu/panels background? gradient_menu=no EOF -# Copy new nitrogen wrapper -cp -a /usr/share/mabox/common/wrappers/nitrogen ~/.local/bin/ fi source "$CNF_FILE" @@ -258,14 +256,24 @@ Color Menu,colormenu EOF fi -WALLPALDIR="$HOME/.config/colormenu/palettes/wallp" +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" + +NAME=${WALLPATH////_} +if [[ "${NAME}" =~ ^_home_.* ]]; then +n=${#HOME} +((n++)) +NAME=${NAME:${n}} fi -mapfile -t w < "$WALLPALDIR/$WALLPAPER.clr" + + +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 +mapfile -t w < "$WALLPALDIR/$NAME.clr" + + if [[ "${#w[@]}" -lt 8 ]]; then w+=("#2e3440" "#4c566a" "#5e81ac" "#bf616b" "#b48ead" "#a3be8c" "#ebcb8b" "#d8dee9" "#eceff4") fi @@ -684,9 +692,9 @@ if [[ "$1" == "-s" ]]; then JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) MENU_PADDING_TOP=$((jgtools_padding + 158)) - 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} diff --git a/bin/colorizer-conky b/bin/colorizer-conky index 0a57ae7..4ba0570 100755 --- a/bin/colorizer-conky +++ b/bin/colorizer-conky @@ -1,4 +1,21 @@ #!/bin/bash +# +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + me="colorizer-conky -s" CONKYDIR="$HOME/.config/conky" @@ -368,13 +385,18 @@ if [[ "$1" == "-s" ]]; then #WALLPAPER read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) - WALLPAPER=${WALLPATH##*/} - THUMBDIR="$HOME/.config/mabox/wallthumbs" + THUMBDIR="$HOME/.cache/colorizer/thumbs" mkdir -p ${THUMBDIR} - THUMB="${THUMBDIR}/${WALLPAPER}.png" + NAME=${WALLPATH////_} + if [[ "${NAME}" =~ ^_home_.* ]]; then + n=${#HOME} + ((n++)) + NAME=${NAME:${n}} + fi + THUMB="${THUMBDIR}/${NAME}.png" if [[ ! -f "$THUMB" ]] then - convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} + convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} fi mkconfigfile diff --git a/bin/colorizer-menus b/bin/colorizer-menus index 759dd47..b03088c 100755 --- a/bin/colorizer-menus +++ b/bin/colorizer-menus @@ -1,4 +1,24 @@ #!/bin/bash +# +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + + + me="colorizer-menus -s" . $HOME/.config/mabox/mabox.conf case "$jgmenu_theme" in @@ -255,13 +275,18 @@ JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) MENU_PADDING_TOP=$((jgtools_padding + 158)) #WALLPAPER read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) - WALLPAPER=${WALLPATH##*/} - THUMBDIR="$HOME/.config/mabox/wallthumbs" + THUMBDIR="$HOME/.cache/colorizer/thumbs" mkdir -p ${THUMBDIR} - THUMB="${THUMBDIR}/${WALLPAPER}.png" + NAME=${WALLPATH////_} + if [[ "${NAME}" =~ ^_home_.* ]]; then + n=${#HOME} + ((n++)) + NAME=${NAME:${n}} + fi + THUMB="${THUMBDIR}/${NAME}.png" if [[ ! -f "$THUMB" ]] then - convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} + convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} fi mkconfigfile diff --git a/bin/colorizer-ob b/bin/colorizer-ob index 922417f..08a9c9a 100755 --- a/bin/colorizer-ob +++ b/bin/colorizer-ob @@ -1,4 +1,20 @@ #!/bin/bash +# +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . MBCOLORSDIR="$HOME"/.themes/MBcolors/openbox-3/ GRADIENT_FILE="$HOME"/.config/colorizer/gradients_all.inc @@ -388,16 +404,21 @@ JGWIDTH=$((jgtools_padding + 278 + jgtools_padding)) MENU_PADDING_TOP=$((jgtools_padding + 158)) # WALLPAPER IMAGE - read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) - WALLPAPER=${WALLPATH##*/} - THUMBDIR="$HOME/.config/mabox/wallthumbs" - mkdir -p ${THUMBDIR} - THUMB="${THUMBDIR}/${WALLPAPER}.png" - if [[ ! -f "$THUMB" ]] - then +read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) +THUMBDIR="$HOME/.cache/colorizer/thumbs" +mkdir -p ${THUMBDIR} +NAME=${WALLPATH////_} +if [[ "${NAME}" =~ ^_home_.* ]]; then + n=${#HOME} + ((n++)) + NAME=${NAME:${n}} +fi +THUMB="${THUMBDIR}/${NAME}.png" +if [[ ! -f "$THUMB" ]] + then convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} - fi - +fi + mkconfigfile cat < ${MENU_ITEMS} diff --git a/bin/colorizer-pyradio b/bin/colorizer-pyradio index bfb0522..3157637 100755 --- a/bin/colorizer-pyradio +++ b/bin/colorizer-pyradio @@ -1,4 +1,20 @@ #!/bin/bash +# +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . # TODO Start Pyradio if not started # TODO check if theme is writeable (users themes) @@ -156,13 +172,18 @@ if [[ "$1" == "-s" ]]; then #WALLPAPER read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) - WALLPAPER=${WALLPATH##*/} - THUMBDIR="$HOME/.config/mabox/wallthumbs" + THUMBDIR="$HOME/.cache/colorizer/thumbs" mkdir -p ${THUMBDIR} - THUMB="${THUMBDIR}/${WALLPAPER}.png" + NAME=${WALLPATH////_} + if [[ "${NAME}" =~ ^_home_.* ]]; then + n=${#HOME} + ((n++)) + NAME=${NAME:${n}} + fi + THUMB="${THUMBDIR}/${NAME}.png" if [[ ! -f "$THUMB" ]] then - convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} + convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} fi mkconfigfile diff --git a/bin/mbclr b/bin/mbclr index aa0afc3..ce9d165 100755 --- a/bin/mbclr +++ b/bin/mbclr @@ -1,5 +1,21 @@ #!/bin/bash # +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + # mbclr current polecenie funkcja argument backprg [config_file] # mbclr #notify-send.sh "mbclr" "${1}\n${2}\n${3}\n${4}\n${5}\n${6}" @@ -33,14 +49,22 @@ esac main () { #read WALLPAPER<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2) -WALLPALDIR="$HOME/.config/colormenu/palettes/wallp" +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" + +NAME=${WALLPATH////_} +if [[ "${NAME}" =~ ^_home_.* ]]; then +n=${#HOME} +((n++)) +NAME=${NAME:${n}} fi -mapfile -t wallcolors < "$WALLPALDIR/$WALLPAPER.clr" + + +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 +mapfile -t wallcolors < "$WALLPALDIR/$NAME.clr" if [[ "${#wallcolors[@]}" -lt 8 ]]; then wallcolors+=("#2e3440" "#4c566a" "#5e81ac" "#bf616b" "#b48ead" "#a3be8c" "#ebcb8b" "#d8dee9" "#eceff4") fi @@ -154,6 +178,14 @@ out2+=("$clr $clr ,$2 $3 '${clr}' ${6};${5}") +done +# NOWE + printf '%s\n' "${out[@]}" printf '%s\n' "${out2[@]}" } diff --git a/bin/w2theme b/bin/w2theme index 0de9fa0..96c0232 100755 --- a/bin/w2theme +++ b/bin/w2theme @@ -1,6 +1,22 @@ #!/bin/bash +# +# colorizer - set of tools for Mabox (auto)theming +# Copyright (C) 2022-2023 Daniel Napora +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . -# w2theme - generate themes from wallpaper colors +# w2theme - generate themes from wallpaper colors WALLPALDIR="$HOME/.config/colormenu/palettes/wallp" mkdir -p "$WALLPALDIR" @@ -330,6 +346,22 @@ reverse () { esac } +genthumb () { + #$1 - filename with full path + NAME=${1////_} + if [[ "${NAME}" =~ ^_home_.* ]]; then + n=${#HOME} + ((n++)) + NAME=${NAME:${n}} + fi + # GENERATE THUMBNAIL + THUMBDIR="$HOME/.cache/colorizer/thumbs" + mkdir -p ${THUMBDIR} + THUMB="${THUMBDIR}/${NAME}.png" + if [[ ! -f "$THUMB" ]]; then + convert ${1} -resize 270x150^ -gravity center -extent 270x150 ${THUMB} + fi +} pin () { #get wallpaper path and filename without ext @@ -353,6 +385,7 @@ case "$1" in gradient) gradient "$2" "$3";; colorize) colorize;; reverse) reverse;; + genthumb)genthumb "$2";; pin) pin;; *) ;; esac