Hello there,
I’ve read multiple threads on the web and still can’t figure it out.
I created a .sh to toggle the touchpad. It works when launched through the terminal using:
Exec=sudo /bin/sh /home/username/Desktop/TouchpadToggle.sh
Now, when I add it to the Keyboard Shortcuts, It says It doesn’t work.
Would appreciate your help.
Thanks.
It may be linked to the “sudo” part of the command. Ordinarily, when you use the sudo command, you would do it in a terminal and a password prompt would appear, requiring that you enter your password. given that this command, in this instance, is being invoked via a keyboard shortcut, it may be that it cannot run because it is waiting for a password that never comes.
If this is the problem, then I have a fix for it. It involves disabling the requirement for entering a password when a sudo command is issued.
Be warned, though. Disabling your sudo password requires that you edit a very important file called the “sudoer” file and if you screw up while you are editing it, you can knacker your system and you will have to re-write it. I know this because I have done precisely that myself on a previous occasion. Furthermore, disabling your sudo passsword prompt is viewed by some as leaving your system less secure. However, I am less personally concerned about this than others and so I have no problem with disabling it. It’s a matter of taste and risk-tolerance I guess. In any event, you still have to enter your password at boot-up.
-
Open up a terminal. Type “sudo visudo” and press the “Enter” key. After typing in your password at the prompt, press “Enter”. You will be taken into something called the “sudoer” file.
-
Hold the down arrow key and you will see the cursor move to the bottom of the file. Paste the following line below all other lines (in order to paste using only the keyboard in a terminal, you need to press the CTRL/SHIFT/V keys simultaneously):
yourusername ALL=NOPASSWD: ALL
where “yourusername” should be replaced with your actual user-name (mine, for example, is “stephen”)
- You now need to save and close the file. To do this you need to:
a) press CTRL and X
b) You will be prompted to type Y or N in order to save or discard the modifications. You must type Y
c) You will be given another prompt for the name that is given. Simply press the “Enter” key.
That’s it. From now on, whenever you issue a sudo based command, it will not ask for your password. This includes, naturally, any sudo command where you would have been unable to enter the password in any event.
Another alternative might be…
Replace: Exec=sudo /bin/sh
With just this: gksu
This for the Command field in the keyboard shortcut. Now, it should prompt for the password every time.
There’s some redundancy in the command you’re using and possible other reasons it may not work, too, the TouchpadToggle.sh file would tell us more.
It doesn’t prompts a password when entered in the terminal.
When this happened (not needing a password), had you already been issuing sudo commands in that terminal? The reason I ask this is because, in a given terminal session, it will only need the sudo password the first time you use a sudo command. For the rest of the time in that particular terminal session, it will not ask for the password
If I do that and then decide against it,
do I just remove ‘yourusername ALL=NOPASSWD: ALL’ ??
Is the 'echo xxx | sudo -S thunar considered a keyboard shortcut '?
Yes, you should only remove the line you added. Indeed, you could simply prefix the line with a “#” and this would kill the line as good as if you had removed it.