mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-26 04:21:22 +02:00
General: Display a notification to show the user progress.
This commit is contained in:
parent
d01e287719
commit
d5b93ac9ee
37
wal
37
wal
@ -13,10 +13,8 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.1"
|
|
||||||
|
|
||||||
|
|
||||||
# Internal variables.
|
# Internal variables.
|
||||||
|
VERSION = "0.1"
|
||||||
COLOR_COUNT = 16
|
COLOR_COUNT = 16
|
||||||
CACHE_DIR = pathlib.Path.home() / ".cache/wal/"
|
CACHE_DIR = pathlib.Path.home() / ".cache/wal/"
|
||||||
|
|
||||||
@ -36,6 +34,12 @@ class ColorType(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=too-few-public-methods
|
||||||
|
class Args(object):
|
||||||
|
"""Store args."""
|
||||||
|
notify = True
|
||||||
|
|
||||||
|
|
||||||
# ARGS {{{
|
# ARGS {{{
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +62,8 @@ def get_args():
|
|||||||
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 and \
|
||||||
|
don't display notifications.")
|
||||||
|
|
||||||
arg.add_argument("-r", action="store_true",
|
arg.add_argument("-r", action="store_true",
|
||||||
help="Reload current colorscheme.")
|
help="Reload current colorscheme.")
|
||||||
@ -84,6 +89,7 @@ def process_args(args):
|
|||||||
# -q
|
# -q
|
||||||
if args.q:
|
if args.q:
|
||||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||||
|
Args.notify = False
|
||||||
|
|
||||||
# -c
|
# -c
|
||||||
if args.c:
|
if args.c:
|
||||||
@ -96,7 +102,7 @@ def process_args(args):
|
|||||||
|
|
||||||
# -v
|
# -v
|
||||||
if args.v:
|
if args.v:
|
||||||
print(f"wal {__version__}")
|
print(f"wal {VERSION}")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# -i
|
# -i
|
||||||
@ -212,9 +218,11 @@ def get_colors(img):
|
|||||||
|
|
||||||
if cache_file.is_file():
|
if cache_file.is_file():
|
||||||
colors = read_file(cache_file)
|
colors = read_file(cache_file)
|
||||||
|
print("colors: Found cached colorscheme.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("colors: Generating a colorscheme...")
|
print("colors: Generating a colorscheme...")
|
||||||
|
notify("wal: Generating a colorscheme...")
|
||||||
|
|
||||||
# Generate the colors.
|
# Generate the colors.
|
||||||
colors = gen_colors(img)
|
colors = gen_colors(img)
|
||||||
@ -223,7 +231,9 @@ def get_colors(img):
|
|||||||
# Cache the colorscheme.
|
# Cache the colorscheme.
|
||||||
save_file("\n".join(colors), cache_file)
|
save_file("\n".join(colors), cache_file)
|
||||||
|
|
||||||
print("colors: Generated colorscheme")
|
print("colors: Generated colorscheme")
|
||||||
|
notify("wal: Generation complete.")
|
||||||
|
|
||||||
return colors
|
return colors
|
||||||
|
|
||||||
|
|
||||||
@ -400,11 +410,7 @@ def set_wallpaper(img):
|
|||||||
set_desktop_wallpaper(desktop, img)
|
set_desktop_wallpaper(desktop, img)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if os.uname == "Darwin":
|
if shutil.which("feh"):
|
||||||
subprocess.Popen(["osascript", "-e", "\"tell application \"Finder\" to set \
|
|
||||||
desktop picture to POSIX file\"" + img + "\""])
|
|
||||||
|
|
||||||
elif shutil.which("feh"):
|
|
||||||
subprocess.Popen(["feh", "--bg-fill", img])
|
subprocess.Popen(["feh", "--bg-fill", img])
|
||||||
|
|
||||||
elif shutil.which("nitrogen"):
|
elif shutil.which("nitrogen"):
|
||||||
@ -557,6 +563,15 @@ def fix_escape(string):
|
|||||||
return bytes(string, "utf-8").decode("unicode_escape")
|
return bytes(string, "utf-8").decode("unicode_escape")
|
||||||
|
|
||||||
|
|
||||||
|
def notify(msg):
|
||||||
|
"""Send arguements to notify-send."""
|
||||||
|
if shutil.which("notify-send") and Args.notify:
|
||||||
|
subprocess.Popen(["notify-send", msg],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
preexec_fn=os.setpgrp)
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user