this commit adds a lot of shit, look at the shit, too much sorry

Signed-off-by: Menno van Leeuwen <menno@vleeuwen.me>
This commit is contained in:
2024-08-24 01:35:46 +02:00
parent 379b1b97ec
commit 183b688617
52 changed files with 580 additions and 453 deletions

64
bin/helpers/apt_packages.sh Normal file → Executable file
View File

@@ -1,56 +1,6 @@
#!/usr/bin/env zsh
apt_packages=(
"zsh"
"git"
"curl"
"wget"
"gpg"
"ca-certificates"
"software-properties-common"
"apt-transport-https"
"vim"
"sl"
"just"
"libglvnd-dev"
"libwayland-dev"
"libseat-dev"
"libxkbcommon-dev"
"libinput-dev"
"udev"
"dbus"
"libdbus-1-dev"
"libsystemd-dev"
"libpixman-1-dev"
"libssl-dev"
"libflatpak-dev"
"libpulse-dev"
"libexpat1-dev"
"libfontconfig-dev"
"libfreetype-dev"
"mold"
"cargo"
"libgbm-dev"
"libclang-dev"
"libpipewire-0.3-dev"
"libpam0g-dev"
"openssh-server"
"build-essential"
"flatpak"
"meson"
"pipx"
"python3-nautilus"
"gettext"
"fzf"
"neofetch"
"screenfetch"
"wezterm"
"brave-browser"
"code"
"1password"
"1password-cli"
"spotify-client"
)
source ~/dotfiles/bin/lists/apt.sh
add_wezterm_repo() {
# Check if we have a wezterm.list file already, if not then create one
@@ -178,7 +128,7 @@ ensure_apt_packages_installed() {
ensure_sudo_privileges "In order to install $package, please provide your password:"
printfe "%s" "yellow" " - Installing $package..."
echo -en "\r"
clear_line
result=$(sudo apt install -y $package 2>&1)
@@ -197,7 +147,7 @@ ensure_apt_packages_installed() {
print_apt_status() {
printfe "%s" "cyan" "Checking APT packages..."
echo -en "\r"
clear_line
# count entries in packages
count=$(echo $apt_packages | wc -w)
@@ -215,5 +165,11 @@ print_apt_status() {
fi
done
printfe "%s\n" "cyan" "APT $installed/$count packages installed"
printfe "%s" "cyan" "APT"
if [ $installed -eq $count ]; then
printfe "%s" "green" " $installed/$count "
else
printfe "%s" "red" " $installed/$count "
fi
printfe "%s\n" "cyan" "packages installed"
}

24
bin/helpers/cargo_packages.sh Normal file → Executable file
View File

@@ -1,17 +1,7 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
cargo_packages=(
"exa"
"lsd"
"bat"
"starship"
"ripgrep"
"fd-find"
"procs"
"bottom"
)
source ~/dotfiles/bin/lists/cargo.sh
ensure_cargo_packages_installed() {
# Check if cargo_packages array contains duplicates
@@ -29,7 +19,7 @@ ensure_cargo_packages_installed() {
if [ -z $pkg_status ]; then
ensure_sudo_privileges "In order to install cargo_packages, please provide your password:"
printfe "%s" "yellow" " - Installing $package..."
echo -en "\r"
clear_line
result=$(cargo install $package 2>&1)
if [ $? -ne 0 ]; then
@@ -45,7 +35,7 @@ ensure_cargo_packages_installed() {
print_cargo_status() {
printfe "%s" "cyan" "Checking Cargo packages..."
echo -en "\r"
clear_line
count=$(echo $cargo_packages | wc -w)
installed=0
@@ -62,5 +52,11 @@ print_cargo_status() {
fi
done
printfe "%s\n" "cyan" "Cargo $installed/$count packages installed"
printfe "%s" "cyan" "Cargo"
if [ $installed -eq $count ]; then
printfe "%s" "green" " $installed/$count "
else
printfe "%s" "red" " $installed/$count "
fi
printfe "%s\n" "cyan" "packages installed"
}

40
bin/helpers/flatpak_packages.sh Normal file → Executable file
View File

@@ -1,33 +1,7 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
flatpak_packages=(
"app.drey.Doggo"
"org.gnome.Boxes"
"org.gnome.baobab"
"re.sonny.Junction"
"com.yubico.yubioath"
"net.nokyan.Resources"
"com.system76.Popsicle"
"com.github.marhkb.Pods"
"org.wezfurlong.wezterm"
"io.github.dimtpap.coppwr"
"com.github.tchx84.Flatseal"
"dev.bragefuglseth.Keypunch"
"io.github.flattool.Warehouse"
"io.github.jonmagon.kdiskmark"
"org.onlyoffice.desktopeditors"
"io.missioncenter.MissionCenter"
"io.podman_desktop.PodmanDesktop"
"io.github.giantpinkrobots.flatsweep"
"io.github.realmazharhussain.GdmSettings"
"io.github.thetumultuousunicornofdarkness.cpu-x"
)
flatpak_remotes=(
"https://flathub.org/repo/flathub.flatpakrepo"
)
source ~/dotfiles/bin/lists/flatpak.sh
ensure_remotes_added() {
for remote in $flatpak_remotes; do
@@ -46,7 +20,7 @@ ensure_flatpak_packages_installed() {
printfe "%s\n" "red" "Failed to install $package: $result"
fi
echo -en "\r"
clear_line
printfe "%s\n" "green" " - $package installed"
else
printfe "%s\n" "green" " - $package is already installed"
@@ -56,7 +30,7 @@ ensure_flatpak_packages_installed() {
print_flatpak_status() {
printfe "%s" "cyan" "Checking Flatpak packages..."
echo -en "\r"
clear_line
count=$(echo $flatpak_packages | wc -w)
installed=0
@@ -71,5 +45,11 @@ print_flatpak_status() {
fi
done
printfe "%s\n" "cyan" "Flatpak $installed/$count packages installed"
printfe "%s" "cyan" "Flatpak"
if [ $installed -eq $count ]; then
printfe "%s" "green" " $installed/$count "
else
printfe "%s" "red" " $installed/$count "
fi
printfe "%s\n" "cyan" "packages installed"
}

90
bin/helpers/fonts.sh Executable file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
source ~/dotfiles/bin/lists/fonts.sh
install_font() {
font_url="$1"
font_name="$2"
if [[ "$OSTYPE" == "darwin"* ]]; then
font_dir="$HOME/Library/Fonts"
else
font_dir="$HOME/.local/share/fonts"
fi
mkdir -p $font_dir
# Check if any font files with the base name exist in the target directory
found=$(find "$font_dir" -name "${font_name}*.ttf" | wc -l)
if [ $found -gt 0 ]; then
printfe "%s\n" "green" " - $font_name is already installed"
else
printfe "%s" "yellow" " - Downloading $font_name..."
echo -en "\r"
result=$(curl -s -L -w "%{http_code}" -o /tmp/$font_name.zip $font_url)
if [ $? -ne 0 ] || [ "$result" -ne "200" ]; then
printfe "%s\n" "red" " - Failed to download $font_name"
printfe "%s\n" "red" " HTTP status code: $result"
return 1
fi
printfe "%s" "yellow" " - Unzipping $font_name..."
echo -en "\r"
result=$(unzip -o /tmp/$font_name.zip -d /tmp/$font_name 2>&1)
if [ $? -ne 0 ]; then
printfe "%s\n" "red" " - Failed to unzip $font_name"
printfe "%s\n" "red" " Error: $result"
return 1
fi
printfe "%s\n" "yellow" " - Moving $font_name to $font_dir..."
mv /tmp/$font_name/*.ttf $font_dir &> /dev/null
# Clear font cache
if [[ "$OSTYPE" != "darwin"* ]]; then
fc-cache -fv $font_dir &> /dev/null
fi
printfe "%s\n" "green" " - $font_name has been installed"
fi
}
ensure_fonts_installed() {
for font in "${fonts[@]}"; do
install_font $(echo $font | awk '{print $1}') $(echo $font | awk '{print $2}')
done
}
print_fonts_status() {
if [[ "$OSTYPE" == "darwin"* ]]; then
font_dir="$HOME/Library/Fonts"
else
font_dir="$HOME/.local/share/fonts"
fi
mkdir -p $font_dir
total_fonts=0
installed_fonts=0
for font in "${fonts[@]}"; do
font_name=$(echo $font | awk '{print $2}')
((total_fonts++))
found=$(find "$font_dir" -name "${font_name}*.ttf" | wc -l)
if [ "$found" -gt 0 ]; then
((installed_fonts++))
fi
done
printfe "%s" "cyan" "NerdFonts:"
if [ "$installed_fonts" -eq "$total_fonts" ]; then
printfe "%s" "green" " $installed_fonts/$total_fonts "
else
printfe "%s" "red" " $installed_fonts/$total_fonts "
fi
printfe "%s\n" "cyan" "fonts installed"
}

View File

@@ -181,3 +181,7 @@ check_or_make_symlink() {
fi
fi
}
clear_line() {
echo -en "\r"
}

51
bin/helpers/gnome_extensions.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
ensure_gnome_extensions_installed() {
printfe "%s" "cyan" " - Loading GNOME extension json file..."
echo -en '\r'
if [ ! -f ~/dotfiles/gnome/extensions.json ]; then
printfe "%s\n" "red" " - No GNOME extensions file found."
return
fi
extensions=$(cat ~/dotfiles/gnome/extensions.json)
gnome_extensions=($(echo $extensions | jq -r '.[]'))
for i in "${gnome_extensions[@]}";
do
printfe "%s" "cyan" " - Fetching extension details for $(echo $i | grep -oP 'extension/\K[^/]+')"
echo -en '\r'
# Check if extension_id is already installed
if gnome-extensions list | grep --quiet ${i}; then
printfe "%s\n" "green" " - Extension $i is already installed."
continue
fi
printfe "%s" "cyan" " - Installing $i..."
echo -en '\r'
result=$(gext install $i 2>&1)
if [ $? -ne 0 ]; then
printfe "%s\n" "red" " - Failed to install $i"
printfe "%s\n" "red" " $result"
continue
fi
if echo $result | grep --quiet "Cannot find extension"; then
printfe "%s\n" "red" " - Failed to install $i, extension not found."
continue
fi
printfe "%s\n" "green" " - Extension $i has been installed."
done
}
# Export a JSON file with all installed GNOME extensions IDs
export_gnome_extensions() {
extensions=$(gnome-extensions list --enabled --user)
echo $extensions | jq -R -s -c 'split("\n")[:-1]' > ~/dotfiles/gnome/extensions.json
}

12
bin/helpers/keyboard_shortcuts.sh Normal file → Executable file
View File

@@ -9,7 +9,7 @@ if ! command -v jq &> /dev/null; then
fi
# Parse JSON file
shortcuts_file=~/dotfiles/config/keyboard-shortcuts.json
shortcuts_file=~/dotfiles/gnome/keyboard-shortcuts.json
if [ ! -f "${shortcuts_file}" ]; then
echo "Shortcuts file not found: ${shortcuts_file}"
exit 1
@@ -48,7 +48,7 @@ ensure_keyboard_shortcuts() {
print_keyboard_shortcuts_status() {
printfe "%s" "cyan" "Checking keyboard shortcuts..."
echo -en "\r"
clear_line
# Retrieve current custom keybindings
existing_bindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | tr -d "[]'")
@@ -66,5 +66,11 @@ print_keyboard_shortcuts_status() {
done
json_count=$(echo $shortcuts | jq 'keys | length')
printfe "%s\n" "cyan" "Keyboard shortcuts $index/$json_count configured"
printfe "%s" "cyan" "Keyboard shortcuts"
if [ $index -eq $json_count ]; then
printfe "%s" "green" " $index/$json_count "
else
printfe "%s" "red" " $index/$json_count "
fi
printfe "%s\n" "cyan" "shortcuts installed"
}

28
bin/helpers/ohmyzsh.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
ensure_ohmyzsh_installed() {
if [ -d ~/.oh-my-zsh ]; then
printfe "%s" "yellow" " - Updating Oh My Zsh..."
echo -en "\r"
zstyle ':omz:update' verbose minimal
result=$($ZSH/tools/upgrade.sh)
if [ $? -ne 0 ]; then
printfe "%s\n" "red" "Failed to update Oh My Zsh"
exit 1
fi
# if result contains "already at the latest version" then it's already up to date and we should say so
if [[ $result == *"already at the latest version"* ]]; then
printfe "%s\n" "green" " - Oh My Zsh is already up to date"
else
printfe "%s\n" "green" " - Oh My Zsh updated successfully"
printfe "%s\n" "green" "$result"
fi
else
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
}

54
bin/helpers/pipx_packages.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
source ~/dotfiles/bin/lists/pipx.sh
ensure_pipx_packages_installed() {
for i in "${pipx_packages[@]}";
do
printfe "%s" "cyan" " - Fetching package details for $i"
echo -en '\r'
if pipx list | grep --quiet ${i}; then
printfe "%s\n" "green" " - $i is already installed."
continue
fi
printfe "%s" "cyan" " - Installing $i..."
echo -en '\r'
pipx install $i
if [ $? -ne 0 ]; then
printfe "%s\n" "red" " - Failed to install $i"
continue
fi
printfe "%s\n" "green" " - $i installed."
done
}
print_pipx_status() {
printfe "%s" "cyan" "Checking pipx packages..."
clear_line
count=$(echo $pipx_packages | wc -w)
installed=0
for package in $pipx_packages; do
if pipx list | grep -q $package; then
installed=$((installed + 1))
else
if [ "$verbose" = true ]; then
printfe "%s\n" "red" "$package is not installed"
fi
fi
done
printfe "%s" "cyan" "pipx"
if [ $installed -eq $count ]; then
printfe "%s" "green" " $installed/$count "
else
printfe "%s" "red" " $installed/$count "
fi
printfe "%s\n" "cyan" "packages installed"
}

27
bin/helpers/rust.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env zsh
source ~/dotfiles/bin/helpers/functions.sh
ensure_rust_installed() {
if [ -x "$(command -v rustc)" ]; then
printfe "%s\n" "green" " - Rust is already installed"
# Update Rust
printfe "%s" "yellow" " - Updating Rust..."
echo -en "\r"
rustup update
else
printfe "%s\n" "yellow" " - Installing Rust..."
echo -en "\r"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
if [ $? -ne 0 ]; then
printfe "%s\n" "red" "Failed to install Rust"
exit 1
fi
printfe "%s\n" "green" " - Rust installed successfully"
fi
}

13
bin/helpers/vscode-extensions.sh Normal file → Executable file
View File

@@ -35,7 +35,7 @@ ensure_vscode_extensions_installed() {
print_vsc_status() {
printfe "%s" "cyan" "Checking VSCode extensions..."
echo -en "\r"
clear_line
load_vscode_extensions
count_installed_extensions=0
@@ -64,6 +64,13 @@ print_vsc_status() {
done < <(code --list-extensions)
fi
total_extensions=${#extensionList[@]}
printfe "%s\n" "cyan" "VSCode $count_installed_extensions/$total_extensions extensions installed"
count=${#extensionList[@]}
printfe "%s" "cyan" "VSCode"
if [ $count_installed_extensions -eq $count ]; then
printfe "%s" "green" " $count_installed_extensions/$count "
else
printfe "%s" "red" " $count_installed_extensions/$count "
fi
printfe "%s\n" "cyan" "extensions installed"
}