From a2b4bc9901aa37bac36b7152c9f953da564b2507 Mon Sep 17 00:00:00 2001 From: Daniel Napora Date: Mon, 25 Apr 2022 02:58:43 +0200 Subject: [PATCH] rand wallpaper --- bin/mbxcolors | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/mbxcolors b/bin/mbxcolors index 14a2b48..1eb9e76 100755 --- a/bin/mbxcolors +++ b/bin/mbxcolors @@ -1,11 +1,9 @@ #!/usr/bin/env bash # Copyright (C) Daniel Napora 2021-22 -# Dependencies: jgmenu, xdotool, xcolor, gcolor3, xdg-utils, xclip, notify-send -# TODO Imagick colors - separate menu big around 700 named colors +# Dependencies: jgmenu, xdotool, xcolor, gcolor3, gpick, pastel, xdg-utils, xclip, notify-send # TODO export to .gpl (GIMP,Inkscape) -# TODO PL translation -VERSION="0.9.0" +VERSION="0.9.1" TEMP_DIR=/tmp/colormenu ME=${0##*/} @@ -30,12 +28,16 @@ htmlcolors=yes picker=gpick #Show built in palettes? (slow) builtin_palettes=yes +# Random wallpaper dir +walldir=/usr/share/backgrounds #Position on screen: topleft, top, topright, left, center, right, bottomleft, bottom, bottomright position=left EOF fi source <(grep = $CNF_FILE) +RANDWALLDIR=${walldir:-/usr/share/backgrounds} + if [ ! -f $RECENT ]; then cat < ${RECENT} #FFFFFF White @@ -210,6 +212,7 @@ case $LANG in CLEAR_RECPICKED="Usuń ostatnio dodane" REMOVEONE="Usuń tylko jeden kolor..." WALLCOLORS="Kolory z tapety" + RANDWALL="Ustaw losową tapetę" IMAGICKCOLORS="Kolory Image Magick" HTMLCOLORS="Kolory HTML" PALETTE="Paleta:" @@ -235,6 +238,7 @@ case $LANG in CLEAR_RECPICKED="Clear recently picked" REMOVEONE="Just remove one color..." WALLCOLORS="Wallpaper colors" + RANDWALL="Set random wallpaper" IMAGICKCOLORS="Image Magick Colors" HTMLCOLORS="HTML colors" PALETTE="Palette:" @@ -262,7 +266,6 @@ mkconfigfile trap "rm -f ${CONFIG_FILE} ${MENU_ITEMS}" EXIT out+=("^sep($COLORMENU [$action $format])") -#out+=("^sep( mbx colors [$action $format])") out+=("$PICK_FROM_SCREEN,$ME pickcolor") if hash gcolor3 2>/dev/null; then out+=("^sep()") @@ -317,13 +320,15 @@ case "$expose" in 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 $3}' > "$WALLPALDIR/$WALLPAPER.clr" + convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print $3}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr" fi #mapfile -t wallcolors < "$WALLPALDIR/$WALLPAPER.clr" out+=("^sep($WALLCOLORS)") while read -r color name;do out+=("$color ,$ME getcolorcode '$color'") done < "$WALLPALDIR/$WALLPAPER.clr" + out+=("^sep()") + out+=("$RANDWALL,nitrogen --random ${RANDWALLDIR} --set-scaled --save;$ME") ;; *) if [ -f "$DATA_DIR/palettes/$expose" ];then @@ -354,6 +359,7 @@ out+=("$BUILTIN_PAL,^checkout(builtpalettes)") palettes fi # WALLPAPER COLORS +if [ "$expose" != "wallpaper" ];then out+=("$WALLCOLORS,^checkout(wallcolors)") read WALLPAPER<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg | cut -d'=' -f2") WALLPALDIR="$HOME/.config/mbxcolors/palettes/wallp" @@ -361,7 +367,7 @@ 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 $3}' > "$WALLPALDIR/$WALLPAPER.clr" + convert ${WALLPATH} -resize 25% -colors 16 -unique-colors txt:- |grep -v '^#'| awk '{print $3}' |pastel sort-by brightness |pastel format hex > "$WALLPALDIR/$WALLPAPER.clr" fi #mapfile -t wallcolors < "$WALLPALDIR/$WALLPAPER.clr" out2+=("^tag(wallcolors)") @@ -371,6 +377,10 @@ out2+=("^sep()") while read -r color name;do out2+=("$color ,$ME getcolorcode '$color'") done < "$WALLPALDIR/$WALLPAPER.clr" +out2+=("^sep()") +out2+=("$RANDWALL,nitrogen --random ${RANDWALLDIR} --set-scaled --save;$ME") +fi + out1+=("$IMAGICKCOLORS,mbxcolors imagick") out1+=("^sep($SETTINGS)") out1+=("$PREFERENCES,^pipe($ME preferences)")