File: README.scripts

package info (click to toggle)
powersave 0.14.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,764 kB
  • ctags: 999
  • sloc: sh: 11,357; cpp: 8,103; ansic: 2,631; makefile: 388
file content (51 lines) | stat: -rw-r--r-- 1,997 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
All scripts must use powersaved_script_return to tell powersaved
when the event is finished. Otherwise no other event will be started
until the previous event times out (after 120 seconds).

The syntax is:@*
    powersaved_script_return $EVENT_ID $RET "$MESSAGE"

$EVENT_ID is the number given to the script as positional parameter $4.@*
$MESSAGE is just informal, except for return codes 2 and 4.@*
Possible return codes $RET are:@*
    0 - execution of the event finished successfully@*
    1 - execution of the event finished, but failed@*
    2 - request a popup by the client, event not finished@*
    3 - request a screenlock by the client, event not finished@*
    4 - request a progress bar popup by the client, event not finished@*
There may be additional codes added in the future.

This is example code to use in your own scripts:@*
@code{
#!/bin/bash@*
# example script for events in powersaved@*
# parameters:@*
# - $1 event type@*
# - $2 current scheme@*
# - $3 ACPI event line@*
# - $4 Event-ID. Needed for $SCRIPT_RETURN@*
#
# source helper_functions to get $PATH, $SCRIPT_RETURN, EV_ID (among others)@*
. /usr/lib/powersave/scripts/helper_functions@*
# Note: this sets a trap on "EXIT", so you must exit the script via the@*
# (also provided) EXIT function after calling $SCRIPT_RETURN@*
# If you don't call EXIT, the trap will call $SCRIPT_RETURN with return code 1@*
#@*
# this is stupid, you'd like to do something useful here :-)@*
case $3 in@*
    button*)@*
        logger "button-event"@*
        ;;@*
    *)  logger "non-button-event"@*
        $SCRIPT_RETURN $EV_ID 1 example script failed"@*
        EXIT 1@*
        ;;@*
esac@*
# always call $SCRIPT_RETURN before exiting:@*
$SCRIPT_RETURN $EV_ID 0 "example script succeeded"@*
EXIT 0@*
}

There are various scripts in the contrib directory (the "example_event_script"
has comments on what is provided by helper_functions) or have a look at the
simple "debug_events" script in the scripts directory for other examples.