···
1
1
+
This is free and unencumbered software released into the public domain.
2
2
+
3
3
+
Anyone is free to copy, modify, publish, use, compile, sell, or
4
4
+
distribute this software, either in source code form or as a compiled
5
5
+
binary, for any purpose, commercial or non-commercial, and by any
6
6
+
means.
7
7
+
8
8
+
In jurisdictions that recognize copyright laws, the author or authors
9
9
+
of this software dedicate any and all copyright interest in the
10
10
+
software to the public domain. We make this dedication for the benefit
11
11
+
of the public at large and to the detriment of our heirs and
12
12
+
successors. We intend this dedication to be an overt act of
13
13
+
relinquishment in perpetuity of all present and future rights to this
14
14
+
software under copyright law.
15
15
+
16
16
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
17
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
18
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
19
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
20
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
+
OTHER DEALINGS IN THE SOFTWARE.
23
23
+
24
24
+
For more information, please refer to <http://unlicense.org/>
···
1
1
+
# description
2
2
+
thm is a shell script that applies colors to a template file.
3
3
+
4
4
+
# usage
5
5
+
thm theme_name
6
6
+
7
7
+
the theme_name does not include the `.theme` at the end of the file.
8
8
+
9
9
+
# directories
10
10
+
By default, the config files will be searched for in `$XDG_CONFIG_HOME/thm` or `$HOME/.config/thm`.
11
11
+
The generated files will be placed in either `$XDG_CACHE_HOME/thm` or `$HOME/.cache/thm`. This can
12
12
+
be changed by setting the environment variables `THM_CONFIG_DIR` and `THM_DEST_DIR`. The dest dir
13
13
+
is cleared while running.
14
14
+
15
15
+
# inside config directory
16
16
+
The themes directory holds shell scripts defining the colors. These files should end with `.theme`
17
17
+
if they should be usable with thm. The templates directory holds files for generating the themes.
18
18
+
These files should end with `.template` The scripts directory holds files to be executed after thm
19
19
+
is finished generating all the files. These files should be executable in order for thm to launch
20
20
+
them. Examples of these files can be found in the examples directory of this repository.
···
1
1
+
#!/bin/sh
2
2
+
swaymsg reload
···
1
1
+
#!/bin/sh
2
2
+
3
3
+
bg_color='{bg_color}'
4
4
+
fg_color='{fg_color}'
5
5
+
6
6
+
color0='{color0}'
7
7
+
color1='{color1}'
8
8
+
color2='{color2}'
9
9
+
color3='{color3}'
10
10
+
color4='{color4}'
11
11
+
color5='{color5}'
12
12
+
color6='{color6}'
13
13
+
color7='{color7}'
14
14
+
15
15
+
color8='{color8}'
16
16
+
color9='{color9}'
17
17
+
color10='{color10}'
18
18
+
color11='{color11}'
19
19
+
color12='{color12}'
20
20
+
color13='{color13}'
21
21
+
color14='{color14}'
22
22
+
color15='{color15}'
···
1
1
+
# class border background text indicator child_border
2
2
+
client.focused #{color5} #{color13} #{bg_color} #{color5} #{color5}
3
3
+
client.focused_inactive #{color4} #{color12} #{bg_color} #{color4} #{color4}
4
4
+
client.unfocused #{color8} #{color8} #{bg_color} #{color8} #{color8}
5
5
+
client.urgent #{color1} #{color9} #{bg_color} #{color1} #{color1}
6
6
+
7
7
+
# set variables
8
8
+
set {
9
9
+
$bg_color {bg_color}
10
10
+
$fg_color {fg_color}
11
11
+
12
12
+
$color0 {color0}
13
13
+
$color1 {color1}
14
14
+
$color2 {color2}
15
15
+
$color3 {color3}
16
16
+
$color4 {color4}
17
17
+
$color5 {color5}
18
18
+
$color6 {color6}
19
19
+
$color7 {color7}
20
20
+
$color8 {color8}
21
21
+
$color9 {color9}
22
22
+
23
23
+
$color10 {color10}
24
24
+
$color11 {color11}
25
25
+
$color12 {color12}
26
26
+
$color13 {color13}
27
27
+
$color14 {color14}
28
28
+
$color15 {color15}
29
29
+
}
···
1
1
+
#!/bin/sh
2
2
+
3
3
+
bg_color="000000"
4
4
+
fg_color="ffffff"
5
5
+
6
6
+
color0="000000"
7
7
+
color1="800000"
8
8
+
color2="008000"
9
9
+
color3="808000"
10
10
+
color4="000080"
11
11
+
color5="800080"
12
12
+
color6="008080"
13
13
+
color7="c0c0c0"
14
14
+
color8="808080"
15
15
+
color9="ff0000"
16
16
+
color10="00ff00"
17
17
+
color11="ffff00"
18
18
+
color12="0000ff"
19
19
+
color13="ff00ff"
20
20
+
color14="00ffff"
21
21
+
color15="ffffff"
···
1
1
+
#!/bin/sh
2
2
+
3
3
+
bg_color="ffffff"
4
4
+
fg_color="000000"
5
5
+
6
6
+
color0="ffffff"
7
7
+
color1="800000"
8
8
+
color2="008000"
9
9
+
color3="808000"
10
10
+
color4="000080"
11
11
+
color5="800080"
12
12
+
color6="008080"
13
13
+
color7="808080"
14
14
+
color8="c0c0c0"
15
15
+
color9="ff0000"
16
16
+
color10="00ff00"
17
17
+
color11="ffff00"
18
18
+
color12="0000ff"
19
19
+
color13="ff00ff"
20
20
+
color14="00ffff"
21
21
+
color15="000000"
···
1
1
+
#!/bin/sh
2
2
+
bg_color="efefef"
3
3
+
fg_color="1f1f1f"
4
4
+
5
5
+
color0="efefef"
6
6
+
color1="b0b0b0"
7
7
+
color2="9d9d9d"
8
8
+
color3="8a8a8a"
9
9
+
color4="787878"
10
10
+
color5="656565"
11
11
+
color6="525252"
12
12
+
color7="3f3f3f"
13
13
+
color9="808080"
14
14
+
color8="bfbfbf"
15
15
+
color10="707070"
16
16
+
color11="606060"
17
17
+
color12="505050"
18
18
+
color13="3f3f3f"
19
19
+
color14="2f2f2f"
20
20
+
color15="1f1f1f"
···
1
1
+
#!/bin/sh
2
2
+
3
3
+
bg_color="efefef"
4
4
+
fg_color="1f1f1f"
5
5
+
6
6
+
color0="efefef"
7
7
+
color1="e67b7b"
8
8
+
color2="80ba63"
9
9
+
color3="f5a868"
10
10
+
color4="849ce6"
11
11
+
color5="b37fe3"
12
12
+
color6="6ebdc4"
13
13
+
color7="3f3f3f"
14
14
+
color8="b0b0b0"
15
15
+
color9="ed9a9a"
16
16
+
color10="a3d989"
17
17
+
color11="f7c297"
18
18
+
color12="a6baf5"
19
19
+
color13="d1adf2"
20
20
+
color14="bedcde"
21
21
+
color15="1f1f1f"
···
1
1
+
#!/bin/sh
2
2
+
# shellcheck disable=SC1090,SC2154
3
3
+
4
4
+
# Usage statement
5
5
+
usage() {
6
6
+
printf '%s\n' "usage: ${0##*/} theme"
7
7
+
}
8
8
+
9
9
+
# Convert hex colors into rgb
10
10
+
hex2rgb() {
11
11
+
hex=$1
12
12
+
hex_r=${hex%????}
13
13
+
hex_g=${hex#??}
14
14
+
hex_g=${hex_g%??}
15
15
+
hex_b=${hex%????}
16
16
+
printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b"
17
17
+
}
18
18
+
19
19
+
# Set directory variables
20
20
+
[ "$THM_CONFIG_DIR" ] \
21
21
+
&& conf_dir="$THM_CONFIG_DIR" \
22
22
+
|| conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm"
23
23
+
[ "$THM_DEST_DIR" ] \
24
24
+
&& conf_dir="$THM_DEST_DIR" \
25
25
+
|| dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm"
26
26
+
27
27
+
err() {
28
28
+
[ "$*" ] && err_msg="$*" || err_msg="error"
29
29
+
printf '%s%b' "${0##*/}: " "$err_msg\n" 1>&2
30
30
+
exit 1
31
31
+
}
32
32
+
33
33
+
# Ensure the theme file exist and source it
34
34
+
case $1 in
35
35
+
-h|h|--help|help ) usage; exit 0 ;;
36
36
+
* ) [ "$1" ] || err "missing argument"
37
37
+
[ -f "$conf_dir/themes/$1.theme" ] || err "$1: theme not found"
38
38
+
theme_file="$conf_dir/themes/$1.theme"
39
39
+
. "$theme_file" ;;
40
40
+
esac
41
41
+
42
42
+
# Create RGB colors from the hex colors
43
43
+
bg_color_rgb="$(hex2rgb "$bg_color")"
44
44
+
fg_color_rgb="$(hex2rgb "$fg_color")"
45
45
+
color0_rgb="$(hex2rgb "$color0")"
46
46
+
color1_rgb="$(hex2rgb "$color1")"
47
47
+
color2_rgb="$(hex2rgb "$color2")"
48
48
+
color3_rgb="$(hex2rgb "$color3")"
49
49
+
color4_rgb="$(hex2rgb "$color4")"
50
50
+
color5_rgb="$(hex2rgb "$color5")"
51
51
+
color6_rgb="$(hex2rgb "$color6")"
52
52
+
color7_rgb="$(hex2rgb "$color7")"
53
53
+
color8_rgb="$(hex2rgb "$color8")"
54
54
+
color9_rgb="$(hex2rgb "$color9")"
55
55
+
color10_rgb="$(hex2rgb "$color10")"
56
56
+
color11_rgb="$(hex2rgb "$color11")"
57
57
+
color12_rgb="$(hex2rgb "$color12")"
58
58
+
color13_rgb="$(hex2rgb "$color13")"
59
59
+
color14_rgb="$(hex2rgb "$color14")"
60
60
+
color15_rgb="$(hex2rgb "$color15")"
61
61
+
62
62
+
# Make sure the dest_dir exist
63
63
+
[ -d "$dest_dir" ] || { mkdir -p "$dest_dir" || err "failed to create $dest_dir"; }
64
64
+
65
65
+
# Ensure the dest_dir is empty before populating it
66
66
+
rm "$dest_dir/"*
67
67
+
68
68
+
# Make a file with the name of the new theme
69
69
+
printf '%s\n' "$theme_file" > "$dest_dir/current_thm"
70
70
+
71
71
+
# Repalce template syntax with the actual colors
72
72
+
for t in "${conf_dir}/templates/"*".template"
73
73
+
do
74
74
+
file_name=${t##*/}
75
75
+
file_name=${file_name%.template}
76
76
+
77
77
+
sed "
78
78
+
s/{bg_color}/$bg_color/g
79
79
+
s/{fg_color}/$fg_color/g
80
80
+
s/{color0}/$color0/g
81
81
+
s/{color1}/$color1/g
82
82
+
s/{color2}/$color2/g
83
83
+
s/{color3}/$color3/g
84
84
+
s/{color4}/$color4/g
85
85
+
s/{color5}/$color5/g
86
86
+
s/{color6}/$color6/g
87
87
+
s/{color7}/$color7/g
88
88
+
s/{color8}/$color8/g
89
89
+
s/{color9}/$color9/g
90
90
+
s/{color10}/$color10/g
91
91
+
s/{color11}/$color11/g
92
92
+
s/{color12}/$color12/g
93
93
+
s/{color13}/$color13/g
94
94
+
s/{color14}/$color14/g
95
95
+
s/{color15}/$color15/g
96
96
+
s/{bg_color.rgb}/$bg_color_rgb/g
97
97
+
s/{fg_color.rgb}/$fg_color_rgb/g
98
98
+
s/{color0.rgb}/$color0_rgb/g
99
99
+
s/{color1.rgb}/$color1_rgb/g
100
100
+
s/{color2.rgb}/$color2_rgb/g
101
101
+
s/{color3.rgb}/$color3_rgb/g
102
102
+
s/{color4.rgb}/$color4_rgb/g
103
103
+
s/{color5.rgb}/$color5_rgb/g
104
104
+
s/{color6.rgb}/$color6_rgb/g
105
105
+
s/{color7.rgb}/$color7_rgb/g
106
106
+
s/{color8.rgb}/$color8_rgb/g
107
107
+
s/{color9.rgb}/$color9_rgb/g
108
108
+
s/{color10.rgb}/$color10_rgb/g
109
109
+
s/{color11.rgb}/$color11_rgb/g
110
110
+
s/{color12.rgb}/$color12_rgb/g
111
111
+
s/{color13.rgb}/$color13_rgb/g
112
112
+
s/{color14.rgb}/$color14_rgb/g
113
113
+
s/{color15.rgb}/$color15_rgb/g
114
114
+
" "$t" > "${dest_dir}/${file_name}"
115
115
+
done
116
116
+
117
117
+
# Run extra user scripts
118
118
+
[ -d "$conf_dir/scripts" ] || return 0
119
119
+
for i in "$conf_dir/scripts/"*
120
120
+
do
121
121
+
[ -x "$i" ] && $i > /dev/null 2>&1 &
122
122
+
done