pywal/examples/example.py

46 lines
1.3 KiB
Python
Raw Normal View History

"""Test script for wal api."""
2017-07-20 15:32:02 +02:00
import pathlib
2017-07-20 02:44:21 +02:00
import pywal
2017-07-20 15:32:02 +02:00
CACHE_DIR = pathlib.Path.home() / "wal-test"
COLOR_COUNT = 16
2017-07-20 02:44:21 +02:00
def main():
"""Main function."""
2017-07-20 15:32:02 +02:00
# Create the custom cache directory.
pywal.util.create_dir(CACHE_DIR / "schemes")
2017-07-20 04:58:33 +02:00
# Validate image and pick a random image if a
# directory is given below.
2017-07-20 15:32:02 +02:00
#
# CACHE_DIR is an optional argument and is used to check the current
# wallpaper against the random selection. This prevents shuffling to
# the identical image when a directory is passed as an argument.
image = pywal.get_image("/home/dylan/Pictures/Wallpapers/", CACHE_DIR)
2017-07-20 02:44:21 +02:00
# Return a dict with the palette.
2017-07-20 15:32:02 +02:00
#
# The last argument is 'quiet' mode. When set to true, no notifications
# are displayed.
colors = pywal.create_palette(image, CACHE_DIR, COLOR_COUNT, True)
2017-07-20 02:44:21 +02:00
# Apply the palette to all open terminals.
# Second argument is a boolean for VTE terminals.
# Set it to true if the terminal you're using is
# VTE based. (xfce4-terminal, termite, gnome-terminal.)
2017-07-20 15:32:02 +02:00
pywal.send_sequences(colors, False, CACHE_DIR)
2017-07-20 02:44:21 +02:00
# Reload xrdb, i3 and polybar.
2017-07-20 15:32:02 +02:00
pywal.reload_env(CACHE_DIR)
2017-07-20 02:44:21 +02:00
2017-07-20 05:40:31 +02:00
# Export template files.
2017-07-20 15:32:02 +02:00
pywal.export_all_templates(colors, CACHE_DIR)
2017-07-20 05:40:31 +02:00
2017-07-20 02:44:21 +02:00
# Set the wallpaper.
pywal.set_wallpaper(image)
2017-07-20 04:43:23 +02:00
main()