Hello. I wrote the script that changes slim's background image. Here's the problem: If a user does not enter the root password correctly, the background image will not be changed. However, the dialog still pops up and announces that it has been changed. How do modify the code to prevent this mistake? Thanks.
#!/bin/sh
cd $HOME/Wallpaper/
slim_background=`zenity --file-selection --title="Select a Background"`
if [ $? = 0 ] ; then
zenity --question --text"Set as new background?"
if [ $? = 0 ] ; then
wterm -tr +sb -fg white -T"System" -e su -c"cp -bv \"$slim_background\" /usr/share/slim/themes/antiX/background.jpg"
zenity --info \
--text="Background Changed.\nPlease Logout/Login see changes."
fi
fi
Unfortunately, that approach did not work. If you do not enter root's pwd correctly, the script terminates. If you enter it correctly, then the script is run as root. And this was a problem since now you are directed to root's wallpaper directory (after all you just made yourself root). So no matter which approach I used, I had trouble getting zenity to point to the user's wallpaper directory (in the slim chooser script).
So to make a long story short, I remembered a discussion I had with the developer of nitrogen in the use of symlinks. I figured why not learn two new things: symlinks and issuing more than one command per button in a gtkdialog script? Finally, I solved the puzzle. The general routine is:
1. Choose the slim option in the control center.
2. A symlink is created to the user's wallpaper folder.
3. Ask for root's password and if correct, launch the slim background chooser.
4. If a user chooses a background, set it and output the operation was successful. Otherwise exit the script.
Although your advice didn't help directly, it helped me indirectly because instead of giving up, I strengthened my skills.
#!/bin/sh
cd Background
slim_background=`zenity --file-selection --title="Select a Background"`
if [ $? = 0 ] ; then
cp -bv"$slim_background" /usr/share/slim/themes/antiX/background.jpg
zenity --info \
--text="Background Changed.\nPlease Logout/Login to see changes."
fi