Last active
January 2, 2016 00:09
-
-
Save hackedd/8221565 to your computer and use it in GitHub Desktop.
Replace default date and time format in cinnamon-screensaver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
source = "/usr/bin/cinnamon-screensaver" | |
time_format = "%l:%M %p" | |
date_format = "%A, %B %e" | |
nul = "\x00" | |
def patch(data, orig, new): | |
assert len(orig) >= len(new), repr(new) + " too long" | |
o, l = data.find(orig), len(orig) | |
assert o >= 0, repr(orig) + " not found" | |
return data[:o] + new.ljust(l, nul) + data[o + l:] | |
new_time_format = sys.argv[1] if len(sys.argv) >= 2 else "%T" | |
new_date_format = sys.argv[2] if len(sys.argv) >= 3 else "%c" | |
dest = sys.argv[3] if len(sys.argv) >= 4 else "cinnamon-screensaver" | |
with open(source, "rb") as fp: | |
data = fp.read() | |
data = patch(data, time_format, new_time_format) | |
data = patch(data, date_format, new_date_format) | |
with open(dest, "wb") as fp: | |
fp.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment