mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-05-21 00:30:53 +02:00
General: Cleanup
This commit is contained in:
parent
b2af5c914d
commit
b2ae26b4fb
21
wal.py
21
wal.py
@ -23,7 +23,6 @@ XRDB_FILE = "%s%s" % (CACHE_DIR, "xcolors")
|
|||||||
|
|
||||||
# Internal variables.
|
# Internal variables.
|
||||||
COLOR_COUNT = 16
|
COLOR_COUNT = 16
|
||||||
OS = os.uname
|
|
||||||
|
|
||||||
|
|
||||||
# ARGS {{{
|
# ARGS {{{
|
||||||
@ -201,7 +200,7 @@ def set_color(index, color):
|
|||||||
return "\\033]4;%s;%s\\007" % (str(index), color)
|
return "\\033]4;%s;%s\\007" % (str(index), color)
|
||||||
|
|
||||||
|
|
||||||
def get_grey(color, color2):
|
def get_grey(colors):
|
||||||
"""Set a grey color based on brightness of color0"""
|
"""Set a grey color based on brightness of color0"""
|
||||||
return {
|
return {
|
||||||
0: "#666666",
|
0: "#666666",
|
||||||
@ -214,7 +213,7 @@ def get_grey(color, color2):
|
|||||||
7: "#a1a1a1",
|
7: "#a1a1a1",
|
||||||
8: "#a1a1a1",
|
8: "#a1a1a1",
|
||||||
9: "#a1a1a1",
|
9: "#a1a1a1",
|
||||||
}.get(int(color[1]), color2)
|
}.get(int(colors[0][1]), colors[7])
|
||||||
|
|
||||||
|
|
||||||
def send_sequences(colors, vte):
|
def send_sequences(colors, vte):
|
||||||
@ -238,7 +237,7 @@ def send_sequences(colors, vte):
|
|||||||
seq.append(set_color(5, colors[13]))
|
seq.append(set_color(5, colors[13]))
|
||||||
seq.append(set_color(6, colors[14]))
|
seq.append(set_color(6, colors[14]))
|
||||||
seq.append(set_color(7, colors[15]))
|
seq.append(set_color(7, colors[15]))
|
||||||
seq.append(set_color(8, get_grey(colors[0], colors[7])))
|
seq.append(set_color(8, get_grey(colors)))
|
||||||
seq.append(set_color(9, colors[9]))
|
seq.append(set_color(9, colors[9]))
|
||||||
seq.append(set_color(10, colors[10]))
|
seq.append(set_color(10, colors[10]))
|
||||||
seq.append(set_color(11, colors[11]))
|
seq.append(set_color(11, colors[11]))
|
||||||
@ -276,6 +275,8 @@ def send_sequences(colors, vte):
|
|||||||
|
|
||||||
def set_wallpaper(img):
|
def set_wallpaper(img):
|
||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
|
uname = os.uname
|
||||||
|
|
||||||
if shutil.which("feh"):
|
if shutil.which("feh"):
|
||||||
subprocess.Popen(["feh", "--bg-fill", img])
|
subprocess.Popen(["feh", "--bg-fill", img])
|
||||||
|
|
||||||
@ -291,7 +292,7 @@ def set_wallpaper(img):
|
|||||||
elif shutil.which("habak"):
|
elif shutil.which("habak"):
|
||||||
subprocess.Popen(["habak", "-mS", img])
|
subprocess.Popen(["habak", "-mS", img])
|
||||||
|
|
||||||
elif OS == "Darwin":
|
elif uname == "Darwin":
|
||||||
subprocess.Popen(["osascript", "-e", "'tell application \"Finder\" to set \
|
subprocess.Popen(["osascript", "-e", "'tell application \"Finder\" to set \
|
||||||
desktop picture to POSIX file\'" + img + "\'"])
|
desktop picture to POSIX file\'" + img + "\'"])
|
||||||
|
|
||||||
@ -354,7 +355,7 @@ def export_xrdb(colors):
|
|||||||
colors[13],
|
colors[13],
|
||||||
colors[14],
|
colors[14],
|
||||||
colors[15],
|
colors[15],
|
||||||
get_grey(colors[0], colors[7]),
|
get_grey(colors),
|
||||||
colors[9],
|
colors[9],
|
||||||
colors[10],
|
colors[10],
|
||||||
colors[11],
|
colors[11],
|
||||||
@ -378,20 +379,20 @@ def export_xrdb(colors):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main script function."""
|
"""Main script function."""
|
||||||
# Create colorscheme dir.
|
# Get the args.
|
||||||
pathlib.Path(SCHEME_DIR).mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
args = get_args()
|
args = get_args()
|
||||||
|
|
||||||
# -c
|
# -c
|
||||||
if args.c:
|
if args.c:
|
||||||
shutil.rmtree(SCHEME_DIR)
|
shutil.rmtree(SCHEME_DIR)
|
||||||
quit()
|
|
||||||
|
|
||||||
# -r
|
# -r
|
||||||
if args.r:
|
if args.r:
|
||||||
reload_colors(args.t)
|
reload_colors(args.t)
|
||||||
|
|
||||||
|
# Create colorscheme dir.
|
||||||
|
pathlib.Path(SCHEME_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
# -i
|
# -i
|
||||||
if args.i:
|
if args.i:
|
||||||
image = str(get_image(args.i))
|
image = str(get_image(args.i))
|
||||||
|
Loading…
Reference in New Issue
Block a user