WSL fixes

This commit is contained in:
2024-10-27 01:33:39 +02:00
parent f3ee35f577
commit e42dd52164
39 changed files with 390367 additions and 390285 deletions

View File

@ -71,7 +71,7 @@ ensure_repositories() {
add_vscode_repo
repos=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.repos))
for repo in $repos; do
for repo in "${repos[@]}"; do
repo_name=$(echo $repo | cut -d ":" -f 2)
# Go through sources.list.d and check if there's a file containing part of URIs: https://ppa.launchpad.net/$repo_name
@ -94,8 +94,9 @@ ensure_repositories() {
fi
done
}
ensure_apt_packages_installed() {
apt_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.apps))
apt_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.apps | tr '\n' ' '))
# Check if apt_packages array contains duplicates
if [ $(echo $apt_packages | tr ' ' '\n' | sort | uniq -d | wc -l) -ne 0 ]; then
@ -105,7 +106,7 @@ ensure_apt_packages_installed() {
exit 1
fi
for package in $apt_packages; do
for package in "${apt_packages[@]}"; do
pkg_status=$(dpkg -s $package 2> /dev/null | grep "Status" | cut -d " " -f 4)
# If pkg_status is `installed` then we don't need to install the package, otherwise if it's empty then the package is not installed
@ -140,7 +141,7 @@ print_apt_status() {
count=$(echo $apt_packages | wc -w)
installed=0
for package in $apt_packages; do
for package in "${apt_packages[@]}"; do
pkg_status=$(dpkg -s $package 2> /dev/null | grep "Status" | cut -d " " -f 4)
if [ "$pkg_status" = "installed" ]; then

View File

@ -14,7 +14,7 @@ ensure_cargo_packages_installed() {
binary=$(cat $DOTFILES_CONFIG | shyaml get-value config.packages.cargo.$package.binary 2>/dev/null)
# If pkg_status is `installed` then we don't need to install the package, otherwise if it's empty then the package is not installed
if [ -z $pkg_status ]; then
if [ -z "$pkg_status" ]; then
ensure_sudo_privileges "In order to install $package, please provide your password:"
printfe "%s" "yellow" " - Compiling/Installing $package... (This may take a while)"
clear_line
@ -50,7 +50,7 @@ print_cargo_status() {
count=$(echo $cargo_packages | wc -w)
installed=0
for package in $cargo_packages; do
for package in "${cargo_packages[@]}"; do
pkg_status=$(cargo install --list | grep -E "^${package}\sv[0-9.]+:$")
if [ -z $pkg_status ]; then

View File

@ -5,7 +5,7 @@ source $HOME/dotfiles/bin/helpers/functions.sh
ensure_flatpak_packages_installed() {
flatpak_packages=($(ls $HOME/dotfiles/config/flatpaks/ | sed 's/.flatpakref//g'))
for package in $flatpak_packages; do
for package in "${flatpak_packages[@]}"; do
if ! flatpak list | grep -q $package; then
printfe "%s\n" "cyan" " - Installing $package..."
flatpak install -y flathub $package
@ -22,6 +22,11 @@ ensure_flatpak_packages_installed() {
}
print_flatpak_status() {
if is_wsl; then
printfe "%s\n" "yellow" "Running in WSL, skipping Flatpak packages check."
return
fi
printfe "%s" "cyan" "Checking Flatpak packages..."
clear_line
@ -30,7 +35,7 @@ print_flatpak_status() {
count=$(echo $flatpak_packages | wc -w)
installed=0
for package in $flatpak_packages; do
for package in "${flatpak_packages[@]}"; do
if flatpak list | grep -q $package; then
installed=$((installed + 1))
else

View File

@ -6,6 +6,15 @@ println() {
printfe "%s\n" $color "$1"
}
is_wsl() {
unameres=$(uname -a | grep -i "microsoft" | wc -l)
if [ -n "$unameres" ]; then
return 0
else
return 1
fi
}
logo() {
tput setaf 2
cat $HOME/dotfiles/bin/resources/logo.txt

View File

@ -7,7 +7,7 @@ ensure_git_repos() {
repos=($(cat $HOME/dotfiles/config/config.yaml | shyaml keys config.git))
# For each repo in the config file, ensure it is cloned (url + branch, if specified)
for repo in $repos; do
for repo in "${repos[@]}"; do
url=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.git.$repo.url)
branch=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.git.$repo.branch)
target=$(cat $HOME/dotfiles/config/config.yaml | shyaml get-value config.git.$repo.target)

View File

@ -3,6 +3,11 @@
source $HOME/dotfiles/bin/helpers/functions.sh
ensure_gnome_extensions_installed() {
if is_wsl; then
printfe "%s\n" "yellow" "Running in WSL, skipping GNOME extensions."
return
fi
# In case gnome-extensions is installed but we don't use GNOME let's do a check
if [ "$XDG_CURRENT_DESKTOP" != "GNOME" ]; then
printfe "%s\n" "red" " - XDG_CURRENT_DESKTOP is not GNOME, likely not running GNOME."

View File

@ -30,6 +30,11 @@ ensure_swhkd() {
}
ensure_keyboard_shortcuts() {
if is_wsl; then
printfe "%s\n" "yellow" "Running in WSL, skipping keyboard shortcuts."
return
fi
printfe "%s\n" "green" " - Setting up swhkd configuration..."
ensure_swhkd

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
source $HOME/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
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh --unattended --keep-zshrc
fi
}

View File

@ -35,7 +35,7 @@ print_pipx_status() {
count=$(echo $pipx_packages | wc -w)
installed=0
for package in $pipx_packages; do
for package in "${pipx_packages[@]}"; do
if pipx list | grep -q $package; then
installed=$((installed + 1))
else

View File

@ -7,7 +7,7 @@ ensure_user_groups() {
users=($(cat $DOTFILES_CONFIG | shyaml keys config.user_groups))
# For each user, ensure they are in the correct groups
for user in $users; do
for user in "${users[@]}"; do
# Ensure this user exists
if [[ ! $(id -u $user) ]]; then
printfe "%s\n" "red" " - User $user does not exist"
@ -25,7 +25,7 @@ ensure_user_in_groups() {
printfe "%s\n" "cyan" " - For user $user..."
# For each group, ensure the user is in it
for group in $groups; do
for group in "${groups[@]}"; do
# Check if the group exists at all, otherwise skip
if [[ ! $(getent group $group) ]]; then
printfe "%s\n" "red" " Group $group does not exist"

View File

@ -13,6 +13,11 @@ load_vscode_extensions() {
}
ensure_vscode_extensions_installed() {
if is_wsl; then
printfe "%s\n" "yellow" "Running in WSL, skipping VSCode extensions."
return
fi
# Load extensions list from jq in ~/dotfiles/vscode/extensions.json
load_vscode_extensions