summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--script/uactivity/activity/-20-graphlcd_dbus2vdr54
-rw-r--r--script/uactivity/activity/-20-switch_tv20
-rw-r--r--script/uactivity/key/-10-syslog_demo6
-rw-r--r--script/uactivity/watchdog/-10-syslog_demo9
-rw-r--r--uactivity.c48
6 files changed, 138 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..84970f2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.dependencies
+*.so
+*.o
+Makefile
+po/*.mo
+po/uactivity.pot
diff --git a/script/uactivity/activity/-20-graphlcd_dbus2vdr b/script/uactivity/activity/-20-graphlcd_dbus2vdr
new file mode 100644
index 0000000..010dfbe
--- /dev/null
+++ b/script/uactivity/activity/-20-graphlcd_dbus2vdr
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Do not use the graphlcd plugin commandline or udev to connect the display.
+# The display will be controlled only by this Script based upton user activity
+
+# Enter here the display specific values
+#
+DISPLAY="serdisp"
+SKIN="sdc_240x128"
+SWITCH_OFF_CMD="sdcmegtron_tool -b 0"
+SWITCH_ON_CMD=""
+#
+# END OF CONFIG SECTION
+
+
+
+switch_lcd(){
+ if [ "${1}" = "on" ]; then
+ # switch display on
+ [ -n "${SWITCH_ON_CMD}" ] && ${SWITCH_ON_CMD}
+ # connect the display to graphlcd
+ /usr/bin/dbus-send --system --type=method_call --dest=de.tvdr.vdr /Plugins/graphlcd de.tvdr.vdr.plugin.SVDRPCommand string:"connect" string:"${DISPLAY} ${SKIN}"
+ else
+ # disconnect the display from graphlcd
+ # " > /dev/null" because "--print-reply"
+ # --print-reply return not before graphlcd ist done with disconn
+ /usr/bin/dbus-send --system --type=method_call --print-reply --dest=de.tvdr.vdr /Plugins/graphlcd de.tvdr.vdr.plugin.SVDRPCommand string:"disconn" string:"${DISPLAY}" > /dev/null
+ # switch display off
+ [ -n "${SWITCH_OFF_CMD}" ] && ${SWITCH_OFF_CMD}
+ fi
+}
+
+
+
+case "${1}" in
+ startup)
+ true
+ ;;
+ started)
+ [ "${2}" = "true" ] && switch_lcd on
+ ;;
+ shutdown)
+ switch_lcd off
+ ;;
+ running)
+ if [ "${2}" = "true" ]; then
+ switch_lcd on
+ else
+ switch_lcd off
+ fi
+ ;;
+esac
+
+exit 0
diff --git a/script/uactivity/activity/-20-switch_tv b/script/uactivity/activity/-20-switch_tv
index 7059e1f..c9bbf57 100644
--- a/script/uactivity/activity/-20-switch_tv
+++ b/script/uactivity/activity/-20-switch_tv
@@ -1,11 +1,21 @@
#!/bin/sh
switch_tv(){
- [ "${1}" = "on" ] && irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE on
- [ "${1}" = "off" ] && irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE off
+ if [ "${1}" = "on" ]; then
+ # yaUSBir sometimes ignore the first command, send an existing dummy ir code
+ irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_DUMMY dummy
+ sleep 0.5
+ irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE on
+ else
+ # yaUSBir sometimes ignore the first command, send an existing dummy ir code
+ irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_DUMMY dummy
+ sleep 0.5
+ irsend -d /var/run/lirc/ya_usbir SEND_ONCE TV_REMOTE off
+ fi
}
+
case "${1}" in
startup)
true
@@ -17,7 +27,11 @@ case "${1}" in
switch_tv off
;;
running)
- [ "${2}" = "true" ] && switch_tv on || switch_tv off
+ if [ "${2}" = "true" ]; then
+ switch_tv on
+ else
+ switch_tv off
+ fi
;;
esac
diff --git a/script/uactivity/key/-10-syslog_demo b/script/uactivity/key/-10-syslog_demo
index 337838d..ee794a7 100644
--- a/script/uactivity/key/-10-syslog_demo
+++ b/script/uactivity/key/-10-syslog_demo
@@ -7,6 +7,12 @@ case "${1}" in
logger -t "uactivity [key/$(basename ${0})]" "CacheDirectory: ${4}"
logger -t "uactivity [key/$(basename ${0})]" "ResourceDirectory: ${5}"
;;
+ started)
+ logger -t "uactivity [key/$(basename ${0})]" "key started"
+ logger -t "uactivity [key/$(basename ${0})]" "ConfigDirectory: ${3}"
+ logger -t "uactivity [key/$(basename ${0})]" "CacheDirectory: ${4}"
+ logger -t "uactivity [key/$(basename ${0})]" "ResourceDirectory: ${5}"
+ ;;
shutdown)
logger -t "uactivity [key/$(basename ${0})]" "key shutting down"
logger -t "uactivity [key/$(basename ${0})]" "ConfigDirectory: ${3}"
diff --git a/script/uactivity/watchdog/-10-syslog_demo b/script/uactivity/watchdog/-10-syslog_demo
index af7249d..8ff6ca3 100644
--- a/script/uactivity/watchdog/-10-syslog_demo
+++ b/script/uactivity/watchdog/-10-syslog_demo
@@ -10,6 +10,15 @@ case "${1}" in
logger -t "uactivity [watchdog/$(basename ${0})]" "CacheDirectory: ${4}"
logger -t "uactivity [watchdog/$(basename ${0})]" "ResourceDirectory: ${5}"
;;
+ started)
+ logger -t "uactivity [watchdog/$(basename ${0})]" "watchdog started"
+ [ "${2}" = "true" ] \
+ && logger -t "uactivity [watchdog/$(basename ${0})]" "status \"user active\"" \
+ || logger -t "uactivity [watchdog/$(basename ${0})]" "status \"user inactive\""
+ logger -t "uactivity [watchdog/$(basename ${0})]" "ConfigDirectory: ${3}"
+ logger -t "uactivity [watchdog/$(basename ${0})]" "CacheDirectory: ${4}"
+ logger -t "uactivity [watchdog/$(basename ${0})]" "ResourceDirectory: ${5}"
+ ;;
shutdown)
logger -t "uactivity [watchdog/$(basename ${0})]" "watchdog shutting down"
[ "${2}" = "true" ] \
diff --git a/uactivity.c b/uactivity.c
index d1481b8..f5f5cf9 100644
--- a/uactivity.c
+++ b/uactivity.c
@@ -27,6 +27,8 @@ private:
bool LastActivity;
int WatchdogTimer;
time_t LastTime;
+ cMutex AliveMutex;
+ time_t Alive;
public:
cPluginUactivity(void);
virtual ~cPluginUactivity() { };
@@ -46,8 +48,8 @@ public:
virtual cMenuSetupPage *SetupMenu(void) { return NULL; };
virtual bool SetupParse(const char *Name, const char *Value) { return false; };
virtual bool Service(const char *Id, void *Data = NULL) { return false; };
- virtual const char **SVDRPHelpPages(void) { return NULL; };
- virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) { return NULL; };
+ virtual const char **SVDRPHelpPages(void);
+ virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
};
class cPluginUactivityMenu : public cOsdMenu {
@@ -118,6 +120,8 @@ bool cPluginUactivity::Start(void)
Run.SetResourceDirectory(ConfigDirectory(PLUGIN_NAME_I18N));
#endif
+ time(&Alive);
+
Run.CallKey(oStartUp, k_Setup);
bool ActivityStatus = !ShutdownHandler.IsUserInactive();
@@ -143,6 +147,10 @@ void cPluginUactivity::MainThreadHook(void)
{
// Perform actions in the context of the main program thread.
// WARNING: Use with great care - see PLUGINS.html!
+ AliveMutex.Lock();
+ time(&Alive);
+ AliveMutex.Unlock();
+
bool ActivityStatus = !ShutdownHandler.IsUserInactive();
if (FirstMainThreadHook) {
@@ -173,4 +181,40 @@ cOsdObject *cPluginUactivity::MainMenuAction(void)
return new cPluginUactivityMenu();
}
+const char **cPluginUactivity::SVDRPHelpPages(void)
+{
+ static const char *HelpPages[] = {
+ "ACTIVE\n"
+ " 'ACTIVE' Return the user activity status",
+ "ALIVE\n"
+ " 'ALIVE' Last time where the VDR was seen alive",
+ NULL
+ };
+ return HelpPages;
+}
+
+cString cPluginUactivity::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
+{
+ if(!strcasecmp(Command, "ACTIVE")) {
+ if(!ShutdownHandler.IsUserInactive()) {
+ ReplyCode = 900;
+ return "User aktive";
+ } else {
+ ReplyCode = 901;
+ return "User inactive";
+ }
+ }
+ else if(!strcasecmp(Command, "ALIVE")) {
+ ReplyCode = 902;
+ AliveMutex.Lock();
+ const time_t tAlive = Alive;
+ AliveMutex.Unlock();
+ return cString::sprintf("%ld", tAlive);
+ }
+ else {
+ ReplyCode = 502; return "Command not implemented";
+ }
+ return NULL;
+}
+
VDRPLUGINCREATOR(cPluginUactivity); // Don't touch this!