Ticket #458: rules.yaml

File rules.yaml, 5.2 KB (added by arne.anka, 3 years ago)

oeventsd/rules.yaml

Line 
1
2# This file is in YAML format (http://www.yaml.org/)
3# We define a list of rules that will be automatically loaded
4# When we start the oevents module of the framework daemon
5#
6# The attributes of a rule are :
7# - trigger     : trigger object
8# - filters     : filters object or list of filters objects
9# - actions     : action object or list of actions objects
10#
11# We define the following functions :
12# - CallStatus()            : create a trigger object activated on a call status event
13# - PowerStatus()           : create a trigger object activated on a power status event
14# - HasAttr(name, value)    : create a filter that accept signal with a given attribute
15# - Not(filter)             : create a neg filter
16# - PlaySound(file)         : Action that starts to play an audio file
17# - StopSound(file)         : Action that stop an audio file
18# - SetScenario(name)       : Action that sets an audio scenario
19# - StartVibration
20# - StopVibration
21# - RingTone(cmd)           : cmd can be 'start' or 'stop'
22# - Time(hour, min)         : create a trigger activated at the given time
23# - Debug(msg)              : Action that prints a debug message (only for debuging)
24-
25    trigger: Time(12,29)
26    actions: Debug("A Test")
27-
28    #
29    # Suspend Handling
30    #
31    trigger: InputEvent()
32    filters:
33             - HasAttr(switch, "POWER")
34             - HasAttr(event, "released")
35             - HasAttr(duration, 0)
36    actions: Suspend()
37-
38    #
39    # Call -> Audio Scenario Handling
40    #
41    trigger: IncomingMessage()
42    actions: MessageTone(play)
43
44-
45    while: CallListContains("incoming")
46    filters: Not(CallListContains("active"))
47    actions:
48             - RingTone()
49             - SetDisplayBrightness("0", 50)
50             - OccupyResource(CPU)
51
52-
53    while: CallStatus()
54    filters: Or(HasAttr(status, "outgoing"), HasAttr(status, "active"))
55    actions:
56            - SetScenario(gsmhandset)
57            - OccupyResource(CPU)
58
59-
60    while: CallStatus()
61    filters:
62            - Or(HasAttr(status, "outgoing"), HasAttr(status, "active"))
63            - Not(BTHeadsetIsConnected())
64    actions:
65            - SetScenario(gsmhandset)
66-
67    while: CallStatus()
68    filters:
69            - Or(HasAttr(status, "outgoing"), HasAttr(status, "active"))
70            - BTHeadsetIsConnected()
71    actions:
72            - SetScenario(gsmbluetooth)
73            - BTHeadsetPlaying()
74
75#-
76#    while: PowerStatus()
77#    filters: Not(HasAttr(status, "discharging"))
78#    actions: OccupyResource(Display)
79
80-
81    while: PowerStatus()
82    filters: HasAttr(status, "charging")
83    actions: SetLed("gta02_power_orange", "light")
84-
85    while: PowerStatus()
86    filters: HasAttr(status, "discharging")
87    actions: SetLed("gta02_power_blue", "light")
88-
89    while: PowerStatus()
90    filters: HasAttr(status, "critical")
91    actions: SetLed("gta02_power_orange", "blink")
92-
93    while: PowerStatus()
94    filters: HasAttr(status, "full")
95    actions: SetLed("gta02_power_blue", "light")
96-
97    trigger: PowerStatus()
98    filters: HasAttr(status, "empty")
99    actions: Command('poweroff')
100
101    #
102    # Headset Audio Scenario Support
103    #
104-
105    trigger: InputEvent()
106    filters:
107             - HasAttr(switch, "HEADSET")
108             - HasAttr(event, "pressed")
109    actions:
110             - Command('amixer -d sset "Amp Spk" mute')
111             - SetScenario(gsmheadset)
112
113-
114    trigger: InputEvent()
115    filters:
116             - HasAttr(switch, "HEADSET")
117             - HasAttr(event, "released")
118    actions:
119             - Command('amixer -d sset "Amp Spk" unmute')
120             - SetScenario(gsmhandset)
121
122
123    #
124    # usb plug out
125    #
126-
127    trigger: InputEvent()
128    filters:
129             - HasAttr(switch, "USB")
130             - HasAttr(event, "released")
131    actions: SetLed("gta02_power_blue", "light")
132
133    #
134    # A few testing rules :
135    #
136
137    # This rule will only be enabled in silent mode
138    # According to the preferences rules conf files.
139-
140    name: 'test-rule'
141    trigger: IdleState()
142    filters: HasAttr(status, "busy")
143    actions: Debug("Hello This is a test")
144-
145    trigger: Test("test")
146    actions: Debug("trigger test")
147-
148    while: Test("test2")
149    actions: RingTone()
150-
151    trigger: DbusTrigger(system, 'org.freesmartphone.odeviced', 0, 'org.freesmartphone.Device.IdleNotifier', 'State')
152    actions: Debug("dbus trigger test")
153
154
155    #
156    # Idleness Brightness Handling
157    #
158#-
159#    trigger: IdleState()
160#    filters: HasAttr(status, "awake")
161#    actions:
162#             - SetDisplayBrightness("0", 50)
163#             - SetLed("gta02_power_blue", "light")
164-
165    trigger: IdleState()
166    filters: HasAttr(status, "busy")
167    actions: SetDisplayBrightness("0", 50)
168-
169    trigger: IdleState()
170    filters: HasAttr(status, "idle_dim")
171    actions: SetDisplayBrightness("0", 15)
172-
173    trigger: IdleState()
174    filters: HasAttr(status, "idle_prelock")
175    actions: SetDisplayBrightness("0", 0)
176-
177    trigger: IdleState()
178    filters: HasAttr(status, "lock")
179    actions: SetLed("gta02_power_blue", "blink")
180
181    # suspend after in frameworkd.conf set time
182    # fso reaches state suspend and now we act accordingly
183-
184    trigger: IdleState()
185    filters:
186             - HasAttr(status, "suspend")
187             - Not(CallListContains("active"))
188    actions:
189             - SetLed("gta02_power_blue", "light")
190             - Suspend()
191