c204f20c7125d8e3c628cf528eb953fa78abccf9 — Charles Daniels 4 years ago 8d4a4f3
add lstart and runstart options to bacchus
1 files changed, 33 insertions(+), 0 deletions(-)

M bin/bacchus
M bin/bacchus => bin/bacchus +33 -0
@@ 51,6 51,7 @@ import toml
import subprocess
import datetime
import stat
import pathlib

# Note, these are the default values for the configuration file, which is
# usually ~/.config/bacchus/bacchus.toml.

@@ 236,6 237,26 @@ def generate_launcher(prefix, winearch, target, name=None):

    logging.info("Wrote launcher to '{}'".format(launcher_file))

def list_startmenu(prefix):
    smpath = pathlib.Path(os.path.join(get_prefix_dir(prefix),
        "drive_c/ProgramData/Microsoft/Windows/Start Menu/Programs/"))
    for path in smpath.glob("**/*.lnk"):

def run_start(prefix, winearch, name):
    smpath = pathlib.Path(os.path.join(get_prefix_dir(prefix),
        "drive_c/ProgramData/Microsoft/Windows/Start Menu/Programs/"))
    lnkpath = smpath / name

    if not lnkpath.exists():
        logging.warning("no such start menu entry {}".format(lnkpath))
        lnkpath = smpath / "{}.lnk".format(name)

    if not lnkpath.exists():
        logging.error("no such start menu entry {}".format(lnkpath))

    invoke_wine(prefix, winearch, ["start", "/unix", str(lnkpath)])

def generate_links(prefix, target):
    launcher_dir = os.path.join(get_prefix_dir(prefix), "bacchus")

@@ 284,6 305,9 @@ def main():
            help="Run a command through WINE. Hint: taskmgr runs " +
            "task manager, explorer runs explorer.exe.")

    action.add_argument("--runstart", "-S", default=None,
            help="Run a start menu entry through WINE.");

    action.add_argument("--where", "-w", default=False, action="store_true",
            help="Display the fully qualified path to the prefix.")

@@ 293,6 317,9 @@ def main():
    action.add_argument("--launcher", "-l", default=None,
            help="Generate a launcher script for the specified file.")

    action.add_argument("--lstart", "-s", default=False, action="store_true",
            help="List start menu entries.")

    action.add_argument("--link", "-L", default=False,
            action="store_true", help="Symlink all launchers for the " +
            "specified prefix into the configured bin directory. " +

@@ 318,6 345,9 @@ def main():
        elif args.run is not None:
            invoke_wine(args.prefix, args.winearch, args.run)

        elif args.runstart is not None:
            run_start(args.prefix, args.winearch, args.runstart)

        elif args.where:

@@ 333,6 363,9 @@ def main():
                    target = args.launcher,
                    name = args.name)

        elif args.lstart:

        elif args.link:
            generate_links(args.prefix, read_config_key("bin_dir"))