Mohsen Jamali | 23 Jun 2012 14:39
Picon
Gravatar

Problem with SDL when coming back from suspend mode in Debian

Hi guys :)
i have an SDL program that runs ok when i run it from shell. also i have an script that i have put it in startup applications of Gnome/Debian that runs the program automatically when system boots. i have decided to autostart my app when the machine comes back from suspend mode so i put this script in

"/etc/pm/sleep.d/myscript"

#! /bin/sh
case "$1" in
        thaw|resume)
               /home/p/Desktop/myscript
               ;;
        *)
               ;;
esac
exit $?

this script simply run my app after coming back from suspend mode!
http://ubuntuforums.org/showthread.php?t=1484156
after coming back from suspend mode, my app runs well but my app has just get 2/3 of screen and the other areas are black and any key doesn't work.
i decided to remove the script from /etc/pm/sleep.d and run my app by myself. in this way my app works correctly, i think something shoul be wrong with running my script from sleep.d
does anyone has any idea? thanks.





_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Mohsen Jamali | 24 Jun 2012 10:09
Picon
Gravatar

Problem with SDL when coming back from suspend mode in Debian

Hi guys :)
i have an SDL program that runs ok when i run it from shell. also i have an script that i have put it in startup applications of Gnome/Debian that runs the program automatically when system boots. i have decided to autostart my app when the machine comes back from suspend mode so i put this script in

"/etc/pm/sleep.d/myscript"

#! /bin/sh
case "$1" in
        thaw|resume)
               /home/p/Desktop/myscript
               ;;
        *)
               ;;
esac
exit $?

this script simply run my app after coming back from suspend mode!
http://ubuntuforums.org/showthread.php?t=1484156
after coming back from suspend mode, my app runs well but my app has just get 2/3 of screen and the other areas are black and any key doesn't work.
i decided to remove the script from /etc/pm/sleep.d and run my app by myself. in this way my app works correctly, i think something shoul be wrong with running my script from sleep.d
does anyone has any idea? thanks.






_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Torsten Giebl | 24 Jun 2012 10:25

Re: Problem with SDL when coming back from suspend mode in Debian

Hello !

> i have an SDL program that runs ok when i run it from shell. also i have an
> script that i have put it in startup applications of Gnome/Debian that runs
> the program automatically when system boots. i have decided to autostart my
> app when the machine comes back from suspend mode so i put this script in
> 
> "/etc/pm/sleep.d/myscript"
> 
> #! /bin/sh
> case "$1" in
>         thaw|resume)

Please try if changing this line from :

                /home/p/Desktop/myscript

to:

                su -u p -c "/home/p/Desktop/myscript"

helps, it might.
If p is your user name, i guessed from /home/p/...

CU
Mohsen Jamali | 25 Jun 2012 08:56
Picon
Gravatar

Re: Problem with SDL when coming back from suspend mode in Debian

su -u p -c "/home/p/Desktop/myscript"
su: invalid option -- 'u'
Usage: su [options] [LOGIN]

Options:
  -c, --command COMMAND         pass COMMAND to the invoked shell
  -h, --help                    display this help message and exit
  -, -l, --login                make the shell a login shell
  -m, -p,
  --preserve-environment        do not reset environment variables, and
                                keep the same shell
  -s, --shell SHELL             use SHELL instead of the default in passwd

It seems that -u doesn't work. is there any other option that could help?
i have also tried su -c "/home/p/Desktop/myscript" but have the same problem again
and looket at sudo but it doesn't have any switch like -c to invoke my app from shell

On Sun, Jun 24, 2012 at 12:55 PM, Torsten Giebl <wizard <at> syntheticsw.com> wrote:
Hello !


> i have an SDL program that runs ok when i run it from shell. also i have an
> script that i have put it in startup applications of Gnome/Debian that runs
> the program automatically when system boots. i have decided to autostart my
> app when the machine comes back from suspend mode so i put this script in
>
> "/etc/pm/sleep.d/myscript"
>
> #! /bin/sh
> case "$1" in
>         thaw|resume)

Please try if changing this line from :

               /home/p/Desktop/myscript

to:

               su -u p -c "/home/p/Desktop/myscript"

helps, it might.
If p is your user name, i guessed from /home/p/...


CU
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Torsten Giebl | 25 Jun 2012 09:21

Re: Problem with SDL when coming back from suspend mode in Debian

Hello !

> su -u p -c "/home/p/Desktop/myscript"
> su: invalid option -- 'u'
> Usage: su [options] [LOGIN]
> 
> Options:
>   -c, --command COMMAND         pass COMMAND to the invoked shell
>   -h, --help                    display this help message and exit
>   -, -l, --login                make the shell a login shell
>   -m, -p,
>   --preserve-environment        do not reset environment variables, and
>                                 keep the same shell
>   -s, --shell SHELL             use SHELL instead of the default in passwd
> 
> It seems that -u doesn't work. is there any other option that could help?
> i have also tried su -c "/home/p/Desktop/myscript" but have the same
> problem again
> and looket at sudo but it doesn't have any switch like -c to invoke my app
> from shell

Please try :

su p -c "/home/p/Desktop/myscript"

p being the username.

CU
Mohsen Jamali | 25 Jun 2012 09:55
Picon
Gravatar

Re: Problem with SDL when coming back from suspend mode in Debian

Same problem again :(

but think my problem can solve in another way!
when the user press power/suspend key my app will exit, is ther any way to pass the power/suspend key to Debian and let Debian handle it(suspend the machine) ? in this way my app won't exit and no problem will occur :)

my code for handling keyboard is as simple as this:
SDL_Event event;
    int keypress = 0;

     while(!keypress)
    {
         while(SDL_PollEvent(&event))
         {     
              switch (event.type)
              {
                  case SDL_QUIT:
                  keypress = 1;
                  break;
                  case SDL_KEYDOWN:
                       keypress = 1;
                       break;
                  //I want to say if key is power/suspend pass it to debian to handle it and don't exit my app
              }
         }
    }


On Mon, Jun 25, 2012 at 11:51 AM, Torsten Giebl <wizard <at> syntheticsw.com> wrote:
Hello !


> su -u p -c "/home/p/Desktop/myscript"
> su: invalid option -- 'u'
> Usage: su [options] [LOGIN]
>
> Options:
>   -c, --command COMMAND         pass COMMAND to the invoked shell
>   -h, --help                    display this help message and exit
>   -, -l, --login                make the shell a login shell
>   -m, -p,
>   --preserve-environment        do not reset environment variables, and
>                                 keep the same shell
>   -s, --shell SHELL             use SHELL instead of the default in passwd
>
> It seems that -u doesn't work. is there any other option that could help?
> i have also tried su -c "/home/p/Desktop/myscript" but have the same
> problem again
> and looket at sudo but it doesn't have any switch like -c to invoke my app
> from shell

Please try :

su p -c "/home/p/Desktop/myscript"

p being the username.


CU
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Gordon Henderson | 25 Jun 2012 10:33
Favicon

Re: Problem with SDL when coming back from suspend mode in Debian

On Mon, 25 Jun 2012, Mohsen Jamali wrote:

> Same problem again :(
>
> but think my problem can solve in another way!
> when the user press power/suspend key my app will exit, is ther any way to
> pass the power/suspend key to Debian and let Debian handle it(suspend the
> machine) ? in this way my app won't exit and no problem will occur :)

Intercepting the power key might need a BIOS change to make it return 
suspend rather than power-down, also some GUI's intercept it too 
and pop-up a confirm window, however...

In general, power buttons, lid close buttons (laptop) suspend, etc. are 
controlled by the ACPI systems, so look in /etc/acpi/events for scripts to 
be actioned on these events. Also make sure you have acpi installed -

   sudo apt-get install acpi

Then go check on the Debian websites, etc. Suspend doesn't normally kill 
programs.

So as a quickie, on my laptops, I change /etc/acpi/lid.sh to simply call 
/usr/sbin/pm-suspend than go through all the other stuff to check...

Gordon
Mohsen Jamali | 25 Jun 2012 20:46
Picon
Gravatar

Re: Problem with SDL when coming back from suspend mode in Debian

Thanks Torsten&Gordon :)
solved that with this spaghetti :)

  while(!keypress)
    {
      char *s;
      while(SDL_PollEvent(&event))
    {     
      switch (event.type)
        {
        case SDL_QUIT:
          keypress = 1;
          break;
        case SDL_KEYDOWN:
              
          s=SDL_GetKeyName(event.key.keysym.sym);
          printf("The %s was pressed !\n",s);
          if(strcmp(s,"unknown key")==0)
        {
          printf("unknown key\n");
          system("sudo pm-suspend");
//          ftStatus = FT_Purge(ftHandle, FT_PURGE_RX | FT_PURGE_TX); // Purge both Rx and Tx bu
          break;
        }else{
        keypress = 1;
        break;           
          }
        }
    }

    }
On Mon, Jun 25, 2012 at 1:03 PM, Gordon Henderson <gordon+sdl <at> drogon.net> wrote:
On Mon, 25 Jun 2012, Mohsen Jamali wrote:

Same problem again :(

but think my problem can solve in another way!
when the user press power/suspend key my app will exit, is ther any way to
pass the power/suspend key to Debian and let Debian handle it(suspend the
machine) ? in this way my app won't exit and no problem will occur :)

Intercepting the power key might need a BIOS change to make it return suspend rather than power-down, also some GUI's intercept it too and pop-up a confirm window, however...

In general, power buttons, lid close buttons (laptop) suspend, etc. are controlled by the ACPI systems, so look in /etc/acpi/events for scripts to be actioned on these events. Also make sure you have acpi installed -

 sudo apt-get install acpi

Then go check on the Debian websites, etc. Suspend doesn't normally kill programs.

So as a quickie, on my laptops, I change /etc/acpi/lid.sh to simply call /usr/sbin/pm-suspend than go through all the other stuff to check...

Gordon

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane