Saturday, November 22, 2008

Creating a Password Dialog Script

Of recent, I had a few occasions whereby I wanted to lend my Eee PC to others to use or try out. I shifted all my programs from my resident SD Card to the EeePC SSD. That done, there was 1 concern left - the Menu Edit shortcut in my Favorites Tab, which was open for anyone to use.

Thus I created a script which would ask for a password before opening simpleui.rc for editing.

  1. Press Ctrl-Alt-T to open the terminal console.

  2. Type "sudo nano /usr/bin/MenuEdit-script" to create a new bash script.

  3. Type the following:

    password=$(kdialog --password "Please enter password to edit menu:")

    if [ $password = "mypassword" ]
    /usr/bin/sudo /usr/bin/kwrite /home/user/.AsusLauncher/simpleui.rc

    exit 0

  4. Press Ctrl-O to save and Ctrl-X to exit.

  5. Type "sudo chmod 755 /usr/bin/MenuEdit-script" to set the permissions for executing it.

  6. Edit your Easy Mode GUI to add or edit the following desktop shortcut (if you do not know how, pls read the earlier posts on customising your Easy Mode GUI):

    <parcel simplecat="Favorites" extraargs="/usr/bin/MenuEdit-script"
    <name lang="en">Menu Edit</name>

  7. Press Ctrl-Alt-Backspace to refresh your XTerm display. The following dialog will pop up when you click on the Menu Edit shortcut.

(^ v ^)

No comments: