mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-08 06:59:34 +01:00
api: Added a simple example.
This commit is contained in:
parent
2973ea06f6
commit
ced562e4df
@ -1,42 +1,29 @@
|
|||||||
"""Test script for wal api."""
|
"""Simple script for wal api."""
|
||||||
import pathlib
|
|
||||||
import pywal
|
import pywal
|
||||||
|
|
||||||
|
|
||||||
CACHE_DIR = pathlib.Path.home() / "wal-test"
|
|
||||||
COLOR_COUNT = 16
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function."""
|
"""Main function."""
|
||||||
# Create the custom cache directory.
|
|
||||||
pywal.util.create_dir(CACHE_DIR / "schemes")
|
|
||||||
|
|
||||||
# Validate image and pick a random image if a
|
# Validate image and pick a random image if a
|
||||||
# directory is given below.
|
# directory is given below.
|
||||||
#
|
image = pywal.get_image("/home/dylan/Pictures/Wallpapers/")
|
||||||
# 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)
|
|
||||||
|
|
||||||
# Return a dict with the palette.
|
# Return a dict with the palette.
|
||||||
#
|
#
|
||||||
# The last argument is 'quiet' mode. When set to true, no notifications
|
# Set quiet to 'True' to disable notifications.
|
||||||
# are displayed.
|
colors = pywal.create_palette(image, quiet=False)
|
||||||
colors = pywal.create_palette(image, CACHE_DIR, COLOR_COUNT, True)
|
|
||||||
|
|
||||||
# Apply the palette to all open terminals.
|
# Apply the palette to all open terminals.
|
||||||
# Second argument is a boolean for VTE terminals.
|
# Second argument is a boolean for VTE terminals.
|
||||||
# Set it to true if the terminal you're using is
|
# Set it to true if the terminal you're using is
|
||||||
# VTE based. (xfce4-terminal, termite, gnome-terminal.)
|
# VTE based. (xfce4-terminal, termite, gnome-terminal.)
|
||||||
pywal.send_sequences(colors, False, CACHE_DIR)
|
pywal.send_sequences(colors, vte=False)
|
||||||
|
|
||||||
# Reload xrdb, i3 and polybar.
|
# Reload xrdb, i3 and polybar.
|
||||||
pywal.reload_env(CACHE_DIR)
|
pywal.reload_env()
|
||||||
|
|
||||||
# Export template files.
|
# Export template files.
|
||||||
pywal.export_all_templates(colors, CACHE_DIR)
|
pywal.export_all_templates(colors)
|
||||||
|
|
||||||
# Set the wallpaper.
|
# Set the wallpaper.
|
||||||
pywal.set_wallpaper(image)
|
pywal.set_wallpaper(image)
|
||||||
|
46
examples/example_custom_cache.py
Normal file
46
examples/example_custom_cache.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
"""Test script for wal api.
|
||||||
|
This script uses a custom cache location for the files."""
|
||||||
|
import pathlib
|
||||||
|
import pywal
|
||||||
|
|
||||||
|
|
||||||
|
CACHE_DIR = pathlib.Path.home() / "wal-test"
|
||||||
|
COLOR_COUNT = 16
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Main function."""
|
||||||
|
# Create the custom cache directory.
|
||||||
|
pywal.util.create_dir(CACHE_DIR / "schemes")
|
||||||
|
|
||||||
|
# Validate image and pick a random image if a
|
||||||
|
# directory is given below.
|
||||||
|
#
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# Return a dict with the palette.
|
||||||
|
#
|
||||||
|
# The last argument is 'quiet' mode. When set to true, no notifications
|
||||||
|
# are displayed.
|
||||||
|
colors = pywal.create_palette(image, CACHE_DIR, COLOR_COUNT, True)
|
||||||
|
|
||||||
|
# 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.)
|
||||||
|
pywal.send_sequences(colors, False, CACHE_DIR)
|
||||||
|
|
||||||
|
# Reload xrdb, i3 and polybar.
|
||||||
|
pywal.reload_env(CACHE_DIR)
|
||||||
|
|
||||||
|
# Export template files.
|
||||||
|
pywal.export_all_templates(colors, CACHE_DIR)
|
||||||
|
|
||||||
|
# Set the wallpaper.
|
||||||
|
pywal.set_wallpaper(image)
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user