Execute shell command

Registered by Greg MacLellan

Create a special template called "turn off display", which can be scheduled to turn off displays. In Xibo client, add ability to control Windows power management options, and run external commands based on this layout's activity. This allows a great deal of flexibility in power options client-side, but also to be managed using the existing schedule system.

Blueprint information

Status:
Complete
Approver:
Alex Harrington
Priority:
Low
Drafter:
None
Direction:
Approved
Assignee:
Dan Garner
Definition:
Approved
Series goal:
Accepted for 1.3
Implementation:
Implemented
Milestone target:
milestone icon 1.3.3
Started by
Dan Garner
Completed by
Dan Garner

Sprints

Whiteboard

Server side:

Create a special template called "turn off display", which can be scheduled to turn off displays. A default "turn off display" layout should be created that uses this template.

There is not much more that needs to be done, as the existing schedule system can be used as-is.

Client side:

In Xibo client, disallow power management from timing out the display EXCEPT when the "turn off display" layout is being used -- this covers cases where Xibo is using a regular computer monitor (and so Windows already provides power management). It would be up to the user to set up Windows power management options appropriately.

There should also be two options to Xibo client added, "command to run to turn off display" and "command to run to turn on display". These would be used to run custom executables. This would allow full customization of actions on a per-client basis, such as running a program to send RS-232 commands, or a batch file that sets a BIOS wakeup timer and then shuts down the system. Potentially %parameters% can be made available to the command-line, such as the number of minutes until the next scheduled non-"turn off display" template, which would allow full server-side control of these options once the initial setup is done.

The SetThreadExecutionState (http://msdn.microsoft.com/en-us/library/aa373233%28VS.85%29.aspx) function can be used to prevent display timeout. It is designed for apps such as video or presentations, which is exactly what Xibo is.

Xibo client would need to check for transitions between the "turn off display" template and non-"turn off display" templates, and then act appropriately (eg, there is a procedure to run for the transition to "off" and another to run for "on"). At this time, calls to SetThreadExecutionState and any custom commands (if entered) would be run.

---

The command options cover https://blueprints.launchpad.net/xibo/+spec/rs232-command-support (note that spec is also suggesting a "Screen is off" layout).

This blueprint also probably supersedes https://blueprints.launchpad.net/xibo/+spec/client-wake-up (as it provides a more generic mechanism to accomplish what is being requested).

Also supersedes https://blueprints.launchpad.net/xibo/+spec/display-control-via-svga

---

AH: I've marked those two blueprints as superseded as it makes sense to me. The magic layout is how Dan and I had envisaged implementing this as it also gives you nice functionallity to override the power off with an Priority layout etc (for example if there's an event in the building that goes on later every now and again).

I think having a pluggable system client side to call various functions makes sense too - so that RS232 and direct Power Management of screens can drop out too.

Andres: If a layout have no region and no media can be treated as a power off layout. With this the name of the layout is not importante and the implementation is simpler with no need for any change on the server.
I have begin to code this option with good progress in NET client.
Alex is possible to change this to version 1.4? the code is simple and can be done in one or two weeks.

AH: While your solution is neat, and we certainly won't object to you building a custom version of the client with that functionality and uploading it in to Launchpad for those who can't wait, we really want to build something that's more extensible than just turning the screen on and off. We want to build some mechanism which allows for numerous arbritary outputs on the client to be triggered - which could include things like screen power but also RS232 commands (controlling tv channels or volume), or loading other applications etc.

DG: New module called shell command, which allows a command with arguments to be specified - this command is then executed on the client when it appears in a layout in the schedule. As discussed, this can be used to achieve almost anything by using batch files, external programs, etc.
Also included is a box for linux command, if we choose the emulate the behavious in the python client.

(?)

Work Items

Work items:
Implement Module in server: DONE
Implement Module in client: DONE
Implement options to restrict command execution: TODO

This blueprint contains Public information 
Everyone can see this information.