From 1447b54c854956b668d2487bcf16f3eae1720c79 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Aleixo de Campos <119341826+phaleixo@users.noreply.github.com> Date: Sat, 7 Jun 2025 12:11:36 -0300 Subject: [PATCH] Atualizar o wallpapers.sh --- src/shell_scripts/wallpapers.sh | 135 +++++++++++++++++--------------- 1 file changed, 74 insertions(+), 61 deletions(-) diff --git a/src/shell_scripts/wallpapers.sh b/src/shell_scripts/wallpapers.sh index 88ef412..2a42400 100644 --- a/src/shell_scripts/wallpapers.sh +++ b/src/shell_scripts/wallpapers.sh @@ -9,83 +9,96 @@ echo "https://github.com/phaleixo/after_install_debian_12" ### Confirm script execution read -p "Do you want to proceed? (y/n): " response -[[ "$response" != "y" ]] && inform "Operation canceled by the user." && exit 0 +[[ "$response" != "y" ]] && echo "Operation canceled by the user." && exit 0 -### check if the distribution is compatible -if [[ $(lsb_release -cs) = "bookworm" ]] -then - echo "" - echo -e "\e[32;1mDebian 12 Distribution.\e[m" - echo "" - echo "Continuing with the script..." - echo "" +### Check if the distribution is Debian 12 (Bookworm) +if [[ $(lsb_release -is) != "Debian" ]] || [[ $(lsb_release -cs) != "bookworm" ]]; then + echo -e "\e[31;1mThis script is designed for Debian 12 (Bookworm) only.\e[m" + exit 1 else - echo -e "\e[31;1mDistribution not approved for use with this script.\e[m" - exit 1 + echo "" + echo -e "\e[32;1mDebian 12 (Bookworm) detected.\e[m" + echo "" fi -### check if there is an internet connection. -if ping -q -c 3 -W 1 1.1.1.1 >/dev/null; -then - echo "" - echo -e "\e[32;1mInternet connection OK.\e[m" - echo "" - echo "Continuing with the script..." - echo "" +### Check internet connection +if ! ping -q -c 3 -W 1 1.1.1.1 >/dev/null; then + echo -e "\e[31;1mNo internet connection. Please check your network.\e[m" + exit 1 else - echo -e "\e[31;1mYou are not connected to the internet. Check your network or Wi-Fi connection before proceeding.\e[m" - exit 1 + echo -e "\e[32;1mInternet connection OK.\e[m" fi clear +### Install required packages if missing +if ! command -v wget &> /dev/null; then + echo "Installing wget..." + sudo apt update && sudo apt install -y wget +fi -wget --version > /dev/null +if ! command -v unzip &> /dev/null; then + echo "Installing unzip..." + sudo apt update && sudo apt install -y unzip +fi + +### Download wallpapers +echo "Downloading wallpapers..." +wget -O my_wallpapers.xml "https://github.com/phaleixo/after_install_debian_12/raw/main/src/my_wallpapers.xml" +wget -O wallpapers.zip "https://github.com/phaleixo/after_install_debian_12/raw/main/src/wallpapers.zip" if [[ $? -ne 0 ]]; then - echo "wget not available , installing" - sudo apt update && sudo apt install wget -y + echo -e "\e[31;1mFailed to download wallpapers.\e[m" + exit 1 fi -unzip >> /dev/null +### Extract wallpapers +echo "Extracting wallpapers..." +unzip -q wallpapers.zip -d ~/ -if [[ $? -ne 0 ]]; then - echo "unzip not available , installing" - sudo apt update && sudo apt install unzip -y +### Detect desktop environment +DE="" +if [[ $XDG_CURRENT_DESKTOP == *"GNOME"* ]]; then + DE="gnome" +elif [[ $XDG_CURRENT_DESKTOP == *"XFCE"* ]]; then + DE="xfce" +else + # Fallback detection for Debian + if pgrep -x "gnome-session" > /dev/null; then + DE="gnome" + elif pgrep -x "xfce4-session" > /dev/null; then + DE="xfce" + fi fi +### Install wallpapers according to DE +case $DE in + "gnome") + echo "Installing for GNOME..." + sudo mv ~/wallpapers /usr/share/backgrounds/ + sudo mv my_wallpapers.xml /usr/share/gnome-background-properties/ + + # Set wallpaper + gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/wallpapers/21.jpg' + gsettings set org.gnome.desktop.background picture-uri-dark 'file:///usr/share/backgrounds/wallpapers/21.jpg' + ;; + "xfce") + echo "Installing for XFCE..." + sudo mv ~/wallpapers /usr/share/xfce4/backdrops/ + + # Set wallpaper for all monitors + for monitor in $(xfconf-query -c xfce4-desktop -l | grep last-image); do + xfconf-query -c xfce4-desktop -p $monitor -s /usr/share/xfce4/backdrops/wallpapers/21.jpg + done + ;; + *) + echo "Unknown desktop environment. Installing to common location..." + sudo mv ~/wallpapers /usr/share/backgrounds/ + ;; +esac -wget -O my_wallpapers.xml "https://github.com/phaleixo/after_install_debian_12/blob/main/src/my_wallpapers.xml" +### Clean up +rm -f wallpapers.zip -wget -O wallpapers.zip "https://github.com/phaleixo/after_install_debian_12/blob/main/src/wallpapers.zip" - - -if [[ $? -ne 0 ]]; then - echo "Downloading failed , exiting" - exit 1 -fi - -unzip wallpapers.zip -d ~/ -sudo mv wallpapers /usr/share/backgrounds/ -sudo mv my_wallpapers.xml /usr/share/gnome-background-properties/ - - -clear - -echo "Done" -sleep 2 -clear -echo "Set Wallpaper " - -gsettings set org.gnome.desktop.background picture-uri-dark 'file:///usr/share/backgrounds/wallpapers/21.jpg' - -gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/wallpapers/21.jpg' - -clear - -rm -rf wallpapers.zip - - -echo -e "Wallpapers installed" - -exit 0 +echo -e "\e[32;1mWallpapers installed successfully!\e[m" +exit 0 \ No newline at end of file