~xubuntu-dev/ubiquity/lp1437180_feh

6104.1.4 by Aurélien Gâteau
Bring back default wallpaper behind Ubiquity window
1
#!/usr/bin/python3
2
3
'''
4
Helper program to draw a background image on each screen of the system.
5
'''
6
7
import sys
8
9
from PyQt4.QtCore import Qt
10
from PyQt4 import QtGui
11
12
13
def die(msg):
14
    print(msg, file=sys.stderr)
15
    sys.exit(1)
16
17
18
def create_window(wallpaper, geometry):
19
    win = QtGui.QWidget()
20
21
    wallpaper = wallpaper.scaled(geometry.size(),
22
                                 Qt.KeepAspectRatioByExpanding,
23
                                 Qt.SmoothTransformation)
24
    palette = QtGui.QPalette()
25
    palette.setBrush(win.backgroundRole(), QtGui.QBrush(wallpaper))
26
27
    win.setPalette(palette)
28
    win.setAttribute(Qt.WA_X11NetWmWindowTypeDesktop)
29
    win.setGeometry(geometry)
30
    win.show()
31
    return win
32
33
34
def main():
35
    if len(sys.argv) != 2:
36
        die('usage: {} <path/to/wallpaper.png>'.format(sys.argv[0]))
37
    path = sys.argv[1]
38
39
    app = QtGui.QApplication(sys.argv)
40
    wallpaper = QtGui.QPixmap(path)
41
    if wallpaper.isNull():
42
        die('Failed to load {}'.format(path))
43
44
    desktop = app.desktop()
45
    # Keep a trace of the windows to ensure they are not garbage collected
46
    windows = []
47
    for idx in range(desktop.screenCount()):
48
        geometry = desktop.screenGeometry(idx)
49
        win = create_window(wallpaper, geometry)
50
        windows.append(win)
51
52
    return app.exec_()
53
54
55
if __name__ == '__main__':
56
    main()