Atualizar o wallpapers.sh

This commit is contained in:
Paulo Henrique Aleixo de Campos 2025-06-07 12:11:36 -03:00 committed by GitHub
parent 5f257f1bf6
commit 1447b54c85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,83 +9,96 @@ echo "https://github.com/phaleixo/after_install_debian_12"
### Confirm script execution ### Confirm script execution
read -p "Do you want to proceed? (y/n): " response 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 ### Check if the distribution is Debian 12 (Bookworm)
if [[ $(lsb_release -cs) = "bookworm" ]] if [[ $(lsb_release -is) != "Debian" ]] || [[ $(lsb_release -cs) != "bookworm" ]]; then
then echo -e "\e[31;1mThis script is designed for Debian 12 (Bookworm) only.\e[m"
echo "" exit 1
echo -e "\e[32;1mDebian 12 Distribution.\e[m"
echo ""
echo "Continuing with the script..."
echo ""
else else
echo -e "\e[31;1mDistribution not approved for use with this script.\e[m" echo ""
exit 1 echo -e "\e[32;1mDebian 12 (Bookworm) detected.\e[m"
echo ""
fi fi
### check if there is an internet connection. ### Check internet connection
if ping -q -c 3 -W 1 1.1.1.1 >/dev/null; if ! ping -q -c 3 -W 1 1.1.1.1 >/dev/null; then
then echo -e "\e[31;1mNo internet connection. Please check your network.\e[m"
echo "" exit 1
echo -e "\e[32;1mInternet connection OK.\e[m"
echo ""
echo "Continuing with the script..."
echo ""
else else
echo -e "\e[31;1mYou are not connected to the internet. Check your network or Wi-Fi connection before proceeding.\e[m" echo -e "\e[32;1mInternet connection OK.\e[m"
exit 1
fi fi
clear 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 if [[ $? -ne 0 ]]; then
echo "wget not available , installing" echo -e "\e[31;1mFailed to download wallpapers.\e[m"
sudo apt update && sudo apt install wget -y exit 1
fi fi
unzip >> /dev/null ### Extract wallpapers
echo "Extracting wallpapers..."
unzip -q wallpapers.zip -d ~/
if [[ $? -ne 0 ]]; then ### Detect desktop environment
echo "unzip not available , installing" DE=""
sudo apt update && sudo apt install unzip -y 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 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" echo -e "\e[32;1mWallpapers installed successfully!\e[m"
exit 0
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