Author Topic: Bind key to suspend  (Read 5649 times)

clafou34

  • Guest
Bind key to suspend
« on: February 08, 2015, 07:44:16 AM »
Hello,

  I want to bind a key (or joystick button) to launch a command line (for put computer in suspend mode). But, i not found any solution.

  In UI, I found binding for "Custom 1" and "Custom 2", but I can't found how to assign command line to this binding.

  Someone know how to do this ?

Thank

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Bind key to suspend
« Reply #1 on: February 09, 2015, 07:51:45 AM »
Yes you could do this using the Custom 1/Custom 2 UI bindings... here's how:

1.  Paste the following into a file called "MyCustomCommand.nut" in the plugin directory of your Attract-Mode setup:
Code: [Select]
fe.add_signal_handler( "custom_signal" )
function custom_signal( signal )
{
if ( signal == "custom1" )
{
fe.plugin_command( "@EXECUTABLE", "@CL_PARAMETERS" );
}
}

Replace @EXECUTABLE with the name of the executable you want to run.  Replace @CL_PARAMETERS with any command line parameters that need to be passed to the executable

2.  Go into the plugin configuration and set the MyCustomCommand plugin as enabled

Now whatever keys you map to the "Custom 1" inputs in the config will trigger your executable to run...

cheers

clafou34

  • Guest
Re: Bind key to suspend
« Reply #2 on: February 10, 2015, 12:46:09 PM »
Hello,

  It works well. Thank you very much.

  It should be in the documentation.

Bye


raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile

noxx

  • Full Member
  • ***
  • Posts: 29
    • View Profile
Re: Bind key to suspend
« Reply #4 on: April 23, 2017, 07:48:31 AM »
i try this to reboot system, but will not work

i add a file MyCustomCommand.nut to /home/pi/.attract/plugins
Code: [Select]
fe.add_signal_handler( "custom_signal" )
function custom_signal( signal )
{
if ( signal == "custom1" )
{
fe.plugin_command( "@EXECUTABLE", "sudo reboot" );
}
}

or

Code: [Select]
fe.add_signal_handler( "custom_signal" )
function custom_signal( signal )
{
if ( signal == "custom1" )
{
fe.plugin_command( "/home/pi/.attract/Attract Mode Setup/Reboot.sh", "@CL_PARAMETERS" );
}
}

but nothing happens
« Last Edit: April 23, 2017, 07:53:00 AM by noxx »

noxx

  • Full Member
  • ***
  • Posts: 29
    • View Profile
Re: Bind key to suspend
« Reply #5 on: April 23, 2017, 10:09:10 AM »
solved, forget to enable this "plugin" in the settings menu