api: More changes.

This commit is contained in:
Dylan Araps 2017-07-23 11:05:20 +10:00
parent 377cc7e68c
commit 1eb16c8f97
3 changed files with 15 additions and 8 deletions

View File

@ -16,10 +16,10 @@ import sys
from .settings import __version__, __cache_dir__ from .settings import __version__, __cache_dir__
from . import colors from . import colors
from . import export
from . import image from . import image
from . import reload from . import reload
from . import sequences from . import sequences
from . import template
from . import util from . import util
from . import wallpaper from . import wallpaper
@ -99,7 +99,7 @@ def process_args(args):
if not args.n: if not args.n:
wallpaper.change(colors_plain["wallpaper"]) wallpaper.change(colors_plain["wallpaper"])
template.export_all(colors_plain) export.every(colors_plain)
reload.env() reload.env()
if args.o: if args.o:

View File

@ -7,15 +7,13 @@ import random
from .settings import __cache_dir__ from .settings import __cache_dir__
from . import util from . import util
from . import wallpaper
def get_random_image(img_dir, cache_dir): def get_random_image(img_dir, cache_dir):
"""Pick a random image file from a directory.""" """Pick a random image file from a directory."""
current_wall = cache_dir / "wal" current_wall = wallpaper.get()
current_wall = os.path.basename(current_wall[0])
if current_wall.is_file():
current_wall = util.read_file(current_wall)
current_wall = os.path.basename(current_wall[0])
file_types = (".png", ".jpg", ".jpeg", ".jpe", ".gif") file_types = (".png", ".jpg", ".jpeg", ".jpe", ".gif")
images = [img for img in os.scandir(img_dir) images = [img for img in os.scandir(img_dir)

View File

@ -3,7 +3,8 @@ import os
import shutil import shutil
import subprocess import subprocess
from pywal import util from .settings import __cache_dir__
from . import util
def get_desktop_env(): def get_desktop_env():
@ -94,3 +95,11 @@ def change(img):
set_wm_wallpaper(img) set_wm_wallpaper(img)
print("wallpaper: Set the new wallpaper") print("wallpaper: Set the new wallpaper")
def get(cache_dir=__cache_dir__):
"""Get the current wallpaper."""
current_wall = cache_dir / "wal"
if current_wall.is_file():
return util.read_file(current_wall)[0]