-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi3start
executable file
·43 lines (32 loc) · 990 Bytes
/
i3start
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
#!/usr/bin/zsh
set -ueo pipefail
CONFIG_DIR=${CONFIG_DIR:-~/.config/i3}
read -r -d '' USAGE << EOM || true
$(basename $0) [i3 STARTUP CONFIG FILE]
i3 STARTUP CONFIG FILE
Default config file is 'startup' in the \$CONFIG_DIR directory
Specify as absolute path ('\$CONFIG_DIR/startup') or path relative
to CONFIG_DIR ('startup')
Each line should be command to be sent to i3-msg, a comment (starts
with '#'), an include ('include some-other-file') or a blank line.
CONFIG_DIR = $CONFIG_DIR
EOM
usage.sh "$USAGE" $@ && exit
startupFile=${1:-startup}
if [[ ! $(realpath $startupFile) =~ "^$CONFIG_DIR" ]]; then
startupFile="$CONFIG_DIR/$startupFile"
fi
while IFS='' read -r line || [[ -n $line ]]; do
if [[ -n "$line" && "${line:0:1}" != '#' ]]; then
echo "Running: $line"
if [[ $line =~ "^include " ]]; then
file=$(echo $line | cut -c9-) # strip out include
$0 $file
else
i3-msg "$line"
sleep 0.3
fi
else
#echo "Skipping: $line"
fi
done < $startupFile