summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wal.py53
1 files changed, 44 insertions, 9 deletions
diff --git a/wal.py b/wal.py
index dd36669..becf3d5 100644
--- a/wal.py
+++ b/wal.py
@@ -25,30 +25,33 @@ COLOR_COUNT = 16
OS = os.uname
+# ARGS {{{
+
+
def get_args():
"""Get the script arguments."""
description = "wal - Generate colorschemes on the fly"
arg = argparse.ArgumentParser(description=description)
# Add the args.
- arg.add_argument('-a', metavar='0-100', type=int,
- help='Set terminal background transparency. \
- *Only works in URxvt*')
+ # arg.add_argument('-a', metavar='0-100', type=int,
+ # help='Set terminal background transparency. \
+ # *Only works in URxvt*')
arg.add_argument('-c', action='store_true',
help='Delete all cached colorschemes.')
- arg.add_argument('-f', metavar='"/path/to/colors"',
- help='Load colors directly from a colorscheme file.')
+ # arg.add_argument('-f', metavar='"/path/to/colors"',
+ # help='Load colors directly from a colorscheme file.')
arg.add_argument('-i', metavar='"/path/to/img.jpg"',
help='Which image or directory to use.')
- arg.add_argument('-n', action='store_true',
- help='Skip setting the wallpaper.')
+ # arg.add_argument('-n', action='store_true',
+ # help='Skip setting the wallpaper.')
- arg.add_argument('-o', metavar='script_name',
- help='External script to run after "wal".')
+ # arg.add_argument('-o', metavar='script_name',
+ # help='External script to run after "wal".')
# arg.add_argument('-q', action='store_true',
# help='Quiet mode, don\'t print anything.')
@@ -78,6 +81,11 @@ def process_args(args):
reload_colors(args.t)
+# }}}
+
+
+# RELOAD COLORS {{{
+
def reload_colors(vte):
"""Reload colors."""
with open(CACHE_DIR + "sequences") as file:
@@ -94,6 +102,12 @@ def reload_colors(vte):
quit()
+# }}}
+
+
+# COLORSCHEME GENERATION {{{
+
+
def get_image(img):
"""Validate image input."""
image = Path(img)
@@ -179,6 +193,12 @@ def get_colors(img):
return colors
+# }}}
+
+
+# SEND SEQUENCES {{{
+
+
def set_special(index, color):
"""Build the escape sequence for special colors."""
return "\\033]" + str(index) + ";" + color + "\\007"
@@ -260,6 +280,12 @@ def send_sequences(colors, vte):
print("colors: Set terminal colors")
+# }}}
+
+
+# WALLPAPER SETTING {{{
+
+
def set_wallpaper(img):
"""Set the wallpaper."""
if shutil.which("feh"):
@@ -289,6 +315,12 @@ def set_wallpaper(img):
return 0
+# }}}
+
+
+# EXPORT COLORS {{{
+
+
def export_plain(colors):
"""Export colors to a plain text file."""
plain_file = CACHE_DIR + "colors"
@@ -336,6 +368,9 @@ def export_xrdb(colors):
print("export: Exported xrdb colors.")
+# }}}
+
+
def main():
"""Main script function."""
args = get_args()