-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreate_config
executable file
·48 lines (39 loc) · 1.12 KB
/
create_config
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
#!/bin/bash
i3_folder="$HOME/.i3"
i3_config_file="$i3_folder/config"
i3_config_dir="$i3_folder/config.d"
i3_includes_file="$i3_config_dir/i3_configs.conf"
if [[ -f "$i3_includes_file" ]]; then
[[ -f "$i3_config_file" ]] && rm "$i3_config_file"
touch "$i3_config_file"
echo "#### DO NOT EDIT THIS FILE, IT IS GENERATED." >> "$i3_config_file"
echo "#### EDIT THE FILES HERE: $i3_folder/config.d/**/*" >> "$i3_config_file"
include_file() {
cat "$i3_config_dir/$1" >> "$i3_config_file"
}
get_file_name_from_line () {
stripped_file_name=$(echo $* | sed 's/\(import \)\(.*.conf\)\(;\)/\2/')
echo "$stripped_file_name"
}
exec 3< "$i3_includes_file"
until [ "$done" ]
do
read <&3 config_line
if [ $? != 0 ]; then
done=1
continue
else
if [[ "$config_line" == "import "* ]]; then
file_name="$(get_file_name_from_line $config_line)"
include_file "$file_name"
fi
fi
done
if [[ "$1" == "restart" || "$1" == "reload" ]]; then
i3-msg "$1"
fi
else
echo "ERROR:"
echo "Please create the configs import file:"
echo " $i3_config_dir/i3_configs.conf"
fi