From 50d8a44a6de0efb51827c2190e8da9e30d6b071d Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 1 Apr 2016 09:47:48 +1100 Subject: [PATCH] Don't hardcode '/home/dyl/.config', use '' if available --- config/config | 3 +-- neofetch | 33 +++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config/config b/config/config index 9b6b8030..e79ff051 100644 --- a/config/config +++ b/config/config @@ -7,7 +7,6 @@ # Speed up script by not using unicode export LC_ALL=C export LANG=C -export LANGUAGE=C # Info Options {{{ @@ -395,7 +394,7 @@ config="on" # Path to custom config file location # --config path/to/config -config_file="$HOME/.config/neofetch/config" +config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/neofetch/config" # }}} diff --git a/neofetch b/neofetch index 21a50ea1..7a61090d 100755 --- a/neofetch +++ b/neofetch @@ -22,8 +22,9 @@ # Created by Dylan Araps # https://github.com/dylanaraps/ -version=${BASH_VERSION/.*} +version="${BASH_VERSION/.*}" SYS_LOCALE="${LANG:-C}" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" # Speed up script by not using unicode export LC_ALL=C @@ -420,7 +421,7 @@ config="on" # Path to custom config file location # --config path/to/config -config_file="$HOME/.config/neofetch/config" +config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/neofetch/config" # }}} @@ -860,7 +861,7 @@ getwmtheme () { 'Openbox') [ -f "${HOME}/.config/openbox/rc.xml" ] && \ - wmtheme="$(awk -F "[<,>]" '/]" '//dev/null 2>&1; then gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)" @@ -1843,7 +1844,7 @@ getwallpaper () { img="$(awk -F\' '/feh/ {printf $2}' "$HOME/.fehbg")" elif type -p nitrogen >/dev/null 2>&1; then - img="$(awk -F'=' '/file/ {printf $2;exit;}' "$HOME/.config/nitrogen/bg-saved.cfg")" + img="$(awk -F'=' '/file/ {printf $2;exit;}' "$XDG_CONFIG_HOME/nitrogen/bg-saved.cfg")" elif type -p gsettings >/dev/null 2>&1; then case "$XDG_CURRENT_DESKTOP" in @@ -2492,26 +2493,26 @@ getconfig () { source "$config_file" return fi - mkdir -p "$HOME/.config/neofetch/" + mkdir -p "$XDG_CONFIG_HOME/neofetch/" - # Check $HOME/.config/neofetch and create the + # Check $XDG_CONFIG_HOME/neofetch and create the # dir/files if they don't exist. - if [ -f "$HOME/.config/neofetch/config" ]; then - source "$HOME/.config/neofetch/config" + if [ -f "$XDG_CONFIG_HOME/neofetch/config" ]; then + source "$XDG_CONFIG_HOME/neofetch/config" elif [ -f "/usr/share/neofetch/config" ]; then - cp "/usr/share/neofetch/config" "$HOME/.config/neofetch" - source "$HOME/.config/neofetch/config" + cp "/usr/share/neofetch/config" "$XDG_CONFIG_HOME/neofetch" + source "$XDG_CONFIG_HOME/neofetch/config" elif [ -f "/usr/local/share/neofetch/config" ]; then - cp "/usr/local/share/neofetch/config" "$HOME/.config/neofetch" - source "$HOME/.config/neofetch/config" + cp "/usr/local/share/neofetch/config" "$XDG_CONFIG_HOME/neofetch" + source "$XDG_CONFIG_HOME/neofetch/config" else getscriptdir - cp "$script_dir/config/config" "$HOME/.config/neofetch" - source "$HOME/.config/neofetch/config" + cp "$script_dir/config/config" "$XDG_CONFIG_HOME/neofetch" + source "$XDG_CONFIG_HOME/neofetch/config" fi }