From 149615c1f7868568b76adff47cc8efc82ae4c3c1 Mon Sep 17 00:00:00 2001 From: Rasmus Lauritsen Date: Wed, 23 Jul 2025 14:37:06 +0200 Subject: [PATCH] Updated a bit --- setup-ubuntu.sh | 126 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 115 insertions(+), 11 deletions(-) diff --git a/setup-ubuntu.sh b/setup-ubuntu.sh index 7b25d9c..f79d424 100755 --- a/setup-ubuntu.sh +++ b/setup-ubuntu.sh @@ -10,6 +10,18 @@ sudo apt-get update > /dev/null && sudo apt-get upgrade -y > /dev/null sudo apt-get update > /dev/null && sudo apt-get install -y nala > /dev/null sudo nala install -y apt-transport-https ca-certificates cifs-utils cksfv curl curl git gnupg golang-go jq mc nano pipx python3 sshpass unrar unzip wget > /dev/null + +# Uninstall Transmission if installed (Ubuntu sometimes installs it by default) +echo "🔧 Checking for Transmission..." +if dpkg -l | grep -q transmission-gtk; then + echo "Removing Transmission (transmission-gtk)..." + sudo apt-get remove --purge -y transmission-gtk transmission-common transmission-qt > /dev/null + sudo apt-get autoremove -y > /dev/null + echo "Transmission removed." +else + echo "Transmission not installed." +fi + # Change work-dir to /tmp/ cd /tmp/ @@ -25,6 +37,7 @@ software=( rpi-imager # Raspberry Pi Imager solaar # Solaar - Logitech keyboard/mouse software for Linux ) + # Run nala install for all software in the array sudo nala install -y "${software[@]}" > /dev/null @@ -33,6 +46,7 @@ echo "📦 Installing applications from Flathub..." sudo nala install -y flatpak gnome-software-plugin-flatpak > /dev/null sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo +# Flatpak applications # Flatpak applications flatpakapps=( com.bitwarden.desktop # Bitwarden client @@ -40,7 +54,7 @@ flatpakapps=( com.prusa3d.PrusaSlicer # PrusaSlicer com.valvesoftware.Steam # Steam - games md.obsidian.Obsidian # Obsidian - markdown notepad - net.waterfox.waterfox # Waterfox - browser + one.ablaze.floorp # Floorp - browser org.deluge_torrent.deluge # Deluge - torrent client org.remmina.Remmina # SSH client org.videolan.VLC # VLC video player @@ -57,9 +71,18 @@ pipx ensurepath pipx completions eval "$(register-python-argcomplete pipx)" + ##################################### # Extend APT with more applications # ##################################### + +### Tailscale ### +echo "📦 Installing Tailscale..." +curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null +curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list +sudo nala update > /dev/null +sudo nala install -y tailscale > /dev/null + ### Fastfetch ### echo "📦 Installing Fastfetch..." sudo add-apt-repository -y ppa:zhangsongcui3371/fastfetch > /dev/null @@ -122,7 +145,6 @@ curl -sOL "https://github.com/bitnami-labs/sealed-secrets/releases/download/v${K tar -xvzf kubeseal-${KUBESEAL_VERSION}-linux-amd64.tar.gz kubeseal > /dev/null sudo install -m 755 kubeseal /usr/local/bin/kubeseal && rm kubeseal* - # Lazygit - TUI for Git echo "📦 Installing Lazygit..." LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') @@ -159,16 +181,31 @@ sudo chmod 0777 unrarall sudo chown root:root unrarall sudo mv unrarall /usr/bin/unrarall + # VSCode echo "📦 Installing VSCode..." -sudo install -m 0755 -d /etc/apt/keyrings -sudo apt-get install -y apt-transport-https wget gpg > /dev/null -wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg -sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg -echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null -rm -f packages.microsoft.gpg -sudo apt-get update > /dev/null -sudo apt-get install -y code > /dev/null +# Install prerequisites +sudo apt-get install -y wget gpg apt-transport-https > /dev/null + +# Import the Microsoft GPG key +wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg +sudo install -D -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/microsoft.gpg +rm -f microsoft.gpg + +# Add the VS Code repository in .sources format +sudo tee /etc/apt/sources.list.d/vscode.sources > /dev/null < /dev/null +sudo nala install -y code > /dev/null # Install VSCode extensions echo "📦 Installing more VSCode extensions.." @@ -230,6 +267,73 @@ gsettings set org.gnome.settings-daemon.plugins.color night-light-temperature 40 # Deactivate "Begin move" shortcut, as the same keys are used in Double Commander gsettings set org.gnome.desktop.wm.keybindings begin-move "[]" +# Remove unwanted apps from favorites using jq for robust JSON handling +apps_to_remove=( + "yelp.desktop" + "rhythmbox.desktop" + "org.gnome.Rhythmbox3.desktop" + "thunderbird.desktop" + "thunderbird_thunderbird.desktop" +) + +# Get current favorites as JSON array, with error handling +gsettings_output=$(gsettings get org.gnome.shell favorite-apps 2>/dev/null) +if echo "$gsettings_output" | grep -q '^@as '; then + # Remove the @as prefix if present + gsettings_output=${gsettings_output#@as } +fi + +# Try to convert to JSON, fallback to empty array if invalid +if echo "$gsettings_output" | grep -q '^\['; then + current_apps=$(echo "$gsettings_output" | tr "'" '"') +else + echo "⚠️ Could not get valid favorite-apps from gsettings, using empty array." + current_apps='[]' +fi + +for app in "${apps_to_remove[@]}"; do + current_apps=$(echo "$current_apps" | jq --arg app "$app" '[.[] | select(. != $app)]') +done + + +# Desired order: Firefox, Floorp, Chrome, Double Commander, then the rest +ordered_apps=( + "firefox.desktop" + "firefox_firefox.desktop" + "one.ablaze.floorp.desktop" + "google-chrome.desktop" + "doublecmd.desktop" +) + +# Only keep ordered apps that are present in current favorites +ordered_present=() +for app in "${ordered_apps[@]}"; do + if echo "$current_apps" | jq -e --arg a "$app" 'index($a)' > /dev/null; then + ordered_present+=("$app") + fi +done + +# Remove all ordered_present from current_apps to avoid duplicates +remaining=$(echo "$current_apps" | jq -c --argjson order "$(printf '%s\n' "${ordered_present[@]}" | jq -R . | jq -s .)" '. as $in | $order as $order | [.[] | select(. as $a | ($order | index($a) | not))]') + +# Build new favorites array in desired order, then add the rest +new_favorites=$(jq -c -n --argjson ordered "$(printf '%s\n' "${ordered_present[@]}" | jq -R . | jq -s .)" --argjson rest "$remaining" '$ordered + $rest') + + +# Convert JSON array to gsettings format: single-quoted, comma-separated +gsettings_favorites=$(echo "$new_favorites" | jq -r 'map("'\''" + . + "'\''") | "[" + join(", ") + "]"') +gsettings set org.gnome.shell favorite-apps "$gsettings_favorites" + +# Cleaup unwanted apps from favorites +for app in "${apps_to_remove[@]}"; do + if echo "$current_set" | grep -q "$app"; then + echo "❌ $app is still present in favorites!" + else + echo "✅ $app is not present in favorites." + fi +done + # All done cd # change directory to homedir -echo "🎉 Setup of Ubuntu is done! 🚀" \ No newline at end of file +echo "🎉 Setup of Ubuntu is done! 🚀" +