LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-16-2011, 11:13 PM   #1
bonixavier
Member
 
Registered: Sep 2010
Distribution: Slackware
Posts: 320

Rep: Reputation: 63
Power Management in Openbox


I'm fairly used to working with Fluxbox. There, if I want to let myself suspend the computer, all I have to do is add something like
Code:
[exec] (suspend) {sudo /usr/sbin/pm-suspend}
to my .fluxbox/menu and it works like a charm, after having added me to the sudoers. I installed openbox earlier today because I was having some font rendering issues in flux and I've been trying to find a way to add something similar to my menu without success. I added this to .config/openbox/menu.xml:
Code:
<item label="suspend">
<action name="Execute">
<command> sudo /usr/sbin/pm-suspend</command>
<prompt>Are you sure?</prompt>
</action>
</item>
When I try to run pm-suspend like that, I get a "couldn't execute login command" on my screen and I get dumped back to the console. I have changed the sudoers line from %users to bonixavier and it didn't change anything. What am I doing wrong here?

Edit: Forgot to mention, openbox's wiki doesn't help a bit:
Quote:
Although suspend is not given as an option on the logout menu, it can be done. At the command line, enter:

pm-suspend

(This works in systems including Mandriva, Arch Linux and Debian-based systems - is it a universal Linux command?)

Last edited by bonixavier; 06-16-2011 at 11:16 PM.
 
Old 06-16-2011, 11:30 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
It's a while since I used openbox (so my comments may not apply to the current version), but checking my old menu.xml indicates to me that the <command> tags should actually be <execute> tags. Also, I've not seen the <prompt> tag before.

Evo2.
 
Old 06-16-2011, 11:36 PM   #3
bonixavier
Member
 
Registered: Sep 2010
Distribution: Slackware
Posts: 320

Original Poster
Rep: Reputation: 63
Quote:
Originally Posted by evo2 View Post
It's a while since I used openbox (so my comments may not apply to the current version), but checking my old menu.xml indicates to me that the <command> tags should actually be <execute> tags. Also, I've not seen the <prompt> tag before.

Evo2.
Thank you for the suggestion. Unfortunately, <execute> tags didn't work. The prompt tag makes a dialog appear asking if you're sure so you can cancel or proceed with the command. I removed it for testing, but the outcome is the same.
 
Old 06-17-2011, 09:48 AM   #4
bonixavier
Member
 
Registered: Sep 2010
Distribution: Slackware
Posts: 320

Original Poster
Rep: Reputation: 63
I fixed my issue by making the suspend item run a simple script suspend.sh:
Code:
#!/bin/sh
xscreensaver-command -activate &
sudo /usr/sbin/pm-suspend
I'll probably start a thread now to try to fix my fonts problems in fluxbox. It's simpler than openbox and I like it better.
 
Old 06-17-2011, 03:44 PM   #5
bonixavier
Member
 
Registered: Sep 2010
Distribution: Slackware
Posts: 320

Original Poster
Rep: Reputation: 63
A better version of the script above would be something like
Code:
#!/bin/sh
answer=$(gxmessage "Are you sure you want to suspend?" -buttons cancel,ok -center -print)
if [ $answer = "ok" ]
then
    xscreensaver-command -activate &
    sudo /usr/sbin/pm-suspend
fi
It lets me have a confirmation dialog. If I didn't want to have a nicer looking dialog, I could have gone with xmessage that is part of a standard Slack install.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Power Management not working on embedded MIPS when using /sys/power/state RichardS Programming 1 01-21-2011 08:18 AM
Which "power distro" for lots of customizing and good system power management? mothergoose729 Linux - Distributions 11 11-18-2009 10:11 PM
Power management ryedunn Linux - Newbie 1 09-08-2008 08:10 AM
Enabling power save/power management/cpu freq scaling features for a Debian system zero79 Debian 0 12-19-2004 02:17 PM
Power Management(sysfs) /sys/power/state mavrick613 Linux - General 0 05-24-2004 04:04 PM


All times are GMT -5. The time now is 04:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration