Last active
October 28, 2020 21:03
-
-
Save ahmedselim2017/f48b7838d6e4dd10b6611ee4bf91b0db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#-------------------------------------------------- | |
# Functions | |
#-------------------------------------------------- | |
installPkg()( | |
echo "Installing $1" | |
pacman --noconfirm --needed -S "$1" | |
) | |
getUser()( | |
echo "Username:" && read username | |
while ! echo "$username" | grep -q "^[a-z_][a-z0-9_-]*$"; do | |
unset $username | |
echo "Username not valid. Give a username beginning with a letter, with only lowercase letters, - or _." && read username | |
done | |
echo "Password:" && read -s password | |
echo "Confirm password:" && read -s passwordConfirm | |
while ! [ "$password" = "$passwordConfirm" ]; do | |
unset password && unset passwordConfirm | |
echo "Passwords do not match. Please retype:" && read -s password | |
echo "Confirm password:" && read -s passwordConfirm | |
done; | |
unset $passwordConfirm | |
) | |
addUser()( | |
useradd -m -s /bin/zsh $username | |
usermod -aG wheel,audio,video,optical,storage $username | |
echo "$username:$password" | chpasswd | |
unset $password | |
) | |
refreshKeys() ( | |
echo "Refreshing Arch Keyring..." | |
pacman -Q artix-keyring >/dev/null 2>&1 && pacman --noconfirm -S archlinux-keyring >/dev/null 2>&1 | |
pacman --noconfirm -S archlinux-keyring >/dev/null 2>&1 | |
) | |
manualInstall() ( | |
[ -f "/usr/bin/$1" ] && echo "$1 is already installed." && return | |
echo "Installing $1" | |
cd /tmp || exit | |
rm -rf /tmp/$1* | |
curl -sO https://aur.archlinux.org/cgit/aur.git/snapshot/"$1".tar.gz && | |
sudo -u "$username" tar -xvf "$1".tar.gz && | |
cd "$1" && | |
sudo -u "$username" makepkg --noconfirm -si | |
cd /tmp | |
) | |
aurInstall() ( | |
echo "Installing $1" | |
sudo -u "$name" $aurhelper -S --noconfirm "$1" | |
) | |
pipInstall() ( | |
echo "Installing $1" | |
command -v pip || installPkg python-pip | |
yes | pip install "$1" | |
) | |
installDots() ( | |
sudo -u "$username" git clone --bare "https://github.com/ahmedselim2017/dotfiles" > "/home/$username/.dots" | |
sudo -u "$username" /usr/bin/git --git-dir="/home/$username/.dots/" --work-tree="/home/$username/.dots/" checkout | |
if [ $? = 0 ]; then | |
echo "Checked out config."; | |
else | |
echo "Backing up pre-existing dot files."; | |
sudo -u "$username" sh -c '/usr/bin/git --git-dir="/home/$username/.dots/" --work-tree="/home/$username/.dots/" checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}' | |
fi | |
sudo -u "$username" /usr/bin/git --git-dir="/home/$username/.dots/" --work-tree="/home/$username/.dots/" checkout | |
sudo -u "$username" /usr/bin/git --git-dir="/home/$username/.dots/" --work-tree="/home/$username/.dots/" config --local status.showUntrackedFiles no | |
) | |
installationLoop() ( | |
progsfile="https://gist.githubusercontent.com/ahmedselim2017/f48b7838d6e4dd10b6611ee4bf91b0db/raw/30c202215b530ecf7392601d0b9f647e0874da31/progs.csv" | |
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) || curl -Ls "$progsfile" | sed '/^#/d' > /tmp/progs.csv | |
total=$(wc -l < /tmp/progs.csv) | |
aurinstalled=$(pacman -Qqm) | |
while IFS=, read -r tag program comment; do | |
n=$((n+1)) | |
echo "$comment" | grep -q "^\".*\"$" && comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")" | |
case "$tag" in | |
"A") aurinstall "$program" "$comment" ;; | |
"G") gitmakeinstall "$program" "$comment" ;; | |
"P") pipinstall "$program" "$comment" ;; | |
*) installPkg "$program" "$comment" ;; | |
esac | |
done < /tmp/progs.csv ;} | |
) | |
installZSHPlugins() ( | |
cd /home/$username/.config/zsh | |
sudo -u "$username" git clone https://github.com/zdharma/fast-syntax-highlighting | |
sudo -u "$username" git clone https://github.com/subnixr/minimal | |
sudo -u "$username" git clone https://github.com/zsh-users/zsh-autosuggestions | |
sudo -u "$username" git clone https://github.com/agkozak/zsh-z | |
) | |
#-------------------------------------------------- | |
# Start | |
#-------------------------------------------------- | |
# Banner | |
echo -e "\033[0;34m┏━┓┏━┓┏━╸╻ ╻┏━┓╺┳╸┏━┓┏━┓╺┳╸┏━╸┏━┓ | |
┣━┫┣┳┛┃ ┣━┫┗━┓ ┃ ┣━┫┣┳┛ ┃ ┣╸ ┣┳┛ | |
╹ ╹╹┗╸┗━╸╹ ╹┗━┛ ╹ ╹ ╹╹┗╸ ╹ ┗━╸╹┗╸\033[0m" | |
getUser | |
refreshKeys || error "Error automatically refreshing Arch keyring." | |
for x in curl base-devel git ntp zsh; do | |
installPkg "$x" | |
done | |
ntpdate 0.us.pool.ntp.org >/dev/null 2>&1 | |
addUser || error "Couldn't add user" | |
[ -f /etc/sudoers.pacnew ] && cp /etc/sudoers.pacnew /etc/sudoers # Just in case | |
# Allow user to run sudo without password. Since AUR programs must be installed | |
# in a fakeroot environment, this is required for all builds with AUR. | |
newperms "%wheel ALL=(ALL) NOPASSWD: ALL" | |
# Make pacman and yay colorful and adds eye candy on the progress bar because why not. | |
grep -q "^Color" /etc/pacman.conf || sed -i "s/^#Color$/Color/" /etc/pacman.conf | |
grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf | |
# Use all cores for compilation. | |
sed -i "s/-j2/-j$(nproc)/;s/^#MAKEFLAGS/MAKEFLAGS/" /etc/makepkg.conf | |
manualinstall yay || error "Failed to install AUR helper." | |
# The command that does all the installing. Reads the progs.csv file and | |
# installs each needed program the way required. Be sure to run this only after | |
# the user has been created and has priviledges to run sudo without a password | |
# and all build dependencies are installed. | |
installationloop | |
installDots | |
installZSHPlugins | |
chsh -s /bin/zsh "$username" >/dev/null 2>&1 | |
sudo -u "$username" mkdir -p "/home/$name/.cache/zsh/" | |
# Tap to click | |
[ ! -f /etc/X11/xorg.conf.d/40-libinput.conf ] && printf 'Section "InputClass" | |
Identifier "libinput touchpad catchall" | |
MatchIsTouchpad "on" | |
MatchDevicePath "/dev/input/event*" | |
Driver "libinput" | |
# Enable left mouse button by tapping | |
Option "Tapping" "on" | |
EndSection' > /etc/X11/xorg.conf.d/40-libinput.conf | |
# Fix fluidsynth/pulseaudio issue. | |
grep -q "OTHER_OPTS='-a pulseaudio -m alsa_seq -r 48000'" /etc/conf.d/fluidsynth || | |
echo "OTHER_OPTS='-a pulseaudio -m alsa_seq -r 48000'" >> /etc/conf.d/fluidsynth | |
# Start/restart PulseAudio. | |
killall pulseaudio; sudo -u "$name" pulseaudio --start | |
# This line, overwriting the `newperms` command above will allow the user to run | |
# serveral important commands, `shutdown`, `reboot`, updating, etc. without a password. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#TAG | NAME IN REPO (or git url) | PURPOSE (should be a verb phrase to sound right while installing) | |
---|---|---|---|
xorg-server | is the graphical server. | ||
xorg-xwininfo | allows querying information about windows. | ||
xorg-xinit | starts the graphical server. | ||
A | hack-font-ligature-nerd-font-git | hack nerd font | |
xcompmgr | is for transparency and removing screen-tearing. | ||
xorg-xprop | is a tool for detecting window properties. | ||
dosfstools | allows your computer to access dos-like filesystems. | ||
libnotify | allows desktop notifications. | ||
dunst | is a suckless notification system. | ||
exfat-utils | allows management of FAT drives. | ||
sxiv | is a minimalist image viewer. | ||
xwallpaper | sets the wallpaper. | ||
ffmpeg | can record and splice video and audio on the command line. | ||
gnome-keyring | serves as the system keyring. | ||
A | gtk-theme-arc-gruvbox-git | gives the dracula GTK theme | |
neovim | a tidier vim with some useful features | ||
cmus | is a lightweight music player. | ||
mpv | is the patrician's choice video player. | ||
man-db | lets you read man pages of programs. | ||
A | brave-bin | is an elegant browser with built-in adblocking, tor and other features. | |
noto-fonts-emoji | is an emoji font. | ||
ntfs-3g | allows accessing NTFS partitions. | ||
pulseaudio-alsa | is the audio system. | ||
pulsemixer | is an audio controler. | ||
pamixer | is a command-line audio interface. | ||
A | sc-im | is an Excel-like terminal spreadsheet manager. | |
maim | can take quick screenshots at your request. | ||
unrar | extracts rar's. | ||
unzip | unzips zips. | ||
lynx | is a terminal browser. | ||
xclip | allows for copying and pasting from the command line. | ||
xdotool | provides window action utilities on the command line. | ||
youtube-dl | can download any YouTube video (or playlist or channel) when given the link. | ||
zathura | is a pdf viewer with vim-like bindings. | ||
zathura-pdf-mupdf | allows mupdf pdf compatibility in zathura. | ||
poppler | manipulates .pdfs and gives .pdf previews and other .pdf functions. | ||
mediainfo | shows audio and video information. | ||
fzf | is a fuzzy finder tool. | ||
highlight | can highlight code output. | ||
xorg-xbacklight | enables changing screen brightness levels. | ||
A | simple-mtpfs-git | enables the mounting of cell phones. | |
slock | allows you to lock your computer, and quickly unlock with your password. | ||
texlive-most | latex | ||
clipmenu | Clipboard management using dmenu | ||
A | i3-gaps-rounded-git | A fork of i3wm tiling window manager with more features, including gaps and rounded corners | |
picom | X compositor that may fix tearing issues | ||
A | polybar | Status bar | |
P | ipython | ipython | |
termite | terminal emulator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment