Power down event

All,

I know this might be a little off topic, but... is there any way that I can catch a pressed power button event through SDL, so that I can perform a clean system shutdown?

Thanks!

Carlos

Isn’t it up to your OS to send terminate signals to all runing apps when the computer is shutting down?

Best regards
Daniel Liljeberg----- Original Message -----
From: Carlos Vrancken
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 6:09 PM
Subject: [SDL] Power down event

All,

  I know this might be a little off topic, but... is there any way that I can catch a pressed power button event through SDL, so that I can perform a clean system shutdown?

Thanks!

Carlos

I’m using Linux and if I press the power button, the computer just goes off.

Any help?

Carlos----- Original Message -----
From: DAMiEN
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 12:13 PM
Subject: Re: [SDL] Power down event

Isn’t it up to your OS to send terminate signals to all runing apps when the computer is shutting down?

Best regards
Daniel Liljeberg
----- Original Message -----
From: Carlos Vrancken
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 6:09 PM
Subject: [SDL] Power down event

All,

    I know this might be a little off topic, but... is there any way that I can catch a pressed power button event through SDL, so that I can perform a clean system shutdown?

Thanks!

Carlos

until recent years the power button was just that. You press the button, it cuts the powerflow. If you have a computer like this, theres nothing you can do, because there isnt even power to send the message to your app which is starting to decay out of ram (o:

im kinda curious, what kind of things do you want your program to do on shutdown? There might be another way around this problem.----- Original Message -----
From: Carlos Vrancken
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 1:08 PM
Subject: Re: [SDL] Power down event

I’m using Linux and if I press the power button, the computer just goes off.

Any help?

Carlos
----- Original Message -----
From: DAMiEN
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 12:13 PM
Subject: Re: [SDL] Power down event

Isn't it up to your OS to send terminate signals to all runing apps when the computer is shutting down?

Best regards
Daniel Liljeberg
  ----- Original Message ----- 
  From: Carlos Vrancken 
  To: sdl at libsdl.org 
  Sent: Monday, January 26, 2004 6:09 PM
  Subject: [SDL] Power down event


  All,

      I know this might be a little off topic, but... is there any way that I can catch a pressed power button event through SDL, so that I can perform a clean system shutdown?

  Thanks!

  Carlos

This has nothing to do with SDL or even applications, so it’s very
off-topic for this list.

What you want to do is configure your BIOS and/or OS to handle the
power button in a nicer way. Depending on your hardware, this may not
be possible at all. Some mainboards just hard-wire the power button
so it kills the machine instantly or after 4 seconds or so. Not much
you can do about that, short of physically wiring the power button to
some input that you can read with a custom driver.

If your BIOS can turn power button presses into ordinary events of
some kind, the rest depends on your OS. In theory, it would be simple
to have a daemon wait for a “power button” message from some kernel
driver, and then run a script when the message arrives. I’m not sure
if there’s any standard way of getting that message, though.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 26 January 2004 22.08, Carlos Vrancken wrote:

I’m using Linux and if I press the power button, the computer just
goes off.

until recent years the power button was just that. You press the
button, it cuts the powerflow. If you have a computer like this,
theres nothing you can do, because there isnt even power to send
the message to your app which is starting to decay out of ram (o:

Though most computers in use these days are ATX based, which means
they have a power supply that’s controlled with a TTL line in the
power connector. The mainboard chipset and BIOS can chose to use this
line in any way they like - which is how a computer can turn itself
off after shutting down the OS.

im kinda curious, what kind of things do you want your program to
do on shutdown? There might be another way around this problem.

Save files and stuff, I guess… But that’s not much of an issue,
provided the OS shuts down properly. Just make sure your SDL apps
handle the SDL_QUIT event. OSes and desktop environments generally
try to close applications nicely before brutally killing them, so
this should cover all “acceptable” ways of shutting down.

It might be a good idea to also trap SIGINT and SIGTERM, though at
least on Linux, SDL does that by default. It sends an SDL_QUIT event
if you hit CTRL+C in the console or equivalent. (See signal() in
signal.h.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 26 January 2004 22.22, Alan Wolfe wrote:

Well, If we assume that you have an ATX system designed for the type of shutdown that you want, the correct settings are set in BIOS (you can set it to just turn off right away on most computers) and it works in Windows for you, then it’s kind of an indication that it is an OS feature so to speak.
I have however, on Mandrake end Linux noticed the behaviour you wish when the power button was pressed. And judging from what I saw I must say that I think the TERM signal was sent.
Try to see if your hardware should support it and your OS.
As Alan sais there might be another way around your problem, but if you really want to do something when the power button is pressed and that makes you computer shutoff at once, I doubt it…

GL though :wink:

Best Regards
Daniel Liljeberg----- Original Message -----
From: Alan Wolfe
To: sdl at libsdl.org
Sent: Monday, January 26, 2004 10:22 PM
Subject: Re: [SDL] Power down event

until recent years the power button was just that. You press the button, it cuts the powerflow. If you have a computer like this, theres nothing you can do, because there isnt even power to send the message to your app which is starting to decay out of ram (o:

im kinda curious, what kind of things do you want your program to do on shutdown? There might be another way around this problem.

----- Original Message ----- 
From: Carlos Vrancken 
To: sdl at libsdl.org 
Sent: Monday, January 26, 2004 1:08 PM
Subject: Re: [SDL] Power down event


I'm using Linux and if I press the power button, the computer just goes off.

Any help?

Carlos
  ----- Original Message ----- 
  From: DAMiEN 
  To: sdl at libsdl.org 
  Sent: Monday, January 26, 2004 12:13 PM
  Subject: Re: [SDL] Power down event


  Isn't it up to your OS to send terminate signals to all runing apps when the computer is shutting down?

  Best regards
  Daniel Liljeberg
    ----- Original Message ----- 
    From: Carlos Vrancken 
    To: sdl at libsdl.org 
    Sent: Monday, January 26, 2004 6:09 PM
    Subject: [SDL] Power down event


    All,

        I know this might be a little off topic, but... is there any way that I can catch a pressed power button event through SDL, so that I can perform a clean system shutdown?

    Thanks!

    Carlos

some kind, the rest depends on your OS. In theory, it would be
simple to have a daemon wait for a “power button” message from some
kernel driver, and then run a script when the message arrives. I’m
not sure if there’s any standard way of getting that message,
though.

ACPI button event.–
Petri Latvala
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040128/0c9de376/attachment.pgp

Well, If we assume that you have an ATX system designed for the type
of shutdown that you want, the correct settings are set in BIOS (you
can set it to just turn off right away on most computers) and it
works in Windows for you, then it’s kind of an indication that it is
an OS feature so to speak. I have however, on Mandrake end Linux
noticed the behaviour you wish when the power button was pressed. And
judging from what I saw I must say that I think the TERM signal was
sent. Try to see if your hardware should support it and your OS.
As Alan sais there might be another way around your problem, but if
you really want to do something when the power button is pressed and
that makes you computer shutoff at once, I doubt it…

acpid is the daemon that listens acpi events. The possible events depend
ones acpi configuration.

From 2.6.x kernel configuration.

ACPI (Advanced Configuration and Power Interface) Support

CONFIG_ACPI=y
CONFIG_ACPI_BOOT=y
CONFIG_ACPI_INTERPRETER=y
CONFIG_ACPI_SLEEP=y
CONFIG_ACPI_SLEEP_PROC_FS=y

CONFIG_ACPI_AC is not set

CONFIG_ACPI_BATTERY is not set

CONFIG_ACPI_BUTTON=y
CONFIG_ACPI_FAN=y
CONFIG_ACPI_PROCESSOR=y
CONFIG_ACPI_THERMAL=y

CONFIG_ACPI_ASUS is not set

CONFIG_ACPI_TOSHIBA is not set

CONFIG_ACPI_DEBUG is not set

CONFIG_ACPI_BUS=y
CONFIG_ACPI_EC=y
CONFIG_ACPI_POWER=y
CONFIG_ACPI_PCI=y
CONFIG_ACPI_SYSTEM=y

CONFIG_ACPI_RELAXED_AML is not set

So when one has the CONFIG_ACPI_BUTTON=y
then the power button press sends event.

If the button is held down n seconds then the power is shut down
immediately. This of course needs that BIOS is set to handle the power
button press this way. It can be set to immediate, which means that the
power is shut the moment the button is pressed.On Tuesday 27 January 2004 00:25, DAMiEN wrote: