mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-28 04:20:03 +02:00
wallpaper: use a temporary file to save current wallpaper
Otherwise, other utilities (like i3lock) may get a corrupted image.
This commit is contained in:
parent
30a6a9a4dc
commit
b205223f63
1 changed files with 5 additions and 1 deletions
|
@ -9,6 +9,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import optparse
|
import optparse
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import xcb
|
import xcb
|
||||||
import xcb.xproto
|
import xcb.xproto
|
||||||
|
@ -82,4 +83,7 @@ for index in range(len(screens)):
|
||||||
|
|
||||||
# Save
|
# Save
|
||||||
assert background, "Don't know the size of the display area"
|
assert background, "Don't know the size of the display area"
|
||||||
background.save(options.target)
|
with tempfile.NamedTemporaryFile(delete=False,
|
||||||
|
dir=os.path.dirname(os.path.realpath(options.target))) as tmp:
|
||||||
|
background.save(tmp, "jpeg")
|
||||||
|
os.rename(tmp.name, options.target)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue