Dynamic wallpaper (DWALL) & mabox coloring components

DWALL (dynamic wallpaper) & Mabox colors [conky, menu, etc].

For the past year I have been using Archcraft i3 regularly with dwall.
I am investigating if it is possible to make a combination with dwall and that also changes the color, like e.g. conky, etc.

MOTIVATION:

Why do I want to use dwall, and not just random backgrounds with mbwallpaper.
With dwall, specific images are displayed at a specific time of day. Playing with light on the desktop, syncing with the time of the day.

QUEST :

When I run dwall script the background changes and the colors of the menu and conky change as it should. Seems ok. But.

However that is probably the default setting. Because when I run dwall again, the background changes as it should, but the colors of the menu and conky remain the same. And it stays that way. No matter which dwall theme I use.

Until I use e.g. nitrogen from terminal to change background. Or use menu/mbwallpaper script.
Then it works as it should. All components color along.

I have looked at mbwallpaper script.
What I understand is that there also nitrogen or feh is used to change the background.

In the original dwall script, feh is used.
Nitrogen in my modified version.

QUESTION:

Can I address nitrogen/feh from the dwall script so that the other components,
like conky, also color with it.

While I have the idea that both scripts, in terms of nitrogen command, do the same thing.


SCRIPTS :
Dwall on github

Orginal script dwall
#!/usr/bin/env bash

## Author  : Aditya Shakya (adi1090x)
## Mail    : adi1090x@gmail.com
## Github  : @adi1090x
## Twitter : @adi1090x

## Dynamic Wallpaper : Set wallpapers according to current time.
## Created to work better with job schedulers (cron)

## ANSI Colors (FG & BG)
RED="$(printf '\033[31m')"  GREEN="$(printf '\033[32m')"  ORANGE="$(printf '\033[33m')"  BLUE="$(printf '\033[34m')"
MAGENTA="$(printf '\033[35m')"  CYAN="$(printf '\033[36m')"  WHITE="$(printf '\033[37m')" BLACK="$(printf '\033[30m')"
REDBG="$(printf '\033[41m')"  GREENBG="$(printf '\033[42m')"  ORANGEBG="$(printf '\033[43m')"  BLUEBG="$(printf '\033[44m')"
MAGENTABG="$(printf '\033[45m')"  CYANBG="$(printf '\033[46m')"  WHITEBG="$(printf '\033[47m')" BLACKBG="$(printf '\033[40m')"

## Wallpaper directory
DIR="/usr/share/dynamic-wallpaper/images"
HOUR=`date +%k`

## Wordsplit in ZSH
set -o shwordsplit 2>/dev/null

## Reset terminal colors
reset_color() {
	tput sgr0   # reset attributes
	tput op     # reset color
    return
}

## Script Termination
exit_on_signal_SIGINT() {
    { printf "${RED}\n\n%s\n\n" "[!] Program Interrupted." 2>&1; reset_color; }
    exit 0
}

exit_on_signal_SIGTERM() {
    { printf "${RED}\n\n%s\n\n" "[!] Program Terminated." 2>&1; reset_color; }
    exit 0
}

trap exit_on_signal_SIGINT SIGINT
trap exit_on_signal_SIGTERM SIGTERM

## Prerequisite
Prerequisite() { 
    dependencies=(feh xrandr crontab)
    for dependency in "${dependencies[@]}"; do
        type -p "$dependency" &>/dev/null || {
            echo -e ${RED}"[!] ERROR: Could not find ${GREEN}'${dependency}'${RED}, is it installed?" >&2
            { reset_color; exit 1; }
        }
    done
}

## Usage
usage() {
	clear
    cat <<- EOF
		${RED}╺┳┓╻ ╻┏┓╻┏━┓┏┳┓╻┏━╸   ${GREEN}╻ ╻┏━┓╻  ╻  ┏━┓┏━┓┏━┓┏━╸┏━┓
		${RED} ┃┃┗┳┛┃┗┫┣━┫┃┃┃┃┃     ${GREEN}┃╻┃┣━┫┃  ┃  ┣━┛┣━┫┣━┛┣╸ ┣┳┛
		${RED}╺┻┛ ╹ ╹ ╹╹ ╹╹ ╹╹┗━╸   ${GREEN}┗┻┛╹ ╹┗━╸┗━╸╹  ╹ ╹╹  ┗━╸╹┗╸${WHITE}
		
		Dwall V2.0   : Set wallpapers according to current time.
		Developed By : Aditya Shakya (@adi1090x)
			
		Usage : `basename $0` [-h] [-p] [-s style]

		Options:
		   -h	Show this help message
		   -p	Use pywal to set wallpaper
		   -s	Name of the style to apply
		   
	EOF

	styles=(`ls $DIR`)
	printf ${GREEN}"Available styles:  "
	printf -- ${ORANGE}'%s  ' "${styles[@]}"
	printf -- '\n\n'${WHITE}

    cat <<- EOF
		Examples: 
		`basename $0` -s beach        Set wallpaper from 'beach' style
		`basename $0` -p -s sahara    Set wallpaper from 'sahara' style using pywal
		
	EOF
}

## Set wallpaper in kde
set_kde() {
	qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "
		var allDesktops = desktops();
		print (allDesktops);
		for (i=0;i<allDesktops.length;i++) {
			d = allDesktops[i];
			d.wallpaperPlugin = 'org.kde.image';
			d.currentConfigGroup = Array('Wallpaper',
										'org.kde.image',
										'General');
			d.writeConfig('Image', 'file://"$1"')
		}"
}

## Set wallpaper in cinnamon
set_cinnamon() {
	 gsettings set org.cinnamon.desktop.background picture-uri "file:///$1"
}

## For XFCE only
if [[ "$OSTYPE" == "linux"* ]]; then
	SCREEN="$(xrandr --listactivemonitors | awk -F ' ' 'END {print $1}' | tr -d \:)"
	MONITOR="$(xrandr --listactivemonitors | awk -F ' ' 'END {print $2}' | tr -d \*+)"
fi

## Choose wallpaper setter
case "$OSTYPE" in
	linux*)
			if [ -n "$SWAYSOCK" ]; then
				SETTER="eval ogurictl output '*' --image"
			elif [[ "$DESKTOP_SESSION" =~ ^(MATE|Mate|mate)$ ]]; then
				SETTER="gsettings set org.mate.background picture-filename"
			elif [[ "$DESKTOP_SESSION" =~ ^(Xfce Session|xfce session|XFCE|xfce|Xubuntu|xubuntu)$ ]]; then
				SETTER="xfconf-query --channel xfce4-desktop --property /backdrop/screen$SCREEN/monitor$MONITOR/workspace0/last-image --set"
			elif [[ "$DESKTOP_SESSION" =~ ^(LXDE|Lxde|lxde)$ ]]; then
				SETTER="pcmanfm --set-wallpaper"
			elif [[ "$DESKTOP_SESSION" =~ ^(cinnamon|Cinnamon)$ ]]; then
				SETTER=set_cinnamon
			elif [[ "$DESKTOP_SESSION" =~ ^(/usr/share/xsessions/plasma|NEON|Neon|neon|PLASMA|Plasma|plasma|KDE|Kde|kde)$ ]]; then
				SETTER=set_kde
			elif [[ "$DESKTOP_SESSION" =~ ^(PANTHEON|Pantheon|pantheon|GNOME|Gnome|gnome|Gnome-xorg|gnome-xorg|UBUNTU|Ubuntu|ubuntu|DEEPIN|Deepin|deepin|POP|Pop|pop)$ ]]; then
				SETTER="gsettings set org.gnome.desktop.background picture-uri"
			else 
				SETTER="feh --bg-fill"
			fi
			;;
esac

## Get Image
get_img() {
	image="$DIR/$STYLE/$1"

	# get image format
	if [[ -f "${image}.png" ]]; then
		FORMAT="png"
	elif [[ -f "${image}.jpg" ]]; then
		FORMAT="jpg"
	else
		echo -e ${RED}"[!] Invalid image file, Exiting..."
		{ reset_color; exit 1; }
	fi
}

## Set wallpaper with pywal
pywal_set() {
	get_img "$1"
	if [[ -x `command -v wal` ]]; then
		wal -i "$image.$FORMAT"
	else
		echo -e ${RED}"[!] pywal is not installed on your system, exiting..."
		{ reset_color; exit 1; }
	fi
}

## Wallpaper Setter
set_wallpaper() {
	cfile="$HOME/.cache/dwall_current"
	get_img "$1"

	# set wallpaper with setter
	if [[ -n "$FORMAT" ]]; then
		$SETTER "$image.$FORMAT"
	fi

	# make/update dwall cache file
	if [[ ! -f "$cfile" ]]; then
		touch "$cfile"
		echo "$image.$FORMAT" > "$cfile"
	else
		echo "$image.$FORMAT" > "$cfile"	
	fi
}

## Check valid style
check_style() {
	styles=(`ls $DIR`)
	for i in "${styles[@]}"; do
		if [[ "$i" == "$1" ]]; then
			echo -e ${BLUE}"[*] Using style : ${MAGENTA}$1"
			VALID='YES'
			{ reset_color; break; }
		else
			continue
		fi
	done

	if [[ -z "$VALID" ]]; then
		echo -e ${RED}"[!] Invalid style name : ${GREEN}$1${RED}, exiting..."
		{ reset_color; exit 1; }
	fi
}

## Main
main() {
	# get current hour
	num=$(($HOUR/1))
	# set wallpaper accordingly
	if [[ -n "$PYWAL" ]]; then
		{ pywal_set "$num"; reset_color; exit 0; }
	else
		{ set_wallpaper "$num"; reset_color; exit 0; }
	fi
}

## Get Options
while getopts ":s:hp" opt; do
	case ${opt} in
		p)
			PYWAL=true
			;;
		s)
			STYLE=$OPTARG
			;;
		h)
			{ usage; reset_color; exit 0; }
			;;
		\?)
			echo -e ${RED}"[!] Unknown option, run ${GREEN}`basename $0` -h"
			{ reset_color; exit 1; }
			;;
		:)
			echo -e ${RED}"[!] Invalid:$G -$OPTARG$R requires an argument."
			{ reset_color; exit 1; }
			;;
	esac
done

## Run
Prerequisite
if [[ "$STYLE" ]]; then
	check_style "$STYLE"
    main
else
	{ usage; reset_color; exit 1; }
fi

My adaptation for mabox :::

dwall-mabox.sh
#!/usr/bin/env bash

## Author  : Aditya Shakya (adi1090x)
## Mail    : adi1090x@gmail.com
## Github  : @adi1090x
## Twitter : @adi1090x

## Dynamic Wallpaper : Set wallpapers according to current time.
## Created to work better with job schedulers (cron)

## ANSI Colors (FG & BG)
RED="$(printf '\033[31m')"  GREEN="$(printf '\033[32m')"  ORANGE="$(printf '\033[33m')"  BLUE="$(printf '\033[34m')"
MAGENTA="$(printf '\033[35m')"  CYAN="$(printf '\033[36m')"  WHITE="$(printf '\033[37m')" BLACK="$(printf '\033[30m')"
REDBG="$(printf '\033[41m')"  GREENBG="$(printf '\033[42m')"  ORANGEBG="$(printf '\033[43m')"  BLUEBG="$(printf '\033[44m')"
MAGENTABG="$(printf '\033[45m')"  CYANBG="$(printf '\033[46m')"  WHITEBG="$(printf '\033[47m')" BLACKBG="$(printf '\033[40m')"

## Wallpaper directory
DIR="`pwd`/images"
HOUR=`date +%k`

## Wordsplit in ZSH
set -o shwordsplit 2>/dev/null

## Reset terminal colors
reset_color() {
	tput sgr0   # reset attributes
	tput op     # reset color
    return
}

## Script Termination
exit_on_signal_SIGINT() {
    { printf "${RED}\n\n%s\n\n" "[!] Program Interrupted." 2>&1; reset_color; }
    exit 0
}

exit_on_signal_SIGTERM() {
    { printf "${RED}\n\n%s\n\n" "[!] Program Terminated." 2>&1; reset_color; }
    exit 0
}

trap exit_on_signal_SIGINT SIGINT
trap exit_on_signal_SIGTERM SIGTERM

## Prerequisite
Prerequisite() { 
    dependencies=(feh nitrogen xrandr crontab)
    for dependency in "${dependencies[@]}"; do
        type -p "$dependency" &>/dev/null || {
            echo -e ${RED}"[!] ERROR: Could not find ${GREEN}'${dependency}'${RED}, is it installed?" >&2
            { reset_color; exit 1; }
        }
    done
}

## Choose wallpaper setter
case "$OSTYPE" in
	linux*)
			if [[ "$DESKTOP_SESSION" =~ ^(OPENBOX|Openbox|openbox)$ ]]; then
				SETTER="nitrogen --set-auto --save"
			else 
			SETTER="feh --bg-fill"
			fi
			;;
esac

## Get Image
get_img() {
	image="$DIR/$STYLE/$1"

	# get image format
	if [[ -f "${image}.png" ]]; then
		FORMAT="png"
	elif [[ -f "${image}.jpg" ]]; then
		FORMAT="jpg"
	else
		echo -e ${RED}"[!] Invalid image file, Exiting..."
		{ reset_color; exit 1; }
	fi
}

## Wallpaper Setter
set_wallpaper() {
	cfile="$HOME/.cache/dwall_current"
	get_img "$1"

	# set wallpaper with setter
	if [[ -n "$FORMAT" ]]; then
		$SETTER "$image.$FORMAT"
	fi

	# make/update dwall cache file
	if [[ ! -f "$cfile" ]]; then
		touch "$cfile"
		echo "$image.$FORMAT" > "$cfile"
	else**While I have the idea that both scripts, in terms of nitrogen command, do the same thing.**
		echo "$image.$FORMAT" > "$cfile"	
	fi
}

## Check valid style
check_style() {
	styles=(`ls $DIR`)
	for i in "${styles[@]}"; do
		if [[ "$i" == "$1" ]]; then
			echo -e ${BLUE}"[*] Using style : ${MAGENTA}$1"
			VALID='YES'
			{ reset_color; break; }
		else
			continue
		fi
	done

	if [[ -z "$VALID" ]]; then
		echo -e ${RED}"[!] Invalid style name : ${GREEN}$1${RED}, exiting..."
		{ reset_color; exit 1; }
	fi
}

## Main**While I have the idea that both scripts, in terms of nitrogen command, do the same thing.**
main() {
	# get current hour
	num=$(($HOUR/1))
	# set wallpaper accordingly
	if [[ -n "$PYWAL" ]]; then
		{ pywal_set "$num"; reset_color; exit 0; }
	else
		{ set_wallpaper "$num"; reset_color; exit 0; }
	fi
}

## Get Options
while getopts ":s:h" opt; do
	case ${opt} in
		s)
			STYLE=$OPTARG
			;;
		h)
			{ usage; reset_color; exit 0; }
			;;
		\?)
			echo -e ${RED}"[!] Unknown option, run ${GREEN}`basename $0` -h"
			{ reset_color; exit 1; }
			;;
		:)
			echo -e ${RED}"[!] Invalid:$G -$OPTARG$R requires an argument."
			{ reset_color; exit 1; }
			;;
	esac
done

## Run
Prerequisite
if [[ "$STYLE" ]]; then
	check_style "$STYLE"
    main
else
	{ usage; reset_color; exit 1; }
fi
  • added dependency nitrogen
  • SETTER = nitrogen
  • SETTER = feh

:bird:
Script tinker.

I don’t have time atm to look closer at scripts but…
Currently the only way to make Colorizer do its job automatically is using nitrogen as setter.
Try to change in your version of script:

SETTER="feh --bg-fill"

to

SETTER="nitrogen --set-auto --save"

or something like that :wink:
I hope that helps.

I can see there is another problem…

Colorizer does quite a few things under the hood:

  • generating a color palette based on the wallpaper
  • generating thumbnail for display in various menus

and these things are cached to avoid unnecessary work when you set the wallpaper a second time.
The palette and thumbnail are ready right away.
This works very nice… but the data is cached based on the wallpaper filename - which is usually not a problem - because usually each wallpaper has a different filename.

This script and collection are different. Sets have 24 files named 1 - 24. So it won’t work as you expect.

For it to work well, I have to make changes to Colorizer - unfortunately, also in a few other scripts… I won’t be able to do it quickly with proper testing (like ~1h or so).
So it has to wait as the next thing to do until I find the right amount of time and energy for it.

Thank you @muzqs for the time and work you did on this.
It will definitely help to improve Mabox :slight_smile:

EDIT :: happy to early, it’s not working :face_with_diagonal_mouth:

I found the solution;

I changed the path inside the dwall script directly to $HOME/.local/bin/nitrogen.
After i discoverd the file.

Dwall seems to work this way now.

Thanks for looking into it.

:bird:

I’ve just played a little bit with those wallpapers, and I like them a lot.
Maybe later today I will have time to improve Colorizer to make it work as it should with those wallpapers :wink:

todo.sh add improve +colorizer-1.0 cache handling
1 Like

New Colorizer (0.9.29) should handle those wallpapers correctly (be able to autogenerate themes if this option is enabled).

I also share short script I use to change wallpaper only if needed:

#!/bin/bash
# usage mb-dwall [stylename]
DYNWALL_DIR="$HOME/Git/dynamic-wallpaper/images"
STYLE=${1:-lake}
 
HOUR=$(date +%k)
H=${HOUR// /}
read file<<< $(grep file "$HOME/.config/nitrogen/bg-saved.cfg" | cut -d'=' -f2)

# find jpg or png
if [[ -f "${DYNWALL_DIR}/${STYLE}/${H}.jpg" ]]; then
NEW_WP_FILE="${DYNWALL_DIR}/${STYLE}/${H}.jpg"
elif [[ -f "${DYNWALL_DIR}/${STYLE}/${H}.png" ]]; then
NEW_WP_FILE="${DYNWALL_DIR}/${STYLE}/${H}.png"
fi
# if file is symlink find target
[[ -L "$NEW_WP_FILE" ]] && NEW_WP_FILE=$(readlink -f ${NEW_WP_FILE})

# set wallpaper if it is not already set
[[ "$NEW_WP_FILE" != "$file" ]] && nitrogen --set-scaled  --save ${NEW_WP_FILE} 

Edit DYNWALL_DIR and STYLE variables on top for your needs.

and cron job:

napcok@mabox ~ $ crontab -l
DISPLAY=:0
0 * * * * "$HOME"/bin/mb-dwall 

Update!
Script above updated. Previous one did not work during night since 0 h to 9 h :joy:

Hi @napcok,

Thanks so much, for looking into this. :face_with_peeking_eye:
From 00:00 to 09:00, me :sleeping: . . . . . . . . . . . . .

I will test it and let the Style read from a txt file, generated from a style manager.


This is what i used for the time being in my crontab. From your help page.

. . . . etc /run/user/1000 /usr/bin/dwall-set.sh ; mb-setvar jgmenu_theme=$(basename -s .colorrc $(ls ~/.config/mabox/jgobthemes/*.colorrc | shuf -n 1))

Manager used with i3-wm, rofi.

Thanks for the work. :bird:

1 Like

Nice custom submenu :slight_smile:
I like this wallpapers and idea a lot. And I have plans to make all these easy to use in Mabox - and probably integrate somehow with “wallpaper menu” super + alt + w (downloading those wallpaper sets, setup and so on).
For now, it’s going to the to-do list until I find the time (unfortunately, this is a big problem right now)

2 Likes

Some more Dynamic Wallpapers.

3 Likes

Sharing themes:

Because Linux_Dynamic_Wallpapers is made with Gnome in mind,
it was necessary to modify the styles to use with mb-dwall.sh.
Now all styles have 0-23 images.

Saves some work if you want to use them with mb-dwall.sh or archcraft dwall.

The script are more for personal use.

:bird:

3 Likes

Wow, you’ve worked hard on this :+1:
Thanks for sharing.

1 Like

If it’s ok, I’ll use this post to share my developments with my Weekly Dynamic wallpaper and animations.

The first animation is ready for testing. Checking to see if the images make some sense.

(ps examen the scripts. The project is mainly a learning track.) tips alway’s welcome …

Pix of the day’s are from the same hour. [17:00-1800]

monday

tuesday

wednesday

thursday

friday

saturday

sunday

:bird:

3 Likes

I’m pretty happy with the day’s sequences of this animation.
The only thing is that the images are copyrighted. At least I assume so.

Now I am creating an account at stabilityAI to generate images. First learn to make good synopses for the AI.
When I have some presentable ones generated I will be happy to share them.

End goal is to make several dwall week themes.
Work in progress.

:bird:

2 Likes

PORTABLE
WEEKLY DYNAMIC WALLPAPER CHANGER.

[NIGHTFISH]

Created a portable weekly dwall version of the animation NightFish
[love,Death&robots].

:bird:

2 Likes

By the way, this is one of my favorite episodes in first season! Superb graphics and animations!

Thanks for your script tinkering. I also learn a lot.

1 Like