How to use the wpgtk.data.config.WPG_DIR function in wpgtk

To help you get started, we’ve selected a few wpgtk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deviantfero / wpgtk / wpgtk / data / files.py View on Github external
def write_script(wallpaper, colorscheme):
    """writes the script that should be called on startup
    to restore the theme."""
    set_wall = settings.getboolean("set_wallpaper", True)
    light_theme = settings.getboolean("light_theme", True)

    flags = "-rs" if set_wall else "-nrs"
    flags += "L" if light_theme else ""

    with open(join(WPG_DIR, "wp_init.sh"), "w") as script:
        command = "wpg %s '%s' '%s'" % (flags, wallpaper, colorscheme)
        script.writelines(["#!/usr/bin/env bash\n", command])
github deviantfero / wpgtk / wpgtk / data / themer.py View on Github external
def get_current():
    image = basename(realpath(path.join(WPG_DIR, '.current')))
    return image
github deviantfero / wpgtk / wpgtk / data / files.py View on Github external
def change_current(filename):
    """update symlink to point to the current wallpaper"""
    os.symlink(join(WALL_DIR, filename), join(WPG_DIR, ".currentTmp"))
    os.rename(join(WPG_DIR, ".currentTmp"), join(WPG_DIR, ".current"))
github deviantfero / wpgtk / wpgtk / data / themer.py View on Github external
pywal.export.every(colors, FORMAT_DIR)
        color.apply_colorscheme(colors)
        if reload_all:
            reload.all()
    else:
        reload.xrdb()

    if set_wall:
        filepath = path.join(WALL_DIR, wallpaper)
        set_wall = filepath if path.isfile(filepath) else colors["wallpaper"]
        pywal.wallpaper.change(set_wall)

    files.write_script(wallpaper, colorscheme)
    files.change_current(wallpaper)

    Popen(['chmod', '+x', path.join(WPG_DIR, "wp_init.sh")])

    if settings.getboolean('execute_cmd', False) and not restore:
        Popen(['bash', '-c', settings['command']])
github deviantfero / wpgtk / wpgtk / gui / theme_picker.py View on Github external
def __init__(self, args):
        Gtk.Window.__init__(self, title='wpgtk ' + __version__)

        image_name = os.path.join(WPG_DIR, '.current')
        image_name = os.path.realpath(image_name)
        self.set_default_size(200, 200)
        self.args = args

        # these variables are just to get the image
        # and preview of current wallpaper
        file_name = themer.get_current()
        logging.info('current wallpaper: ' + file_name)
        sample_name = files.get_sample_path(file_name)

        self.notebook = Gtk.Notebook()
        self.add(self.notebook)

        self.wpage = Gtk.Grid()
        self.wpage.set_border_width(PAD)
        self.wpage.set_column_homogeneous(1)
github deviantfero / wpgtk / wpgtk / data / color.py View on Github external
def get_pywal_dict(wallpaper, is_file=False):
    """get the color dictionary of a given wallpaper"""
    light_theme = settings.getboolean("light_theme", False)
    pywal.util.Color.alpha_num = settings.get("alpha", "100")

    image = pywal.image.get(os.path.join(WALL_DIR, wallpaper))

    return pywal.colors.get(
        image,
        light=(is_file and light_theme),
        backend=settings.get("backend", "wal"),
        cache_dir=WPG_DIR
    )
github deviantfero / wpgtk / wpgtk / data / themer.py View on Github external
def set_theme(wallpaper, colorscheme, restore=False):
    """apply a given wallpaper and a given colorscheme"""
    use_vte = settings.getboolean("vte", False)
    is_file = path.isdir(colorscheme) or path.isfile(colorscheme)
    target = colorscheme if is_file else path.join(WALL_DIR, colorscheme)

    set_wall = settings.getboolean("set_wallpaper", True)
    reload_all = settings.getboolean("reload", True)
    colors = color.get_pywal_dict(target, is_file)
    pywal.sequences.send(colors, WPG_DIR, vte_fix=use_vte)

    if not restore:
        pywal.export.every(colors, FORMAT_DIR)
        color.apply_colorscheme(colors)
        if reload_all:
            reload.all()
    else:
        reload.xrdb()

    if set_wall:
        filepath = path.join(WALL_DIR, wallpaper)
        set_wall = filepath if path.isfile(filepath) else colors["wallpaper"]
        pywal.wallpaper.change(set_wall)

    files.write_script(wallpaper, colorscheme)
    files.change_current(wallpaper)
github deviantfero / wpgtk / wpgtk / data / files.py View on Github external
def get_cache_path(wallpaper, backend=None):
    """get a colorscheme cache path using a wallpaper name"""
    if not backend:
        backend = settings.get("backend", "wal")

    filepath = join(WALL_DIR, wallpaper)
    filename = cache_fname(filepath, backend, False, WPG_DIR)

    return join(*filename)