Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I would like to know how to make a program (Eclipse) always start with a lower 'nice' value.

I tried to manipulate ‘/usr/share/applications/eclipse.desktop’ - with no success.

Exec='nice -n -10 eclipse'

Here is the solution as described by 'geirha':

Step 1 - allow user to run nice on eclipse as root:

EDITOR=nano visudo -f /etc/sudoers.d/local_changes

# Last row must always be empty!

# Allow certain users to change 'nice' values
Cmnd_Alias SET_ECLIPSE_NICE = /root/

Step 2 - create the script that launches eclipse with nice -10:

nano /root/


 nice -n -10 sudo -H -u "$1" eclipse


chmod u+x /root/

Step 3 - edit eclipse launcher:

nano /usr/share/applications/eclipse.desktop

change Exec to:

Exec=sh -c 'gksudo -- /root/ "$USER"'
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Remove the quotes.

Exec=nice -n -10 eclipse

Edit: though only the root user can set a niceness lower than 0, so

Exec=sh -c 'eclipse & gksudo -- renice -n -10 $!'

Or maybe better:

Exec=sh -c 'exec gksudo -- nice -n -10 sudo -H -u $USER eclipse'
share|improve this answer
doesn't work, nice is 0 –  Paradiesstaub Feb 25 '12 at 12:40
@Paradiesstaub ah right, only root can set a niceness lower than 0, so you have to renice it afterwards, as root. –  geirha Feb 25 '12 at 12:51
Okay, your solution works for admin users. Now lets remove the pw dialog. I tried all the time to exit '/etc/sudoers.d/' → 'Cmnd_Alias SET_NICE = /usr/bin/nice -n -10 sudo -u tux eclipse'. This works too but only for one user. So maybe you can tell me a way how to remove the pw dialog or I find a generic way using sudoers.d –  Paradiesstaub Feb 25 '12 at 13:16
@Paradiesstaub For that, write a wrapper script that does nice -n -10 sudo -H -u "$USER" eclipse, change the desktop entry to Exec=gksudo -- thatscript, and allow the users to run this script as root instead. –  geirha Feb 25 '12 at 13:35
@Paradiesstaub err, I didn't think that through. The USER variable in that script will be root, so Exec=sh -c 'gksudo -- thatscript "$USER"' and use "$1" instead of "$USER" in the script. –  geirha Feb 25 '12 at 13:42

Your Answer


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.