-
Notifications
You must be signed in to change notification settings - Fork 4
/
rotate-wallpaper
executable file
·27 lines (24 loc) · 1.05 KB
/
rotate-wallpaper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
#=======================================================================================================================
# Description
# Script to set a random wallpaper in Gnome 3/Unity. See
# http://blog.yktoo.com/2011/10/gnome-3-ubuntu-1110-random-wallpaper.html for details.
# Synopsis
# rotate-wallpaper
# Author
# Dmitry Kann, http://yktoo.com/
# License
# Public domain
#=======================================================================================================================
# Setup vars
dir_wallpapers="$HOME/Pictures/Wallpapers/iMac" # Path to wallpaper directory
# Fill array with picture files (replace spaces with colons to fool the array)
files=( $(find "$dir_wallpapers" -type f \( -iname '*.jpeg' -o -iname '*.jpg' -o -iname '*.png' \) | sed s/' '/':'/g) )
# Get number of members in the array
N=${#files[@]}
# Randomize N
((N=RANDOM%N))
# Get the normal file name (change colons back to spaces)
file=${files[$N]//:/ }
# Change desktop wallpaper
gsettings set org.gnome.desktop.background picture-uri "file://$file"