Welcome
Welcome to antiX-forum.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

slim background

News about upgrades

slim background

Postby OU812 on Sun Jul 06, 2008 5:25 am

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.

Code: Select all
#!/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

john
OU812
 
Posts: 633
Joined: Sat Sep 29, 2007 9:12 pm
Location: California

Postby eriefisher on Mon Jul 07, 2008 3:50 am

Take a look at the first few lines of remaster.sh. It should help to figure it out. It check for root and fails if you are not.
eriefisher
------------------------------------------------------------
If I knew It was this good I would have been "Anti" everything long ago.

The first thing a I met was a fly with a buzz......America
User avatar
eriefisher
 
Posts: 955
Joined: Sun Oct 07, 2007 6:16 pm
Location: Canada's South Coast

Postby OU812 on Mon Jul 07, 2008 8:40 am

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.

john
OU812
 
Posts: 633
Joined: Sat Sep 29, 2007 9:12 pm
Location: California

Postby eriefisher on Tue Jul 08, 2008 12:07 am

Motivation!
eriefisher
------------------------------------------------------------
If I knew It was this good I would have been "Anti" everything long ago.

The first thing a I met was a fly with a buzz......America
User avatar
eriefisher
 
Posts: 955
Joined: Sun Oct 07, 2007 6:16 pm
Location: Canada's South Coast

Postby thinkpada21 on Wed Jul 09, 2008 5:32 am

Just one small issue. The file chooser is being opened with root privilege. I would recommend changing your original su command:

Code: Select all
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.'"
thinkpada21
 
Posts: 39
Joined: Thu Sep 13, 2007 4:34 am

Postby OU812 on Wed Jul 09, 2008 9:19 am

Thanks for the heads up, but I did rewrite the script. If you're interested, here it is:

Code: Select all
#!/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


and in the control center

Code: Select all
<action>ln -s $HOME/Wallpaper/ Background &</action>
<action>wterm -tr +sb -fg white -T "Root Password Needed" -e su -c slimbackground.sh</action>

john
OU812
 
Posts: 633
Joined: Sat Sep 29, 2007 9:12 pm
Location: California


Return to Development

Who is online

Users browsing this forum: No registered users and 0 guests