aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
blob: 1d70729d6984ffc796f2378cea65ecd1359a7505 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash

URL="https://git.sr.ht/~heckyel/i3-config"

while true
do
    function _copy_i3_config() {
        # check root
        if [[ "$UID" == 0 ]]; then
            root_key=''
        elif [[ $(command -v sudo) ]]; then
            root_key=sudo
        elif [[ $(command -v doas) ]]; then
            root_key=doas
        fi
        ## Install dependencies
        if [[ $(command -v pacman) ]]; then
            $root_key pacman -Syy --noconfirm
            # i3 base
            $root_key pacman -S --noconfirm i3-wm i3status dmenu sysstat
            # i3 blocks and dependecies
            $root_key pacman -S --noconfirm i3blocks rofi \
                      conky acpi scrot st sakura feh ranger bubblewrap \
                      ttf-hack xenocara-xbacklight xdg-user-dirs
        fi

        # Install i3config
        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Cloning i3-config...' '\e[m'
        git clone "$URL" "/tmp/i3config/" --depth=1

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying images...' '\e[m'
        install -d -m755 "$HOME/.config/i3/images"
        for i in background.png; do
            install -m644 -v "/tmp/i3config/images/$i" "$HOME/.config/i3/images/$i"
        done

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying scripts...' '\e[m'
        cp -rv /tmp/i3config/scripts "$HOME/.config/i3/"

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying i3-config...' '\e[m'
        for i in config i3blocks.conf; do
            install -m644 -v "/tmp/i3config/$i" "$HOME/.config/i3/$i"
        done

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying conky...' '\e[m'
        install -d -m755 "$HOME/.config/conky/"
        install -m644 -v /tmp/i3config/extra/conky.conf "$HOME/.config/conky/"

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying bubblewrap scripts...' '\e[m'
        install -d -m755 "$HOME/.config/bwrap/"
        for i in /tmp/i3config/bwrap/*.bash; do
            install -m644 -v "$i" "$HOME/.config/bwrap/"
        done

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying FontAwesome...' '\e[m'
        install -d -m755 "$HOME/.local/share/fonts/"
        for i in /tmp/i3config/fonts/*.ttf; do
            install -m644 -v "$i" "$HOME/.local/share/fonts/"
        done

        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Make log directory...' '\e[m'
        install -d -m755 "$HOME/.config/i3/logs/"

        # clean up temp files
        rm -rf /tmp/i3config/

        # update xdg-user-dirs
        printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Run xdg-user-dirs-update...' '\e[m'
        $(command -v xdg-user-dirs-update) && xdg-user-dirs-update
    }

    case  ${LANG/_*/} in
        es)
            read -r -p "¿Estás seguro de instalar i3config? [S/n]: " input
            case $input in
                [sS]|"") _copy_i3_config "$@"; break ;;
                [nN]) break ;;
                *) echo "Por favor responde sí o no" ;;
            esac
            ;;
        *)
            read -r -p "Are you sure to install i3config? [Y/n]: " input
            case $input in
                [yY]|"") _copy_i3_config "$@"; break ;;
                [nN]) break ;;
                *) echo "Please answer yes or no.";;
            esac
            ;;
    esac
done

unset URL