All times are UTC-06:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Nov 12, 2012 11:54 am 
Offline

Joined: Tue Apr 17, 2012 3:15 am
Posts: 44
Location: Barcelona, Spain
This post comprises two problems:
1) when I monitor /var/log/messages and I close the lid and then open it again, the message that appears at the moment of closing is "Efika MX: Lid open", and the moment I open the lid "Efika MX: Lid closed" appears. Unless this is reporting the status of the system immediately *before* the event, I assume that it is erroneously reversed.

2) I am not running any desktop environment in Debian armhf. I am trying to set up the system to suspend when the lid is closed. I tried via acpid but I had no luck, including when I tried suspending on an "open" event, to account for the possible reversal explained above. Suspend works fine if I call it manually via pm-suspend, so it's just a matter of catching the lid-closing event. Any tips?

_________________
http://www.brandoninvergo.com


Top
   
PostPosted: Mon Nov 12, 2012 1:31 pm 
Offline

Joined: Sun Mar 27, 2011 1:18 pm
Posts: 183
Location: Hornell, NY
Since there is no ACPI on the smartbook there is no ACPI event to listen for.

I think the gnome power manager gets the lid close event and does the suspend. if you want to do this
without a desktop environment you could possibly write a C program similar to
this one that I did for a project in the summer of 2011: https://github.com/wschaub/outpostserve ... erbutton.c

that looks for the power button to be pressed on the efika and then does a shutdown. I'm pretty sure the same interface can be used to look for the lid events and do a suspend.

I'm going to check if this works on my smartbook but I think you just want to change this line:
if(event.type == EV_KEY && event.code == KEY_POWER)
to
if(event.type == EV_SW && event.code == SW_LID)

and change the system line to whatever you need to do a suspend. I will let you know if this works on my smartbook in a bit.


Top
   
PostPosted: Mon Nov 12, 2012 2:04 pm 
Offline

Joined: Sun Mar 27, 2011 1:18 pm
Posts: 183
Location: Hornell, NY
I have tested the following code on my smartbook. this should run in the background and do what you need if you want the smartbook to suspend on lid close without a desktop running.

You can also put in a similar if statement to do whatever you want on power button presses as well. I believe there should be two values one for button press and one for release, you only want to catch one of them.

I didn't bother with this in the original code on github because I just wanted a simple shutdown on powerbutton press and had the daemon exit after it called system.

Either way I hope this helps you. you can just save it to suspendd.c and do gcc -o suspendd suspendd.c and you will have a suspendd executable. you can put that into /usr/sbin and run it from your rc.local script at boot. you can test it standalone by just running sudo ./suspendd -f (or just let it fork into the background by omitting the -f)


Code:
/* $Id: powerbutton.c,v 1.3 2011/06/23 07:35:36 wschaub Exp wschaub $ */
/* read /dev/input/event0 forever until the lid is closed and then suspend */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <linux/input.h>
/* struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
}; */

int main(int argc, char **argv) {
int opt,foreground;
foreground = 0;

while ((opt = getopt(argc, argv, "f")) != -1) {
switch (opt) {
case 'f':
foreground = 1;
break;
default: /* '?' */
fprintf(stderr, "Usage: %s [ -f ]\n",
argv[0]);
exit(EXIT_FAILURE);
}
}

if(!foreground) {
daemon(0,0);
}

struct input_event event; //Each read of event0 gives us an input_event struct
FILE *fp;
fp = fopen("/dev/input/event0","r");
if(fp == NULL)
{
perror("/dev/input/event0");
abort();
}

//Loop forever reading events and do something only when the lid is closed.
while(1)
{
fread(&event,sizeof(event),1,fp);
//printf("type = %d\n",event.type);
//printf("code = %d\n",event.code);
if(event.type == EV_SW && event.code == SW_LID && event.value == 1) {
printf("lid switch pressed value = %u\n",event.value);
system("pm-suspend");
}
}

}


Top
   
PostPosted: Mon Nov 12, 2012 3:17 pm 
Offline

Joined: Tue Apr 17, 2012 3:15 am
Posts: 44
Location: Barcelona, Spain
Yes, it works great, thanks!! It even wakes on opening, which I didn't expect from reading the code. Where can I find documentation on changing the state of the power button LED? That way I could make it blink slowly while it's suspended...not really necessary but a nice visual reminder of its state.

Funny, I had no idea that the Smartbook does not have ACPI. I'm stuck in my x86_64 ways.

BTW, I just switched over to a Debian armhf installed via your install script and it works great so far, so thanks for that too!

_________________
http://www.brandoninvergo.com


Top
   
PostPosted: Mon Nov 12, 2012 3:22 pm 
Offline

Joined: Sun Mar 27, 2011 1:18 pm
Posts: 183
Location: Hornell, NY
Quote:
Yes, it works great, thanks!! It even wakes on opening, which I didn't expect from reading the code. Where can I find documentation on changing the state of the power button LED? That way I could make it blink slowly while it's suspended...not really necessary but a nice visual reminder of its state.

Funny, I had no idea that the Smartbook does not have ACPI. I'm stuck in my x86_64 ways.

BTW, I just switched over to a Debian armhf installed via your install script and it works great so far, so thanks for that too!
Unfortunately there is no way to change the power LED state at least not on the smartbook. (it is possible on the smarttop though but I doubt you can do much to make it blink when it's suspended)


Top
   
PostPosted: Mon Nov 12, 2012 4:04 pm 
Offline

Joined: Tue Apr 17, 2012 3:15 am
Posts: 44
Location: Barcelona, Spain
Quote:
Unfortunately there is no way to change the power LED state at least not on the smartbook. (it is possible on the smarttop though but I doubt you can do much to make it blink when it's suspended)
Ah that's a shame. I was hoping based on your use of blinking the smarttop light on your headless install. Oh well, I can't be greedy.

Thanks again for your help!

_________________
http://www.brandoninvergo.com


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
PowerDeveloper.org: Copyright © 2004-2012, Genesi USA, Inc. The Power Architecture and Power.org wordmarks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org.
All other names and trademarks used are property of their respective owners. Privacy Policy
Powered by phpBB® Forum Software © phpBB Group