Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remake/port for python using argparse #105

Open
H4ppy-04 opened this issue Dec 19, 2023 · 0 comments
Open

remake/port for python using argparse #105

H4ppy-04 opened this issue Dec 19, 2023 · 0 comments

Comments

@H4ppy-04
Copy link

I remade this in python but now i don't know what to do with it lol. anyway here ya go:

import subprocess
import os
import sys
import argparse

BANNER = """
╺┳┓╻ ╻┏┓╻┏━┓┏┳┓╻┏━╸   ╻ ╻┏━┓╻  ╻  ┏━┓┏━┓┏━┓┏━╸┏━┓
 ┃┃┗┳┛┃┗┫┣━┫┃┃┃┃┃     ┃╻┃┣━┫┃  ┃  ┣━┛┣━┫┣━┛┣╸ ┣┳┛
╺┻┛ ╹ ╹ ╹╹ ╹╹ ╹╹┗━╸   ┗┻┛╹ ╹┗━╸┗━╸╹  ╹ ╹╹  ┗━╸╹┗╸
"""

THEMES = [
    "aurora",
    "beach",
    "bitday",
    "chihuahuan",
    "cliffs",
    "colony",
    "desert",
    "earth",
    "exodus",
    "factory",
    "firewatch",
    "forest",
    "gradient",
    "home",
    "island",
    "lake",
    "lakeside",
    "market",
    "mojave",
    "moon",
    "mountains",
    "room",
    "sahara",
    "street",
    "tokyo",
]

__program__ = "dmenu"
__authors__ = ["https://github.com/adi1090x/dynamic-wallpaper/graphs/contributors"]
__version__ = 3.0

DEFAULT_THEME = "tokyo"
EXEC_PATH = "/home/joshua/.local/bin/pipes.sh"
HOME = os.getenv("$HOME")

if not os.path.exists(EXEC_PATH):
    raise FileNotFoundError("pipes.sh is not in the local path")

parser = argparse.ArgumentParser(
    prog=__program__,
    # description=BANNER,
    #epilog="".join([i + " " for i in __authors__]),
)
parser.add_argument(
    "--list-styles",
    help="List available styles",
    action="store_true",
    dest="list",
)
parser.add_argument(
    "-p",
    "--pywal",
    action="store_true",
    help="Use pywal to set wallpaper",
    dest="pywal",
)
parser.add_argument(
    "-s",
    nargs=1,
    type=str,
    dest="style",
    help="Name of the style to apply",
)


args = parser.parse_args()

if args.list:
    print(f"Available styles: {'  '.join(THEMES)}")
    sys.exit()
if args.pywal == False and args.style == None:
    parser.print_help()
    print("""\n\nExamples:
    dwall -s beach        Set wallpaper from 'beach' style
    dwall -p -s sahara    Set wallpaper from 'sahara' style using pywal
    """)
    sys.exit()

theme = args.style[0] if args.style else DEFAULT_THEME
stdargs = [EXEC_PATH, "-p" if args.pywal else "", theme]

subprocess.run(
    " ".join(stdargs),
    cwd=HOME,
    shell=True,
    stderr=subprocess.STDOUT,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant