summaryrefslogtreecommitdiff
path: root/install.sh
blob: 3170868ba7b18ce83a8d15761e9beef5e78fcf82 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/bash

SRCDIR="$HOME/.local/src/"

rm ~/.config/mimeapps.list
rm ~/.local/share/wallpapers/bg
mkdir -p "$SRCDIR"

sudo apt-get -y install stow
stow $(ls -d */)

ln -sf ~/.local/share/wallpapers/mountains.jpg ~/.local/share/wallpapers/bg

# update nvim plugins
nvim +'hi NormalFloat guibg=#1e222a' +PackerSync

# yes/no dialog
# https://gist.github.com/davejamesmiller/1965569
ask() {
    local prompt default reply

    if [[ ${2:-} = 'Y' ]]; then
        prompt='Y/n'
        default='Y'
    elif [[ ${2:-} = 'N' ]]; then
        prompt='y/N'
        default='N'
    else
        prompt='y/n'
        default=''
    fi

    while true; do

        # Ask the question (not using "read -p" as it uses stderr not stdout)
        echo -n "$1 [$prompt] "

        # Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
        read -r reply </dev/tty

        # Default?
        if [[ -z $reply ]]; then
            reply=$default
        fi

        # Check if the reply is valid
        case "$reply" in
            Y*|y*) return 0 ;;
            N*|n*) return 1 ;;
        esac

    done
}


# Update Make Install
umi() { \
    if [[ ! -d "$SRCDIR/$1" ]]; then
        echo "$1 not found, skipping"
        return
    fi

    branch=${2:-master}
    echo "[UPDATE] $1 $branch"
    cd "$SRCDIR/$1"
    git pull
    git checkout "$branch"
    make -j
    if [ -z "$3" ]; then
        sudo checkinstall --nodoc -y sudo make install
    else
        sudo checkinstall --nodoc -y sudo make "$3" install
    fi
}

umi_pamixer() { \
    if [[ ! -d "$SRCDIR/pamixer" ]]; then
        echo "pamixer not found, skipping"
        return
    fi
    cd "$SRCDIR/pamixer"
    git pull
    meson setup build
    meson compile -C build
    sudo meson install -C build
}

umi_digimend() { \
    if [[ ! -d "$SRCDIR/digimend-kernel-drivers" ]]; then
        echo "digimend not found, skipping"
        return
    fi
    cd "$SRCDIR/digimend-kernel-drivers"
    git pull
    # TODO is it necessary to uninstall?
    sudo make dkms_uninstall
    sudo make dkms_install
}

umi_xournalpp() { \
    if [[ ! -d "$SRCDIR/xournalpp" ]]; then
        echo "xournalpp not found, skipping"
        return
    fi
    cd "$SRCDIR/xournalpp"
    mkdir build ; cd build
    rm -rf packages
    cmake ..
    cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo --build . -- -j 6
    cmake --build . --target translations -- -j 6
    cmake .. -DCPACK_GENERATOR="DEB"
    cmake --build . --target package -- -j 6
    cd packages
    sudo dpkg -i xournalpp*
}

umi_oomox() { \
    if [[ ! -d "$SRCDIR/oomox" ]]; then
        echo "oomox not found, skipping"
        return
    fi
    cd "$SRCDIR/oomox"
    make -f po.mk install
}

umi_all() { \
    umi "ly"
    umi "dwm" "patched-config"
    umi "dwmblocks"
    umi "st"
    umi "neovim"
    umi "nnn" "master" "strip"
    umi "devour"
    umi "dragon"

    umi_pamixer
    umi_digimend
    umi_xournalpp
    umi_oomox
}

if [ "$1" = "-i" ]; then
    # system
    #dbus-x11 -> dbus-broker
    sudo apt-get install xserver-xorg dbus-broker lm-sensors xclip python2 python3 python3-pip gdebi virtualenv gawk xdotool zsh libnotify-bin jmtpfs maim xfce4-power-manager redshift i3lock dmenu suckless-tools pass git trash-cli htop network-manager rsync ncdu shellcheck
    python3 -m pip install --user --upgrade pynvim
    # media
    sudo apt-get install alsa-tools sxiv mpv ncmpcpp mpd mpv ffmpeg syncthing playerctl fzf
    # TODO migrate to pipewire for good
    sudo apt-get install pulseaudio
    # sudo apt-get install pipewire wireplumber pipewire-pulse
    sudo apt-get install pulseeffects
    # web
    sudo apt-get install firefox
    sudo apt-get install chromium
    sudo apt-get install thunderbird
    # office
    sudo apt-get install git unrar unzip p7zip-full zathura zathura-pdf zathura-ps texlive latexmk virt-manager gnome-keyring
    # theming
    sudo apt-get install oxygen-icon-theme sox imagemagick lxappearance xwallpaper fonts-symbola fonts-liberation fonts-font-awesome compton dunst
    pip3 install pywal


    cd "$SRCDIR"

    # required for ly
    sudo apt-get install build-essential libpam0g-dev libxcb-xkb-dev
    git clone --recurse-submodules https://github.com/nullgemm/ly.git

    # required for st, dwm and dwmblocks
    sudo apt-get install libfontconfig-dev libx11-dev libxft-dev
    # required for dwm
    sudo apt-get install libx11-xcb-dev libxcb-res0-dev
    git clone https://github.com/ivan-boikov/dwm
    git clone https://github.com/ivan-boikov/dwmblocks
    git clone https://github.com/lukesmithxyz/st

    # required for neovim
    sudo apt-get install ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip curlgit
    clone https://github.com/neovim/neovim
    git clone https://github.com/jarun/nnn

    # required for pamixer
    sudo apt-get install meson libboost-dev libpulse0 libpulse-dev
    git clone https://github.com/cdemoulins/pamixer

    # required for devour
    sudo apt-get install libx11-dev
    # is it necessary with dwm swallow patch?
    git clone https://github.com/salman-abedin/devour

    # dragon
    sudo apt-get install libgtk-3-dev
    git clone https://github.com/mwh/dragon

    # digimend drivers
    if ask "Install DIGImend drivers?"; then
        cd "$SRCDIR"
        sudo apt-get install "linux-headers-$(uname -r)"
        git clone https://github.com/DIGImend/digimend-kernel-drivers
    fi

    # xournalpp
    if ask "Install xournalpp?"; then
        sudo apt-get install "linux-headers-$(uname -r)" dkms
        sudo apt-get install cmake libgtk-3-dev libpoppler-glib-dev portaudio19-dev libsndfile-dev libcppunit-dev dvipng texlive libxml2-dev liblua5.3-dev libzip-dev librsvg2-dev gettext lua-lgi
        cd "$SRCDIR"
        git clone https://github.com/xournalpp/xournalpp
    fi

    # required for nnn
    sudo apt-get install pkg-config libncursesw5-dev libreadline-dev

    # required for oomox
    if ask "Install oomox theming engine?"; then
        sudo apt-get install python3-gi python3-gi-cairo libglib2.0-bin libgdk-pixbuf2.0-dev libxml2-utils x11-xserver-utils gir1.2-gtk-3.0 gir1.2-glib-2.0 gir1.2-pango-1.0 gir1.2-gdkpixbuf-2.0 gtk2-engines gtk2-engines-murrine gtk2-engines-pixbuf bash bc sed grep parallel sassc libsass1 imagemagick optipng librsvg2-bin inkscape python3-pillow python3-pystache python3-yaml make automake libgtk-3-dev
        cd "$SRCDIR"
        git clone https://github.com/themix-project/oomox --recursive
    fi

    umi_all

    # cleaning Firefox, schizo-style
    # https://12bytes.org/articles/tech/firefox/firefoxgecko-configuration-guide-for-privacy-and-performance-buffs/
    if ask "Schizofy firefox?"; then
        sudo cd /usr/lib/firefox/browser/features
        sudo rm *.xpi

        cp -r ~/.mozilla ~/.mozilla.bak

        cd ~/.mozilla
        FFPATH=$(dirname $(find ~/.mozilla -wholename "*release/prefs.js"));
        cd "$FFPATH"
        rm -f updater.sh prefsCleaner.sh user-overrides.js
        wget https://raw.githubusercontent.com/arkenfox/user.js/master/updater.sh
        wget https://raw.githubusercontent.com/arkenfox/user.js/master/prefsCleaner.sh
        wget https://raw.githubusercontent.com/ivan-boikov/user-overrides.js/master/user-overrides.js
        chmod +x updater.sh
        chmod +x prefsCleaner.sh
        bash updater.sh
        bash prefsCleaner.sh
    fi
fi

if [ "$1" = "-u" ]; then
    umi_all
fi