-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·51 lines (46 loc) · 1.61 KB
/
install
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
#! /bin/sh
src_dir="$( dirname "$( realpath $0)")"
if [ -n "$XDG_CONFIG_DIR" ]; then
echo "-> \$XDG_CONFIG_DIR was found"
inst_dir="$XDG_CONFIG_DIR/i3"
else
echo "-> ~/.config/i3 by default, press enter to accept"
echo -n "Config directory:"
read inst_dir
[ "$inst_dir" ] || inst_dir="$HOME/.config/i3"
fi
echo "Installing to $inst_dir"
if [ -d $inst_dir ]; then
echo -n "Directory exists, backing up..."
mv -i "$inst_dir" "$inst_dir.old" && echo "Done"
fi
mkdir --parents "$inst_dir" && echo "Created path $inst_dir"
if ! { echo "$PATH" | grep -q "$HOME/.local/bin"; }; then
echo "-> ~./local/bin was not found in \$PATH!"
echo -n "Continue? [y|N] "
read answ_scr_pth
case "$answ_scr_pth" in
y) ;;
n) exit 1 ;;
*) exit 1 ;;
esac
fi
echo "Link config to git files?[y/n]"
read answ_config
echo "Link scripts to git files?[y/n]"
read answ_scripts
case "$answ_config" in
y) echo -n "Linking config..."
ln --symbolic "$src_dir/config" "$inst_dir/config" && echo "Done";;
n) echo -n "Copying config..."
cp --interactive "$src_dir/config" "$inst_dir/config" && echo "Done";;
*) exit 1 ;;
esac
case "$answ_scripts" in
3-msg -t get_tree| jq --compact-output -Mr ".. | objects | select(.focused == true) |.window_properties| [.instance, .title] | @tsv" y) echo -n "Linking scripts..."
ln --symbolic --target-directory="$HOME/.local/bin" $src_dir/scripts/* && echo "Done";;
n) echo -n "Copying scripts..."
cp --interactive $src_dir/scripts/* "$HOME/.local/bin" && echo "Done";;
*) exit 1 ;;
esac
echo "Done"