Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 20th, 2010 | Syntax: Lua | Size: 8.23 KB | Hits: 67 | Expires: Never
Copy text to clipboard
  1. root@htcdream ~ $ cat /etc/freesmartphone/oevents/rules.yaml
  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.     #                                                                                  
  26.     # Call -> Audio Scenario Handling                                                  
  27.     #                                                                                  
  28.     trigger: IncomingMessage()                                                        
  29.     actions: MessageTone(play)                                                        
  30.  
  31. -
  32.     while: CallListContains("incoming")
  33.     filters: Not(CallListContains("active"))
  34.     actions:                                
  35.              - RingTone()                  
  36.              - Command('xset -display localhost:0 s reset')
  37.              - SetLed("green", "blink")                    
  38.              - OccupyResource(Display)                    
  39. -                                                          
  40.     while: CallStatus()                                    
  41.     filters: Or(HasAttr(status, "outgoing"), HasAttr(status, "active"))
  42.     actions:                                                          
  43.             - OccupyResource(CPU)                                      
  44. -                                                                      
  45. #    while: CallStatus()                                              
  46. #    filters:                                                          
  47. #            - Or(Or(HasAttr(status, "outgoing"), HasAttr(status, "active")), And(HasAttr(status, "incoming"), CallListContains("active")))
  48. #            - Not(BTHeadsetIsConnected())                                                                                                
  49. #    actions:                                                                                                                              
  50. #            - SetScenario(gsmhandset)                                                                                                    
  51. #-                                                                                                                                        
  52.     while: CallStatus()                                                                                                                    
  53.     filters:                                                                                                                              
  54.             - Or(Or(HasAttr(status, "outgoing"), HasAttr(status, "active")), And(HasAttr(status, "incoming"), CallListContains("active")))
  55.             - BTHeadsetIsConnected()                                                                                                      
  56.     actions:                                                                                                                              
  57.             - SetScenario(gsmbluetooth)                                                                                                    
  58.             - BTHeadsetPlaying()                                                                                                          
  59. -                                                                                                                                          
  60.     while: PowerStatus()                                                                                                                  
  61.     filters: HasAttr(status, "charging")                                                                                                  
  62.     actions: SetLed("blue", "light")                                                                                                      
  63.  
  64. -
  65.     while: PowerStatus()
  66.     filters: Not(HasAttr(status, "discharging"))
  67.     actions: OccupyResource(CPU)                
  68.  
  69. -
  70.     while: PowerStatus()
  71.     filters: HasAttr(status, "critical")
  72.     actions: SetLed("red", "blink")    
  73. -                                      
  74.     while: PowerStatus()                
  75.     filters: HasAttr(status, "full")    
  76.     actions: SetLed("green", "light")  
  77. -                                      
  78.     trigger: PowerStatus()              
  79.     filters: HasAttr(status, "empty")  
  80.     actions: Command('poweroff')        
  81.  
  82.     #
  83.     # Headset Audio Scenario Support. There is still work to be done.
  84.     #                                                                
  85. -                                                                    
  86.     trigger: InputEvent()                                            
  87.     filters:                                                          
  88.              - HasAttr(switch, "HEADSET")                            
  89.              - HasAttr(event, "pressed")                              
  90.     actions: Command('amixer -d sset "Amp Spk" mute')                
  91. -                                                                    
  92.     trigger: InputEvent()                                            
  93.     filters:                                                          
  94.              - HasAttr(switch, "HEADSET")                            
  95.              - HasAttr(event, "released")                            
  96.     actions: Command('amixer -d sset "Amp Spk" unmute')              
  97.  
  98.  
  99.     #
  100.     # Idleness Brightness Handling
  101.     # (activating the user's screen saver from a central daemon is quite hacky
  102.    #  we really want some user's application to listen for the right signals)
  103. -
  104.     while: IdleState()
  105.     filters: HasAttr(status, "busy")
  106.     actions:
  107.              - SetLed("lcd_backlight", "light")
  108.              - SetLed("button_backlight", "light")
  109.              - SetLed("keyboard_backlight", "light")
  110. -
  111.     trigger: IdleState()
  112.     filters: HasAttr(status, "idle_dim")
  113.     actions:
  114.              - Command('xset -display localhost:0 s blank')
  115.              - Command('xset -display localhost:0 s activate')
  116. -
  117.     trigger: IdleState()
  118.     filters: HasAttr(status, "suspend")
  119.     actions:
  120.              - Suspend()
  121. -
  122.     trigger: InputEvent()
  123.     filters:
  124.             - HasAttr(status, "suspend")
  125.             - HasAttr(key, "POWER")
  126.             - HasAttr(event, "pressed")
  127.     actions:
  128.              - Command('/usr/bin/susres')
  129. -
  130.     trigger: InputEvent()
  131.     filters:
  132.              - HasAttr(switch, "LID")
  133.              - HasAttr(event, "pressed")
  134.     actions:
  135.             - SetLed("keyboard_backlight", "light")
  136.             - SetLed("button_backlight", "light")
  137.             - SetLed("lcd_backlight", "light")
  138.             - Command('/usr/bin/susres')
  139.             - Debug("Lid Opened")