-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallppr
More file actions
executable file
·67 lines (51 loc) · 1.82 KB
/
wallppr
File metadata and controls
executable file
·67 lines (51 loc) · 1.82 KB
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
61
62
63
64
65
66
#!/usr/bin/env python2
# to get PIL: pacman -S python-pillow
# to get Xlib: pacman -S python2-xlib
import os
import random
from PIL import Image
from Xlib import display
from Xlib.ext import xinerama
# Paths of source and target here
imgPath = "/home/stew/Pictures/Wallpapers/"
targetBackground = "/tmp/wallppr.jpg"
# Here we get the screen information
screens = display.Display().xinerama_query_screens().screens
# Find the target width + height of the spliced image
targetwidth = 0
maxheight = 0
for scr in screens:
targetwidth = targetwidth + scr.width
if maxheight < scr.height:
maxheight = scr.height
if (maxheight < 600) or (targetwidth < 1000):
sys.exit()
# Create our spliced image
imOut = Image.new("RGB", (targetwidth, maxheight), None)
# For each screen, get a random image, resize to fit the screen
# and paste into the spliced image
for scr in screens:
imagePath = imgPath + random.choice( os.listdir(imgPath) )
print( imagePath )
im = Image.open(imagePath)
im = im.resize((scr.width, scr.height), Image.ANTIALIAS)
print( "resizing image" )
imOut.paste( im, (scr.x, scr.y) )
print( "image merged" )
# Save the image and set it as the background
imOut.save(targetBackground)
print( "Background saved" )
desktopEnv = os.environ['DESKTOP_SESSION']
print( "Desktop enviornment is " + desktopEnv )
if 0: #desktopEnv == "mate":
print ("Using MATE config")
os.system('mateconftool-2 -t string -s /desktop/mate/background/picture_filename "file://' + targetBackground + '"')
else:
print("Using Gnome config")
os.system('gsettings set org.gnome.desktop.background picture-uri "file://' + targetBackground + '"')
#
# Original bash script:
# pic=(/home/stew/Pictures/Wallpapers/*)
# gsettings set org.gnome.desktop.background picture-uri \
# "file://${pic[RANDOM % ${#pic[@]}]}"
#