From 793242e9659dd4c55b7ccaf4cba7323145eee859 Mon Sep 17 00:00:00 2001 From: Gabe Date: Thu, 22 Oct 2026 01:26:38 +0000 Subject: [PATCH] Add Ricing/Basic Mint Rice/install-rice.sh --- Ricing/Basic Mint Rice/install-rice.sh | 118 +++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Ricing/Basic Mint Rice/install-rice.sh diff --git a/Ricing/Basic Mint Rice/install-rice.sh b/Ricing/Basic Mint Rice/install-rice.sh new file mode 100644 index 0000000..6b5f029 --- /dev/null +++ b/Ricing/Basic Mint Rice/install-rice.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# install-rice.sh - restore the "Basic Mint Rice" desktop customization. +# Run as your normal user, from a terminal inside the desktop session. +# Works for any username: paths are rewritten to the current $HOME. + +set -e + +RICE_URL="https://scripts.gabesville.com/Gabesville/Debian-Linux/raw/branch/main/Ricing/Basic%20Mint%20Rice/rice-export" + +[ "$(id -u)" -ne 0 ] || { echo "Run this as your normal user, not root."; exit 1; } + +if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then + echo "No desktop session found. Run this from a terminal inside your desktop session, not over SSH." + exit 1 +fi + +case "$XDG_CURRENT_DESKTOP" in + *Cinnamon*) ;; + *) + printf "This rice is for Cinnamon, but the current desktop is '%s'. Continue anyway? [y/N]: " "$XDG_CURRENT_DESKTOP" + read -r answer || answer="" + case "$answer" in + y|Y|yes|YES) ;; + *) echo "Aborting."; exit 1 ;; + esac + ;; +esac + +command -v curl >/dev/null 2>&1 || sudo apt install -y curl +command -v dconf >/dev/null 2>&1 || sudo apt install -y dconf-cli + +WORKDIR=$(mktemp -d) +trap 'rm -rf "$WORKDIR"' EXIT + +# fetch +fetch () { + curl -fsSL "$RICE_URL/$1" -o "$WORKDIR/$1" || { rm -f "$WORKDIR/$1"; return 1; } +} + +# localize : make home-directory paths in a settings file match this machine. +# 1. __HOME__ placeholders (written by backup-rice.sh) become the current $HOME. +# 2. Files exported before placeholders existed: if exactly one other /home/ +# appears, it is rewritten to the current $HOME. +localize () { + sed -i "s#__HOME__#$HOME#g" "$1" + old=$(grep -aoE '/home/[A-Za-z0-9._-]+' "$1" | sort -u | grep -vx "$HOME" || true) + if [ -n "$old" ] && [ "$(printf '%s\n' "$old" | wc -l)" -eq 1 ]; then + sed -i "s#$old/#$HOME/#g" "$1" + fi +} + +# ---------- 1. files: themes, icons, fonts, applets, GTK config ---------- +echo "Downloading rice.tar.gz..." +if ! fetch rice.tar.gz; then + echo "❌ Could not download rice.tar.gz, aborting" + exit 1 +fi +tar tzf "$WORKDIR/rice.tar.gz" > /dev/null || { echo "❌ rice.tar.gz is corrupt, aborting"; exit 1; } + +echo "Extracting into $HOME:" +tar tzf "$WORKDIR/rice.tar.gz" | cut -d/ -f1-2 | sort -u | sed 's/^/ /' +tar xzf "$WORKDIR/rice.tar.gz" -C "$HOME" + +# Rewrite old home paths inside the extracted text files (binary files are skipped). +tar tzf "$WORKDIR/rice.tar.gz" | grep -v '/$' > "$WORKDIR/files.txt" || true +OLD_HOMES=$( + while IFS= read -r f; do + [ -f "$HOME/$f" ] && grep -aIoE '/home/[A-Za-z0-9._-]+' "$HOME/$f" 2>/dev/null + done < "$WORKDIR/files.txt" | sort -u | grep -vx "$HOME" || true +) +if [ -n "$OLD_HOMES" ]; then + if [ "$(printf '%s\n' "$OLD_HOMES" | wc -l)" -eq 1 ]; then + echo "Rewriting $OLD_HOMES -> $HOME in extracted files" + while IFS= read -r f; do + if [ -f "$HOME/$f" ] && grep -aIq "$OLD_HOMES/" "$HOME/$f" 2>/dev/null; then + sed -i "s#$OLD_HOMES/#$HOME/#g" "$HOME/$f" + fi + done < "$WORKDIR/files.txt" + else + echo "⚠ Several different /home/ paths found in the archive; leaving them as they are:" + printf '%s\n' "$OLD_HOMES" | sed 's/^/ /' + fi +fi + +if command -v fc-cache >/dev/null 2>&1; then + fc-cache -f +fi + +# ---------- 2. settings (dconf) ---------- +for pair in \ + "cinnamon:/org/cinnamon/" \ + "nemo:/org/nemo/" \ + "terminal:/org/gnome/terminal/" \ + "hydrapaper:/org/gabmus/hydrapaper/" +do + name=${pair%%:*} + path=${pair#*:} + if fetch "$name.dconf"; then + localize "$WORKDIR/$name.dconf" + dconf load "$path" < "$WORKDIR/$name.dconf" + echo "Loaded $name settings" + else + echo "No $name.dconf in the repo, skipping" + fi +done + +# ---------- 3. sanity check ---------- +echo +echo "Active theme settings:" +echo " GTK theme: $(gsettings get org.cinnamon.desktop.interface gtk-theme 2>/dev/null || echo '?')" +echo " Icon theme: $(gsettings get org.cinnamon.desktop.interface icon-theme 2>/dev/null || echo '?')" +echo " Cursor theme: $(gsettings get org.cinnamon.desktop.interface cursor-theme 2>/dev/null || echo '?')" +echo " Shell theme: $(gsettings get org.cinnamon.theme name 2>/dev/null || echo '?')" +echo +echo "Done. Press Ctrl+Alt+Esc to restart Cinnamon (or log out and back in) to apply everything." +if command -v hydrapaper >/dev/null 2>&1; then + echo "Hydrapaper: open it and click Apply once to regenerate the merged wallpaper." +fi \ No newline at end of file