A control is a ruby class that will be called by the command protocol “control control_name [arguments]” sent by the client to the server. Actually, a control is a specific action, for example the amarok control class is composed of one or several methods to manage amarok application on linux OS.
Each control is located in the “server/controls” directory.
There is another method to create a specific action for remote controlling : exec.
When you create a control, you beneficiate of ruby's power and flexibility.
On top of that, whenever the server executes a control, it keeps persistent data in the client context because each control call is made by the same class instance. For example, if you want to set the volume to a value and keep this value all the time to do a simple incrementation to increase the volume, you can store this value in a class member.
Finally, the last features offered by PwrCtl controls are :
Let's see an example :
class Demo
## OPTIONAL: Plaforms supported
PLATFORMS = ['windows', 'linux']
## OPTIONAL: Control initialization
def initialize
puts 'Demo control initialized'
end
## REQUIRED: Control entry point
# args is an Array containing the control arguments
def run(args)
message('Control Demo ok :)', :info)
end
end
These are optional:
These are required:
Please note it's very important to name your control class <your control name>.capitalize. For example if you want to create the “amarok” control, name it “Amarok” when your create the class.