To automatically change wallpaper on battery level, read the battery level from /sysclass and change the wallpaper setting using gsettings.
my $batt_file = "/sys/class/power_supply/axp20x-battery/capacity";
[...some code...]
chomp(my $current = `gsettings get org.gnome.desktop.background picture-uri`);
$current =~ s/^'file:\/\/\///;
$current =~ s/'$//;
[...some code...]
gsettings set org.gnome.desktop.background picture-uri "${IMG_URI}"
gsettings set org.gnome.desktop.background picture-uri-dark "${IMG_URI}"
Note: In my setup, i have a script battery_wallpaper that calls set_wallpaper.sh when there is need to change the wallpaper depending on the battery level read once every 15 minutes.