mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-05-21 00:30:53 +02:00
GENERAL: Added fold markers and commented out unimplemented args.
This commit is contained in:
parent
168f622b5d
commit
bfef5a1737
53
wal.py
53
wal.py
@ -25,30 +25,33 @@ COLOR_COUNT = 16
|
|||||||
OS = os.uname
|
OS = os.uname
|
||||||
|
|
||||||
|
|
||||||
|
# ARGS {{{
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
"""Get the script arguments."""
|
"""Get the script arguments."""
|
||||||
description = "wal - Generate colorschemes on the fly"
|
description = "wal - Generate colorschemes on the fly"
|
||||||
arg = argparse.ArgumentParser(description=description)
|
arg = argparse.ArgumentParser(description=description)
|
||||||
|
|
||||||
# Add the args.
|
# Add the args.
|
||||||
arg.add_argument('-a', metavar='0-100', type=int,
|
# arg.add_argument('-a', metavar='0-100', type=int,
|
||||||
help='Set terminal background transparency. \
|
# help='Set terminal background transparency. \
|
||||||
*Only works in URxvt*')
|
# *Only works in URxvt*')
|
||||||
|
|
||||||
arg.add_argument('-c', action='store_true',
|
arg.add_argument('-c', action='store_true',
|
||||||
help='Delete all cached colorschemes.')
|
help='Delete all cached colorschemes.')
|
||||||
|
|
||||||
arg.add_argument('-f', metavar='"/path/to/colors"',
|
# arg.add_argument('-f', metavar='"/path/to/colors"',
|
||||||
help='Load colors directly from a colorscheme file.')
|
# help='Load colors directly from a colorscheme file.')
|
||||||
|
|
||||||
arg.add_argument('-i', metavar='"/path/to/img.jpg"',
|
arg.add_argument('-i', metavar='"/path/to/img.jpg"',
|
||||||
help='Which image or directory to use.')
|
help='Which image or directory to use.')
|
||||||
|
|
||||||
arg.add_argument('-n', action='store_true',
|
# arg.add_argument('-n', action='store_true',
|
||||||
help='Skip setting the wallpaper.')
|
# help='Skip setting the wallpaper.')
|
||||||
|
|
||||||
arg.add_argument('-o', metavar='script_name',
|
# arg.add_argument('-o', metavar='script_name',
|
||||||
help='External script to run after "wal".')
|
# help='External script to run after "wal".')
|
||||||
|
|
||||||
# arg.add_argument('-q', action='store_true',
|
# arg.add_argument('-q', action='store_true',
|
||||||
# help='Quiet mode, don\'t print anything.')
|
# help='Quiet mode, don\'t print anything.')
|
||||||
@ -78,6 +81,11 @@ def process_args(args):
|
|||||||
reload_colors(args.t)
|
reload_colors(args.t)
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# RELOAD COLORS {{{
|
||||||
|
|
||||||
def reload_colors(vte):
|
def reload_colors(vte):
|
||||||
"""Reload colors."""
|
"""Reload colors."""
|
||||||
with open(CACHE_DIR + "sequences") as file:
|
with open(CACHE_DIR + "sequences") as file:
|
||||||
@ -94,6 +102,12 @@ def reload_colors(vte):
|
|||||||
quit()
|
quit()
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# COLORSCHEME GENERATION {{{
|
||||||
|
|
||||||
|
|
||||||
def get_image(img):
|
def get_image(img):
|
||||||
"""Validate image input."""
|
"""Validate image input."""
|
||||||
image = Path(img)
|
image = Path(img)
|
||||||
@ -179,6 +193,12 @@ def get_colors(img):
|
|||||||
return colors
|
return colors
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# SEND SEQUENCES {{{
|
||||||
|
|
||||||
|
|
||||||
def set_special(index, color):
|
def set_special(index, color):
|
||||||
"""Build the escape sequence for special colors."""
|
"""Build the escape sequence for special colors."""
|
||||||
return "\\033]" + str(index) + ";" + color + "\\007"
|
return "\\033]" + str(index) + ";" + color + "\\007"
|
||||||
@ -260,6 +280,12 @@ def send_sequences(colors, vte):
|
|||||||
print("colors: Set terminal colors")
|
print("colors: Set terminal colors")
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# WALLPAPER SETTING {{{
|
||||||
|
|
||||||
|
|
||||||
def set_wallpaper(img):
|
def set_wallpaper(img):
|
||||||
"""Set the wallpaper."""
|
"""Set the wallpaper."""
|
||||||
if shutil.which("feh"):
|
if shutil.which("feh"):
|
||||||
@ -289,6 +315,12 @@ def set_wallpaper(img):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
# EXPORT COLORS {{{
|
||||||
|
|
||||||
|
|
||||||
def export_plain(colors):
|
def export_plain(colors):
|
||||||
"""Export colors to a plain text file."""
|
"""Export colors to a plain text file."""
|
||||||
plain_file = CACHE_DIR + "colors"
|
plain_file = CACHE_DIR + "colors"
|
||||||
@ -336,6 +368,9 @@ def export_xrdb(colors):
|
|||||||
print("export: Exported xrdb colors.")
|
print("export: Exported xrdb colors.")
|
||||||
|
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main script function."""
|
"""Main script function."""
|
||||||
args = get_args()
|
args = get_args()
|
||||||
|
Loading…
Reference in New Issue
Block a user