blob: 7462ed0e3afad6ca2a72c8e7f47f2fec1cf8838c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
From ee44b859003972275d8e469ab41b9900420295e0 Mon Sep 17 00:00:00 2001
From: Malte Rohde <malte.rohde@flavoursys.com>
Date: Fri, 9 Jan 2015 13:10:41 +0100
Subject: [PATCH] Store user configuration in appropriate config location.
So that the dynamic-colors source can live somewhere else
(e.g., /usr/local/dynamic-colors) and multiple users
can use the same script.
---
bin/dynamic-colors | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/bin/dynamic-colors b/bin/dynamic-colors
index a669221..5d6bce7 100755
--- a/bin/dynamic-colors
+++ b/bin/dynamic-colors
@@ -84,16 +84,27 @@ else
fi
COLORSCHEMES="${DYNAMIC_COLORS_ROOT}/colorschemes"
+if [ -z "${DYNAMIC_COLORS_HOME}" ]; then
+ if [ -d "${HOME}/.dynamic-colors" ] || [ -z "${XDG_CONFIG_HOME}" ]; then
+ DYNAMIC_COLORS_HOME="${HOME}/.dynamic-colors"
+ else
+ DYNAMIC_COLORS_HOME="${XDG_CONFIG_HOME}/dynamic-colors"
+ fi
+else
+ DYNAMIC_COLORS_HOME="${DYNAMIC_COLORS_HOME%/}"
+fi
+
write_colorscheme_name () {
- echo "$1" > "${DYNAMIC_COLORS_ROOT}/colorscheme"
+ [ ! -d "${DYNAMIC_COLORS_HOME}" ] && mkdir -p "${DYNAMIC_COLORS_HOME}"
+ echo "$1" > "${DYNAMIC_COLORS_HOME}/colorscheme"
}
load_colorscheme_name () {
- head -1 "${DYNAMIC_COLORS_ROOT}/colorscheme"
+ head -1 "${DYNAMIC_COLORS_HOME}/colorscheme"
}
init () {
- [ ! -f "${DYNAMIC_COLORS_ROOT}/colorscheme" ] && return
+ [ ! -f "${DYNAMIC_COLORS_HOME}/colorscheme" ] && return
colorscheme_name=$(load_colorscheme_name)
load_colorscheme "$colorscheme_name"
set_colors
@@ -142,8 +153,8 @@ audit () {
}
cycle() {
- if [ -f "${DYNAMIC_COLORS_ROOT}/colorscheme" ]; then
- current=`head -1 "${DYNAMIC_COLORS_ROOT}/colorscheme"`
+ if [ -f "${DYNAMIC_COLORS_HOME}/colorscheme" ]; then
+ current=$(load_colorscheme_name)
found=false
cd "$COLORSCHEMES"
for file in *.sh; do
|