forked from SergKolo/sergrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_wallpaper.sh
executable file
·60 lines (56 loc) · 1.8 KB
/
random_wallpaper.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
#
###########################################################
# Author: Serg Kolo , contact: [email protected]
# Date: March 10th 2016
# Purpose: Set random wallpaper
# To make it start automatically, add it as one of
# the Startup Applications in Ubuntu's Unity
# or Gnome
#
# Written for: http://askubuntu.com/q/744464/295286
# Tested on: Ubuntu 14.04 LTS
###########################################################
# Copyright: Serg Kolo , 2016
#
# Permission to use, copy, modify, and distribute this software is hereby granted
# without fee, provided that the copyright notice above and this permission statement
# appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
ARGV0="$0"
ARGC=$#
change_background()
{
FILE="'file://$(readlink -f "$1" )'"
echo changing to "$FILE"
gsettings set org.gnome.desktop.background picture-uri "$FILE"
}
make_list()
{
# -max-depth may be optional , if you want to
# traverse subdirectories,too
find "$1" -maxdepth 1 -type f > "$2"
}
main()
{
# Variables
local DISPLAY=:0 # ensure this is set
local DIR="$1"
local LIST="/tmp/wallpaper.list"
local TIME="$2"
# cat $LIST # for debugging only
make_list "$DIR" "$LIST"
while true
do
change_background $( shuf $LIST | head -n 1 )
sleep 5 #
done
}
main "$@"