wallpaper: use a temporary file to save current wallpaper

Otherwise, other utilities (like i3lock) may get a corrupted image.
This commit is contained in:
Vincent Bernat 2015-02-05 09:26:17 +01:00
parent 30a6a9a4dc
commit b205223f63

View file

@ -9,6 +9,7 @@ import os
import random
import string
import optparse
import tempfile
import xcb
import xcb.xproto
@ -82,4 +83,7 @@ for index in range(len(screens)):
# Save
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)