
auto change random background in gnome
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
This script will auto change background desktop by pictures from one folder after a period time that you set up.
Anyway, you can add many folders contains pictures you want but their path should not has any space character.
Maybe that's too late but I want to share it.
Hope it usefully to you!
10 years ago
# Verion 0.1 :
# Verion 0.2 :
# Add function "custom options" from command
10 years ago
# Verion 0.1 :
# Verion 0.2 :
# Add function "custom options" from command
inameiname
10 years ago
Anyway, not to condone this script, as it does work just fine, here are a couple I prefer. And they handle spaces in paths and such.
###### Random wallpaper (add whatever wallpaper directory(s) you wish after 'BACKGROUND_DIRS')
#!/usr/bin/env python
BACKGROUND_DIRS = ['/usr/share/backgrounds', '~/Pictures/Backgrounds']
EXTENSIONS = ['jpeg', 'jpg', 'bmp', 'png', 'svg']
import os, glob, random, itertools, gconf
files = list(itertools.chain(*[[os.path.join(dirpath, name)
for name in filenames]
for dirpath, dirnames, filenames in
itertools.chain(*[os.walk(os.path.expanduser(d))
for d in BACKGROUND_DIRS])]))
gconf.client_get_default().set_string(
'/desktop/gnome/background/picture_filename',
random.choice(files))
###### Automatic wallpaper switcher for Gnome
#!/bin/bash
if [ $# -ne 2 ];then
echo -n "Usage: $0 directory_name timeout_in_seconds
Leave the directory name blank for Current Directory
For you lazy pal, I assume timeout as 5 sec and Directory as current
Do you want to accept this settings? (Y/n): ";
read response
if [[ "$response" =~ ^[^yY] ]];then
exit 0
fi
fi
function set_wallpaper() {
gconftool-2 -s /desktop/gnome/background/picture_options "centered" -t string;
gconftool-2 -s /desktop/gnome/background/picture_filename "$1" -t string;
}
TIMEOUT=${2-5};
WALL_DIR=${1-`pwd`};
echo "Timeout value is: $TIMEOUT";
echo "Directory is: $WALL_DIR";
echo
if [ ! -d "$WALL_DIR" ];then
echo "The Directory Specified is invalid..";
exit 1;
fi
filelst="$(find "$WALL_DIR" -type f -name '*.jpg' -o -name '*.png')";
if [ -z "$filelst" ];then
echo "No Suitable files found in this location: $WALL_DIR";
exit 1;
fi
while true;do
filename=`echo "$filelst" | shuf -n 1`
set_wallpaper "$filename";
sleep $TIMEOUT;
done
exit
Report
s8dtvt
10 years ago
Thanks.
Report
inameiname
10 years ago
Report