config: Read/write from .config

This commit is contained in:
Dylan Araps 2018-04-01 15:17:57 +10:00
parent 49ca108ead
commit a057497d13
2 changed files with 24 additions and 1 deletions

13
pywal/config/config.ini Normal file
View File

@ -0,0 +1,13 @@
[general]
# External command to run after pywal.
cmd_hook =
[colors]
# Color backend to use.
# Possible values, see: wal --backend
backend = random
[wallpaper]
# Which wallpaper setter to use.
# Example: feh --bg-fill
setter =

View File

@ -12,6 +12,9 @@ Created by Dylan Araps.
import configparser import configparser
import os import os
import platform import platform
import shutil
from . import util
__version__ = "1.3.3" __version__ = "1.3.3"
@ -22,8 +25,15 @@ HOME = os.getenv("HOME", os.getenv("USERPROFILE"))
CACHE_DIR = os.path.join(HOME, ".cache", "wal") CACHE_DIR = os.path.join(HOME, ".cache", "wal")
MODULE_DIR = os.path.dirname(__file__) MODULE_DIR = os.path.dirname(__file__)
CONF_DIR = os.path.join(HOME, ".config", "wal") CONF_DIR = os.path.join(HOME, ".config", "wal")
CONF_FILE = os.path.join(CONF_DIR, "config.ini")
DEFAULT_CONF_FILE = os.path.join(MODULE_DIR, "config", "config.ini")
OS = platform.uname()[0] OS = platform.uname()[0]
if not os.path.isfile(CONF_FILE):
util.create_dir(CONF_DIR)
shutil.copy2(DEFAULT_CONF_FILE, CONF_DIR)
CONFIG = configparser.ConfigParser() CONFIG = configparser.ConfigParser()
CONFIG.read("/home/black/.config/wal/config.ini") CONFIG.read(CONF_FILE)