Compare commits

..

1 Commits

Author SHA1 Message Date
Kai S. K. Engelbart 42692aa969
Use XDG config directory
In addition, extracted some file paths into variables.
2021-08-16 12:57:45 +02:00
1 changed files with 9 additions and 9 deletions

View File

@ -3,22 +3,22 @@
# Simple CLI to make wallpaper changes with xwallpaper more comfortable
CONF_DIR=${XDG_CONFIG_HOME:-~/.config}/paperchanger
CONF_CURRENT_WP="${CONF_DIR}/current_wallpaper.txt"
CONF_PATH="${CONF_DIR}/paperchanger.conf.sh"
CONF_CURRENT_WP=${CONF_DIR}/current_wallpaper.txt
CONF_PATH=${CONF_DIR}/paperchanger.conf.sh
mkdir -p ${CONF_DIR}
if [[ ! -f "${CONF_DIR}" ]]; then
touch "${CONF_DIR}"
if [[ ! -f ${CONF_DIR} ]]; then
touch ${CONF_DIR}
fi
if [[ ! -f "${CONF_PATH}" ]]; then
if [[ ! -f ${CONF_PATH} ]]; then
echo '# This is the configuration file used by the paperchanger program
default_directory=' > "${CONF_DIR}/paperchanger.conf.sh"
default_directory=' > ${CONF_DIR}/paperchanger.conf.sh
fi
read -r current_file_path < "${CONF_CURRENT_WP}"
read -r current_file_path < ${CONF_CURRENT_WP}
source "${CONF_CURRENT_WP}"
function _help() {
@ -44,11 +44,11 @@ function _display() {
function _set() {
current_file_path="$1"
echo "$current_file_path" > "${CONF_CURRENT_WP}"
echo "$current_file_path" > ${CONF_CURRENT_WP}
}
function _change_config_path() {
sed -i "s/^default_directory=.*\$/default_directory=${1//\//\\/}/" "${CONF_PATH}"
sed -i "s/^default_directory=.*\$/default_directory=${1//\//\\/}/" ${CONF_PATH}
}
case "$#" in