Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wrote a custom .desktop file that contains an Exec line

#!/usr/bin/env xdg-open
[Desktop Entry]
(...)
Exec=gksudo /my/path/to/bash_script.sh
(...)

This script launches some zenity calls.

Then I made this desktop file to appear in unity-2d launcher side bar.

My problem is every time I use this launcher shortcut it keeps asking for my password... While the expected behavior is to ask once, then remember for some time. It was acting like that in gnome/Lucid so something has changed but what ?

(I also tried '-k' option but doesn't change my problem)

If try that command line from a terminal (as my regular user)

gksudo /my/path/to/bash_script.sh

It works like expected (=same behavior as in Lucid): asks the password only on the first launch.

What am I missing here?

share|improve this question

2 Answers 2

As far as I know, it is the terminal environment which remembers the password for a certain amount of time.

For example, the command

gksudo nautilus

in the terminal will ask the password only once in a certain timeframe. While the same command in the alt+f2 launcher asks it every time.

Either way, if you want to run something as root, it is not that weird it will ask your password every time. That way you know you will be running the command as root.

share|improve this answer
    
You're right it is not that weird, but in Lucid, I had the same .desktop file and a different behavior: the password got remembered like any other app that needs administrative privileges (ie: synaptic...). –  martin-mystere Nov 29 '12 at 15:35

This is absolutely normal. In the terminal, you've always got the same "session", so it remembers the authentification, but that's not the same with a .desktop launcher.

I'd recommend you to just add a file to /etc/sudoers.d (name it my_script or something like that), so that you can always use your command without password (if your script doesn't accept arguments that should be safe) - but do this at your own risk:

Create a new file with following content

your_username ALL=(ALL) NOPASSWD: /my/path/to/bash_script.sh

When I tested it with gksu it worked directly afterwards, but if it doesn't, try logging in and out again or rebooting.

share|improve this answer
    
I don't want to disable password checking, I just wanna get the elevated privilege remembered like for any other app...ie synaptic etc. It was working great in Lucid but something has changed in Precise. It's not a big deal but I wanna understand what has changed :) Thanks anyway ! –  martin-mystere Nov 29 '12 at 15:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.