LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-28-2013, 06:58 PM   #1
hellomynameisphil
LQ Newbie
 
Registered: Aug 2005
Distribution: CRUX and Arch
Posts: 11

Rep: Reputation: 0
Can't run programs as sudo via keyboard shortcuts in Openbox in Fedora 19


I have the following script called pwrmenu:

Code:
#!/bin/sh

OPTION=$(echo -e 'hibernate\nsuspend\nreboot\nshutdown' | dmenu "$@")

case $OPTION in
hibernate)
        sudo /bin/systemctl hibernate
        ;;
suspend)
        sudo /bin/systemctl suspend
        ;;
reboot)
        sudo /bin/systemctl reboot
        ;;
shutdown)
        sudo /bin/systemctl poweroff
        ;;
*)
        echo "whuh?"
        exit 1
        ;;
esac
I am a member of the 'power' group which I created:

Code:
 ~  > groups
phil wheel audio jackuser power
As per visudo, members of the 'power' group can run power management commands via sudo with no password:

Code:
[...]
Cmnd_Alias POWER = /bin/systemctl hibernate, /bin/systemctl reboot, /bin/systemctl suspend, /bin/systemctl poweroff
[...]
%power  ALL=(ALL) NOPASSWD: POWER
[...]
Running, e.g., 'sudo /bin/systemctl hibernate' from a terminal hibernates the machine with no password. Running pwrmenu (the script above) from a terminal allows me to manage power with no password.

But in my Openbox config, I have the following:

Code:
[...]
    <keybind key="W-p">
      <action name="Execute">
        <command>/home/phil/bin/pwrmenu -b -fn '-*-clean-medium-r-*-*-16-*-*-*-*-*-*-*' -nb '#000000' -nf '#0088ff' -sb '#0088ff' -sf '#000000'</command>
      </action>
    </keybind>
[...]
When I hit Win+p, the pwrmenu comes up, but none of the options actually do anything; the computer's power state does not change. How could I have it so that I can use the script above to change the computer's power state?
 
Old 07-29-2013, 11:48 AM   #2
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Blog Entries: 1

Rep: Reputation: 172Reputation: 172
You can't run sudo commands from a script that you call from the gui like this. You can use gksu instead if you've installed it. But I suspect it won't work as you expect it to.
 
Old 08-01-2013, 04:20 AM   #3
flyinggeorge
Member
 
Registered: Feb 2012
Location: United States
Distribution: Slackware 14.0
Posts: 159

Rep: Reputation: 3
If you have gksu, it is possible to call scripts with gksu or gksudo to launch with elevated privileges. The gksudo command prompts the user for their password and they must be in the sudoers file. Alternatively, if your user is in the sudoers file, you should be able to set that command to run with sudo and not require a password.

Read this for more information:

http://askubuntu.com/questions/15900...out-a-password

Hopefully this helps.
 
Old 08-01-2013, 06:16 AM   #4
moo-cow
Member
 
Registered: Mar 2006
Distribution: Debian
Posts: 105

Rep: Reputation: 26
Try removing the four instances of "sudo" in your pwrmenu script and call the script itself with sudo:

Code:
sudo /home/phil/bin/pwrmenu -b -fn ... # etc.
Does that work? If not, try redirecting stderr to a file to see if there are any error messages:

Code:
sudo /home/phil/bin/pwrmenu -b -fn ... 2> /home/phil/error.log
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
typical sudo programs run Qwerty9119 Red Hat 3 08-22-2007 03:25 AM
Keyboard shortcuts to run commands in GNOME Xzyx987X Ubuntu 5 12-13-2006 02:32 AM
openbox & sudo hungrigerhaifisch Ubuntu 10 10-07-2005 05:22 AM
Binding Programs with keyboard shortcuts in GNOME (fedora) pymehta Linux - Newbie 1 01-24-2004 01:17 PM
shortcuts to run commands/programs nexx_au Linux - General 3 12-21-2003 04:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration