install.fairie/dotfiles/.local/bin/install-dotfiles
2022-10-31 01:57:25 +00:00

76 lines
3.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
if [ -f '/etc/qubes-release' ]; then
# Qubes dom0
qvm-create --label red --template debian-11 provision &> /dev/null || EXIT_CODE=$?
qvm-run --pass-io provision 'if [ -d ~/Downloads/professor-dotfiles ]; then cd ~/Downloads/professor-dotfiles && git config pull.rebase false && git pull origin master; else git clone https://gitlab.com/megabyte-labs/dotfiles.git ~/Downloads/professor-dotfiles; fi; cd ~/Downloads; tar -zcvf /tmp/professor-dotfiles.tar.gz professor-dotfiles'
qvm-run --pass-io provision "cat /tmp/professor-dotfiles.tar.gz" > "/tmp/dotfiles.tar.gz"
tar -xzf "/tmp/dotfiles.tar.gz" -C "$HOME"
rm -f "/tmp/dotfiles.tar.gz"
sudo rm -rf /usr/local/src/professor-dotfiles
sudo mv "$HOME/professor-dotfiles" /usr/local/src/professor-dotfiles
else
if [ -d /usr/local/src/professor-dotfiles/.git ]; then
cd /usr/local/src/professor-dotfiles
sudo git config pull.rebase false
sudo git pull origin master
cd ~/
else
sudo rm -rf /usr/local/src/professor-dotfiles
sudo git clone https://gitlab.com/megabyte-labs/dotfiles.git /usr/local/src/professor-dotfiles
fi
fi
# Copy dotfile folders
while read DOTFILE_FOLDER; do
BASENAME_FOLDER="$(basename "$DOTFILE_FOLDER")"
if [ ! -d "$HOME/$BASENAME_FOLDER" ]; then
mkdir -p "$HOME/$BASENAME_FOLDER"
fi
cp -rf "$DOTFILE_FOLDER/"* "$HOME/$BASENAME_FOLDER"
done < <(find /usr/local/src/professor-dotfiles/dotfiles -maxdepth 1 -mindepth 1 -type d)
# Copy dotfile files
while read DOTFILE_FILE; do
BASENAME_FILE="$(basename "$DOTFILE_FILE")"
cp "$DOTFILE_FILE" "$HOME/$BASENAME_FILE"
chmod 600 "$HOME/$BASENAME_FILE"
done < <(find /usr/local/src/professor-dotfiles/dotfiles -maxdepth 1 -mindepth 1 -type f)
# Ensure .local/bin contents are executable
while read LOCAL_BIN; do
chmod +x "${LOCAL_BIN}"
done < <(find "$HOME/.local/bin" -maxdepth 1 -mindepth 1 -type f)
if [ -d /Applications ] && [ -d /System ]; then
chown -Rf "$USER":"$(id -g -n)" /usr/local/src/professor-dotfiles
mkdir -p "$HOME/Library/Fonts"
cp "$HOME/.local/share/fonts/Hack Bold Nerd Font Complete.ttf" "$HOME/Library/Fonts/Hack Bold Nerd Font Complete.ttf"
theme=$(<$HOME/.local/theme/Betelgeuse.macOS.terminal)
plutil -replace Window\ Settings.Betelgeuse -xml "$theme" ~/Library/Preferences/com.apple.Terminal.plist
defaults write com.apple.Terminal "Default Window Settings" -string "Betelgeuse"
defaults write com.apple.Terminal "Startup Window Settings" -string "Betelgeuse"
/usr/libexec/PlistBuddy -c "Delete :Window\ Settings:Betelgeuse:columnCount" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betelgeuse:columnCount integer 35" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Delete :Window\ Settings:Betelgeuse:rowCount" ~/Library/Preferences/com.apple.Terminal.plist
/usr/libexec/PlistBuddy -c "Add :Window\ Settings:Betelgeuse:rowCount integer 124" ~/Library/Preferences/com.apple.Terminal.plist
# Desktop background
curl -sSL https://gitlab.com/megabyte-labs/misc/betelgeuse/-/raw/master/share/wallpapers/Next/contents/source.jpg > "$HOME/.local/theme/background.jpg"
# TODO: set desktop image or set desktop picture
osascript -e tell application “Finder” to set desktop image to POSIX file "~/.local/theme/background.jpg"'
fi
# Firefox theme
# if [ ! -f ~/.mozilla/firefox ] && [ ! -f '/etc/qubes-release' ]; then
# if [ -d /usr/local/src/firefox-sweet-theme/.git ]; then
# sudo git config pull.rebase false
# cd /usr/local/src/firefox-sweet-theme && git pull origin master
# else
# sudo git clone https://github.com/EliverLara/firefox-sweet-theme /usr/local/src/firefox-sweet-theme
# fi
# bash /usr/local/src/firefox-sweet-theme/scripts/install.sh
# fi
# grep -q QT_QPA_PLATFORMTHEME=qt5ct /etc/environment || echo QT_QPA_PLATFORMTHEME=qt5ct | sudo tee -a /etc/environment
# sudo cp -rv "$HOME/.local/share/qt5ct" /usr/share