misc: changes.

This commit is contained in:
Dylan Araps 2018-01-02 13:46:31 +11:00
parent 55503fbc60
commit 30ea15b0e2
4 changed files with 11 additions and 13 deletions

View File

@ -13,13 +13,11 @@ from . import util
def imagemagick(color_count, img, magick_command):
"""Call Imagemagick to generate a scheme."""
colors = subprocess.run([*magick_command, img,
"-resize", "25%", "+dither",
"-colors", str(color_count),
"-unique-colors", "txt:-"],
stdout=subprocess.PIPE)
flags = ["-resize", "25%", "-colors", str(color_count),
"-unique-colors", "txt:-"]
return colors.stdout.splitlines()
return subprocess.check_output([*magick_command,
img, *flags]).splitlines()
def has_im():

View File

@ -53,11 +53,13 @@ def every(colors, output_dir=CACHE_DIR):
template_dir_user = os.path.join(CONF_DIR, "templates")
util.create_dir(template_dir_user)
join = os.path.join # Minor optimization.
for file in os.scandir(template_dir):
template(colors, file.path, os.path.join(output_dir, file.name))
template(colors, file.path, join(output_dir, file.name))
for file in os.scandir(template_dir_user):
template(colors, file.path, os.path.join(output_dir, file.name))
template(colors, file.path, join(output_dir, file.name))
print("export: Exported all files.")
print("export: Exported all user files.")

View File

@ -18,9 +18,7 @@ def xrdb(xrdb_files=None):
if shutil.which("xrdb") and OS != "Darwin":
for file in xrdb_files:
subprocess.Popen(["xrdb", "-merge", "-nocpp", file],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL).wait()
subprocess.run(["xrdb", "-merge", "-nocpp", file])
def gtk():

View File

@ -73,14 +73,14 @@ def create_sequences(colors):
def send(colors, cache_dir=CACHE_DIR):
"""Send colors to all open terminals."""
sequences = create_sequences(colors)
if OS == "Darwin":
tty_pattern = "/dev/ttys00[0-9]*"
else:
tty_pattern = "/dev/pts/[0-9]*"
sequences = create_sequences(colors)
# Writing to "/dev/pts/[0-9] lets you send data to open terminals.
for term in glob.glob(tty_pattern):
util.save_file(sequences, term)