mikshaw
Group: Members
Posts: 4856
Joined: July 2004 |
|
Posted: April 12 2007,13:45 |
|
As usual, I can't help but pick at little optimization opportunities. Is it necessary to check the "state" file _AND_ set a state variable explicitly? To reduce redundancy and filesize, you can check the state file once and determine your action from that. If you have only two possible options, "elif" is unnecessary
This is untested, since i don't have/use acpid or a laptop =o) The LIDSTATE especially may not work, since i have no idea what the state file looks like.
Code Sample | #!/bin/bash
while true do sleep 1s LIDSTATE=`cat /proc/acpi/button/lid/C162/state` if [ "$LIDSTATE" == "closed" ]; then # Run commands to set you as 'away'. else # Run commands to set you as 'Online'. fi done |
Also seems to me that one second is a pretty high frequency. Raising that number would be easier on your processor. It's just an opinion, though.
-------------- http://www.tldp.org/LDP/intro-linux/html/index.html
|