Skip to content

Commit e889b37

Browse files
authored
Create rotating-wallpaper.py
1 parent d58ccd2 commit e889b37

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

rotating-wallpaper.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/python3
2+
3+
# This file is part of gnome-rotating-wallpaper.
4+
# Copyright (C) 2018 stratacast
5+
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
20+
import subprocess
21+
import imghdr
22+
import os
23+
from os.path import isfile, join
24+
import time
25+
import random
26+
27+
timer = 15
28+
29+
def main():
30+
#directory = ""
31+
directory = ""
32+
photo_list = []
33+
count = 0
34+
35+
for filename in os.listdir(directory):
36+
picture = join(directory, filename)
37+
if isfile(picture) and imghdr.what(picture):
38+
photo_list.append(picture)
39+
count+=1
40+
41+
last_wallpaper = 0
42+
43+
while True:
44+
p_index = last_wallpaper
45+
46+
while p_index == last_wallpaper:
47+
p_index = random.randint(1, count) - 1
48+
49+
photo = photo_list[p_index]
50+
command = "gsettings set org.gnome.desktop.background picture-uri file:///" + str(photo)
51+
subprocess.run(command.split())
52+
53+
time.sleep(timer)
54+
55+
56+
if(__name__ == "__main__"):
57+
main()

0 commit comments

Comments
 (0)