-
Notifications
You must be signed in to change notification settings - Fork 0
How to Create a Plugin
A plugin can have different configurations. These configurations determine which type of script the plugin is. The different types are One Shot, Periodic, and Persistent Scripts.
###Sample Projects
- [XKCD Comic Plugin] (./Basic-Web-Plugin-Example)
##Plugin Directory Skeleton
The folder structure for a plugin is as follows:
<webdirectory>/
-><pluginsdirectory>/
-><pluginname>/
- ->
plugin.conf
- ->
<plugin>.html
* - ->
<plugin>.css
* - ->
<plugin>.js
* - -> (other directories for extra content)*
*as defined in the plugin.conf
file
<webdirectory>
and <pluginsdirectory>
are defined as command line options for the Plugin Daemon. <pluginname>
is the public name of your plugin.
##Plugin Configuration Creation Plugin Configuration files are created with various options found [here] (./Plugin-Configuration)
###Configuring a Plugin for One Shot Runtime This type of script will only execute once if it is enabled or loaded on start up.
A script-path
must be defined. This path can be bash script, python script, etc. as long as it is executable.
Example One Shot Script
#!/bin/bash
#outputs the system's local ip address for wireless or cabled interface
#get the current ip address of the machine
iface=$(ifconfig wlan0)
if [ $? -ne 0 ]; then
iface=$(ifconfig eth0)
fi
if [ $? -ne 0 ]; then
echo "Error grabbing IP Address..."
exit 1
fi
echo "$iface" | egrep -o "addr:([0-9]{1,3}[\.]?){4}" | sed 's/addr://g'
exit 0
To make a script executable, use chmod +x <script name>
in the terminal
script-timer
must be set as a negative value in the plugin.conf
Example Configuration File
#period in which to execute script in seconds
#negative values indicate that the script is to be only executed once
#at abs(script-timer) seconds after the daemon connects to the display.
script-timer=-1
A full sample script can be found [here] (link to oneshot script example)
###Configuring a Plugin for Periodic Runtime
Periodic scripts are One Shot Scripts that are executed at every set interval defined in script-timer
. Its output changes for every execution
A script-path
must be defined.
Example Periodic Script
#!/bin/bash
#prints out the current data and time
#some command that has different output every time this script runs...
date
script-timer
must have a value > 0 as seconds
Example Configuration File
#period in which to execute script in seconds
script-timer=1
###Configuring a Plugin for Persistent Runtime A Persistent Script is a script that runs in its own child process. The plugin is responsible for all communications to the display. See sample program for more information
A script-path
must be defined and script-background
must be set to true.
Example Configuration File
#indicate this script is its own program
script-background=true
###Non-Script Plugins
These plugins send over html and javascript files to the display. They utilize the js-path
, html-path
, css-path
, and js-main-obj
configuration options.
NOTE: All plugins, when instantiated, have their own div containers on the display with an ID set to the name of the plugin, as defined by the plugin folder's name.
For example: If you have a plugin in directory <webdirectory>/
-><pluginsdirectory>/
->Clock/
the display will create a div with an ID as Clock:
<div id="Clock">
<!--included html file content from 'plugin.conf'>
</div>
The div id is case sensitive and may be used in the Plugin's CSS file for styling