separete self made palettes

master
Daniel Napora 2021-10-27 17:38:03 +02:00
parent c332f0f21e
commit 45b5e89c74
1 changed files with 16 additions and 8 deletions

View File

@ -2,7 +2,7 @@
# Copyright (C) Daniel Napora 2021 <napcok@gmail.com> # Copyright (C) Daniel Napora 2021 <napcok@gmail.com>
# Dependencies: jgmenu, xdotool, colorpicker, xdg-utils, xclip # Dependencies: jgmenu, xdotool, colorpicker, xdg-utils, xclip
# TODO Built-in palettes read-only pre-generated like HTML colors amd not copied to ~/.../palettes # TODO Built-in palettes read-only pre-generated like HTML colors amd not copied to ~/.../palettes
# TODO self made palettes in ~/.../palettes # DONE self made palettes in ~/.../palettes
# TODO notifications when copying to clipboard (imagick needed to create icon) # TODO notifications when copying to clipboard (imagick needed to create icon)
# TODO check for other color-tools like gpick,gcolor2 and add launchers to menu # TODO check for other color-tools like gpick,gcolor2 and add launchers to menu
# TODO export to .gpl (GIMP,Inkscape) # TODO export to .gpl (GIMP,Inkscape)
@ -96,20 +96,22 @@ getcolorcode() {
} }
recent2palette () { recent2palette () {
DATE=$(date +"%Y%m%d-%H%M%S") DATE=$(date +"%Y%m%d-%H%M%S")
grep ^# $RECENT |tac > "$CNF_DIR/palettes/New_$DATE.clr" mkdir -p "$CNF_DIR/palettes/my"
grep ^# $RECENT |tac > "$CNF_DIR/palettes/my/My_palette_$DATE.clr"
} }
newpalette() { newpalette() {
DATE=$(date +"%Y%m%d-%H%M%S") DATE=$(date +"%Y%m%d-%H%M%S")
touch "$CNF_DIR/palettes/New_$DATE.clr" mkdir -p "$CNF_DIR/palettes/my"
touch "$CNF_DIR/palettes/my/My_palette_$DATE.clr"
} }
palettes() { palettes() {
out1+=("^sep(Color palettes)") [ -n "$1" ] && pdir="$CNF_DIR/palettes/my/" || pdir="$CNF_DIR/palettes/"
for file in "$CNF_DIR"/palettes/*.clr;do for file in "$pdir"*.clr;do
filename=${file##*/} filename=${file##*/}
palette=${filename%.*} palette=${filename%.*}
pal=${palette//_/ } pal=${palette//_/ }
tagname=${palette// /_} tagname=${palette// /_}
out1+=("${pal^},^checkout($tagname)") out+=("${pal^},^checkout($tagname)")
out2+=("^tag($tagname)") out2+=("^tag($tagname)")
out2+=("^sep(${pal^})") out2+=("^sep(${pal^})")
while read -r color name; while read -r color name;
@ -128,10 +130,11 @@ palettes() {
out3+=("^sep(Are you sure?)") out3+=("^sep(Are you sure?)")
out3+=("Yes,rm '$file';$ME") out3+=("Yes,rm '$file';$ME")
done done
if [[ $# = 0 ]] ; then
out1+=("^sep()") out1+=("^sep()")
out1+=("<b>Add new</b> palette...,$ME newpalette;$ME") out1+=("<b>Add new</b> palette...,$ME newpalette;$ME")
out1+=("Open palette directory,xdg-open $CNF_DIR/palettes/") out1+=("Open palette directory,xdg-open $CNF_DIR/palettes/")
fi
} }
htmlcolors() { htmlcolors() {
@ -326,8 +329,13 @@ case "$expose" in
;; ;;
esac esac
#if [[ "$CNF_DIR"/palettes/my/*.clr ]]; then
if [ "$(find "$CNF_DIR"/palettes/my/*.clr -maxdepth 1 -type f -iname \*.clr)" ]; then
out+=("^sep(My palletes)")
palettes my
fi
if [[ $builtin_palettes == "yes" ]];then if [[ $builtin_palettes == "yes" ]];then
out+=("^sep(Built-in palettes)")
palettes palettes
fi fi