2017-02-12 11:41:03 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Installs user preferences the way I like it
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
function prompt { # text
|
|
|
|
while true; do
|
|
|
|
read -p "$1 [yn] " yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]* ) return 1;;
|
|
|
|
[Nn]* ) return 0;;
|
|
|
|
* ) echo "Please answer yes or no.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't ask for things that are already there
|
2017-03-27 10:03:44 +02:00
|
|
|
TERMUX=0
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ -d /data/data/com.termux/files ]; then
|
2017-03-27 10:03:44 +02:00
|
|
|
TERMUX=1
|
|
|
|
GUI=0
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if which i3 &> /dev/null; then
|
2017-03-27 10:03:44 +02:00
|
|
|
GUI=1
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $ADMIN ]; then
|
|
|
|
prompt "Are you a superuser on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
ADMIN=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
if [ -z $GUI ]; then
|
|
|
|
prompt "Do you want a X environment on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
GUI=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
if [ -z $EXTRA ]; then
|
|
|
|
prompt "Do you want not-so-needed software on this machine?"
|
2017-03-27 10:03:44 +02:00
|
|
|
EXTRA=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# TODO Verify if the package exists before installing it
|
|
|
|
|
|
|
|
# System detection
|
|
|
|
if which pacman &> /dev/null; then
|
|
|
|
ARCH=1
|
|
|
|
if [ $ADMIN == 1 ]; then
|
|
|
|
sudo pacman -Sy
|
|
|
|
function installOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
2017-07-26 04:34:10 +02:00
|
|
|
sudo pacman -S $1 --noconfirm --needed
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
function installFileOne { # file
|
|
|
|
sudo pacman -U "$1"
|
|
|
|
}
|
2018-10-06 10:27:36 +02:00
|
|
|
if which aurman &> /dev/null; then
|
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
aurman -S "$1" --noconfirm --noedit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
elif which pacaur &> /dev/null; then
|
2017-11-02 16:48:43 +01:00
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
pacaur -S "$1" --noconfirm --noedit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
elif which yaourt &> /dev/null; then
|
2017-02-12 11:41:03 +01:00
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
yaourt -S "$1" --noconfirm
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
else
|
|
|
|
# Install package from PKGBUILD file
|
|
|
|
function installPKGBUILD { # url
|
|
|
|
TMP_DIR="$(mktemp -d /tmp/pkgbuild.XXXXXXXXXX)"
|
|
|
|
cd "$TMP_DIR"
|
|
|
|
wget "$1" -O PKGBUILD
|
|
|
|
makepkg -si
|
|
|
|
cd -
|
|
|
|
rm -rf "$TMP_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
function altInstallOne { # package
|
|
|
|
pacman -Q $1 &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "You're on a Arch System but it's not yours? Did Arch got that popular?"
|
|
|
|
return 42
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif which dpkg &> /dev/null; then
|
|
|
|
DEBIAN=1
|
|
|
|
if [[ $ADMIN == 1 || $TERMUX == 1 ]]; then
|
|
|
|
if [ $TERMUX == 1 ]; then
|
|
|
|
DEBIAN=0
|
|
|
|
apt update -y
|
|
|
|
else
|
|
|
|
sudo apt-get update -y
|
|
|
|
fi
|
|
|
|
function installOne { # package
|
|
|
|
|
|
|
|
# Finding out if it's already installed or not
|
|
|
|
STATUS=$(mktemp)
|
|
|
|
LANG=C dpkg-query --status $1 &> $STATUS
|
2017-03-27 10:03:44 +02:00
|
|
|
installed=0
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $? == 0 ]; then
|
|
|
|
cat $STATUS | grep '^Status:' | grep ' installed' --quiet
|
|
|
|
if [ $? == 0 ]; then
|
|
|
|
installed=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rm -f $STATUS > /dev/null
|
|
|
|
|
|
|
|
# Installing if it's not installed
|
|
|
|
if [ $installed == 0 ]; then
|
|
|
|
# TODO noconfirm
|
|
|
|
if [ $TERMUX == 1 ]; then
|
|
|
|
apt install $1 -y
|
|
|
|
else
|
|
|
|
sudo apt-get install $1 -y
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function installFileOne { # file
|
|
|
|
dpkg -i "$1"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function installOne { # package
|
2017-02-12 13:29:03 +01:00
|
|
|
debloc install $1
|
2017-02-12 11:41:03 +01:00
|
|
|
}
|
|
|
|
function installFileOne { # file
|
2017-02-12 13:29:03 +01:00
|
|
|
debloc deb "$1"
|
2017-02-12 11:41:03 +01:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
function altInstallOne {
|
|
|
|
echo "[ERROR] There's no alternate installer for this distribution. Can't install $1."
|
|
|
|
}
|
|
|
|
else
|
|
|
|
echo "Uuuh, what kind of distribution is this?"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install package with the standard
|
|
|
|
# package manager for the distribution
|
|
|
|
function inst {
|
|
|
|
for pkg in $*; do
|
|
|
|
installOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install package FILE with the standard
|
|
|
|
# package manager for the distribution
|
|
|
|
function instFile {
|
|
|
|
for pkg in $*; do
|
|
|
|
installFileOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install package with the alternate
|
|
|
|
# package manager for the distribution
|
|
|
|
function altInst {
|
|
|
|
for pkg in $*; do
|
|
|
|
altInstallOne $pkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-03-19 07:29:56 +01:00
|
|
|
function systemdUserUnit {
|
2018-10-08 23:52:53 +02:00
|
|
|
systemctl --user enable "$1"
|
|
|
|
systemctl --user start "$1"
|
2018-03-19 07:29:56 +01:00
|
|
|
}
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
# Common CLI
|
|
|
|
|
2018-10-06 10:27:36 +02:00
|
|
|
changeColors monokai
|
2017-06-27 09:19:26 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Utils
|
|
|
|
if [ $TERMUX == 1 ]; then
|
2018-10-06 10:27:36 +02:00
|
|
|
inst coreutils man openssl-tool grep sed sh tar
|
2017-02-12 15:14:51 +01:00
|
|
|
inst termux-api
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $ADMIN == 1 ]; then
|
|
|
|
inst tsu
|
|
|
|
fi
|
|
|
|
fi
|
2018-06-24 18:27:20 +02:00
|
|
|
inst moreutils screen ncdu lsof htop proxytunnel pv curl wget netcat mosh bash-completion rsync pwgen fzf highlight
|
|
|
|
# TODO Test those who are on Debian machines and those who aren't
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $ARCH == 1 ]; then
|
2018-10-06 10:27:36 +02:00
|
|
|
inst bash-completion
|
2017-11-02 16:48:43 +01:00
|
|
|
altInst gopass
|
2017-02-12 11:41:03 +01:00
|
|
|
else
|
|
|
|
inst pass
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Dev
|
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst build-essential
|
|
|
|
elif [ $ARCH == 1 ]; then
|
|
|
|
inst base-devel
|
|
|
|
else
|
|
|
|
inst make
|
|
|
|
fi
|
2018-10-06 10:27:36 +02:00
|
|
|
inst git
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Text editor
|
2018-10-06 10:27:36 +02:00
|
|
|
inst neovim
|
|
|
|
if [ $DEBIAN == 1]; then
|
|
|
|
inst python-neovim pyhon3-neovim
|
|
|
|
elif [ $ARCH == 1]; then
|
|
|
|
inst python2-neovim python-neovim
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
2018-10-06 10:27:36 +02:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $DEBIAN == 1 ]; then
|
|
|
|
inst exuberant-ctags
|
|
|
|
else
|
|
|
|
inst ctags
|
|
|
|
fi
|
2018-06-24 18:27:20 +02:00
|
|
|
vim +PlugUpgrade +PlugUpdate +PlugInstall +qall
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
# Common GUI
|
|
|
|
if [ $GUI == 1 ]; then
|
2018-06-24 18:27:20 +02:00
|
|
|
.Xresources.d/configure
|
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Desktop manager
|
2018-10-06 10:27:36 +02:00
|
|
|
inst dunst feh i3-wm i3lock numlockx qutebrowser rofi rxvt-unicode scrot trayer unclutter xautolock xclip
|
2017-07-02 22:06:24 +02:00
|
|
|
if [ $ARCH == 1 ]; then
|
2018-10-14 16:59:49 +02:00
|
|
|
inst xorg-xinit xorg-xbacklight ttf-dejavu
|
2018-10-06 10:27:36 +02:00
|
|
|
altInst lemonbar-xft-git autorandr-git keynav-enhanced pacmixer rofi-pass
|
|
|
|
elif [ $DEBIAN == 1 ]; then
|
2018-10-14 16:59:49 +02:00
|
|
|
# TODO autorandr pacmixer rofi-pass ttf-dejavu
|
2018-10-06 10:27:36 +02:00
|
|
|
inst lemonbar keynav xbacklight
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Screen filter
|
|
|
|
if [ $ARCH == 1 ]; then
|
|
|
|
altInst sct
|
2017-02-12 13:29:03 +01:00
|
|
|
elif [ $TERMUX != 1 ]; then
|
2018-08-19 11:29:59 +02:00
|
|
|
if [ ! -f $HOME/.local/bin/sct ]; then
|
2017-09-20 11:47:30 +02:00
|
|
|
TMP=$(mktemp /tmp/XXXXXXXXXX.c)
|
|
|
|
wget https://gist.githubusercontent.com/ajnirp/208c03d3aa7f02c743d2/raw/55bf3eed25739173d8be57b5179ed5542cf40ed6/sct.c -O $TMP
|
2018-08-19 11:29:59 +02:00
|
|
|
cc $TMP --std=c99 -lX11 -lXrandr -o $HOME/.local/bin/sct
|
2017-09-01 18:39:06 +02:00
|
|
|
rm $TMP
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-03-19 07:29:56 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $EXTRA == 1 ]; then
|
2018-10-06 10:27:36 +02:00
|
|
|
# Extra dev (not on mobile though ^^)
|
|
|
|
if [ $TERMUX == 0 ]; then
|
2018-10-14 16:59:49 +02:00
|
|
|
inst cmake clang llvm ccache python-pip gdb
|
2018-10-06 10:27:36 +02:00
|
|
|
fi
|
2017-02-12 13:29:03 +01:00
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Extra CLI
|
2018-10-18 21:14:11 +02:00
|
|
|
inst ffmpeg optipng syncthing mutt msmtp notmuch mbsync jq lynx
|
2018-10-14 16:59:49 +02:00
|
|
|
inst unzip unrar jdupes bedup p7zip
|
|
|
|
inst youtube-dl megatools speedtest-cli
|
2018-10-06 10:27:36 +02:00
|
|
|
systemdUserUnit syncthing
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ $ARCH == 1 ]; then
|
2018-10-08 23:52:53 +02:00
|
|
|
insta pandoc youtube-dl translate-shell imagemagick
|
2018-10-06 10:27:36 +02:00
|
|
|
altInst insect pdftk visidata
|
2018-03-19 07:29:56 +01:00
|
|
|
|
|
|
|
# Orga
|
|
|
|
# TODO For others
|
2018-10-06 10:27:36 +02:00
|
|
|
inst vdirsyncer khard todoman offlineimap khal
|
2018-03-19 07:29:56 +01:00
|
|
|
systemdUserUnit vdirsyncer.timer
|
2018-10-06 10:27:36 +02:00
|
|
|
elif [ $DEBIAN == 1]; then
|
|
|
|
inst pandoc pdftk visidata translate-shell youtube-dl
|
2017-10-30 11:44:12 +01:00
|
|
|
else
|
|
|
|
# translate-shell
|
2018-08-19 11:29:59 +02:00
|
|
|
curl -L git.io/trans > ~/.local/bin/trans
|
|
|
|
chmod +x ~/.local/bin/trans
|
2018-10-06 10:27:36 +02:00
|
|
|
|
|
|
|
# TODO Others
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
2018-10-14 16:59:49 +02:00
|
|
|
# FPGA goodness
|
|
|
|
if [ $ARCH == 1 ]; then
|
|
|
|
inst iverilog
|
|
|
|
altInst ghdl
|
|
|
|
fi
|
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
# Extra GUI
|
|
|
|
if [ $GUI == 1 ]; then
|
2018-10-14 16:59:49 +02:00
|
|
|
inst vlc gimp inkscape mpd thunar musescore evince pdfpc texlive-{most,lang}
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
if [ $ARCH == 1 ]; then
|
2018-10-06 10:27:36 +02:00
|
|
|
inst simplescreenrecorder mpc
|
|
|
|
altInst vimpc-git ashuffle-git ttf-emojione-color
|
2018-10-14 16:59:49 +02:00
|
|
|
|
|
|
|
# FPGA goodness
|
|
|
|
inst gtkwave
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
2018-10-06 10:27:36 +02:00
|
|
|
# TODO Others
|
|
|
|
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|