diff options
author | louis <louis.braun@gmx.de> | 2015-05-14 16:55:56 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-05-14 16:55:56 +0200 |
commit | 5a0155d1e924601c7fa686001af19928887f83f7 (patch) | |
tree | e0534ba0ce29994db85c186bdf25f66f8c704e93 | |
parent | af59c465aa869ecf23084738022e2f09711ff396 (diff) | |
download | vdr-plugin-skindesigner-5a0155d1e924601c7fa686001af19928887f83f7.tar.gz vdr-plugin-skindesigner-5a0155d1e924601c7fa686001af19928887f83f7.tar.bz2 |
added viewelement <vdrstatistics> in main menu
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | dtd/displaymenu.dtd | 16 | ||||
-rw-r--r-- | libtemplate/templateview.c | 6 | ||||
-rw-r--r-- | libtemplate/templateviewelement.h | 1 | ||||
-rw-r--r-- | scripts/README | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/temperatures.g2v | 0 | ||||
-rw-r--r-- | scripts/vdrstats.default | 17 | ||||
-rw-r--r-- | skinskeleton/xmlfiles/displaymenumain.xml | 30 | ||||
-rw-r--r-- | views/displaymenuview.c | 32 | ||||
-rw-r--r-- | views/displaymenuview.h | 1 | ||||
-rw-r--r-- | views/viewhelpers.c | 38 | ||||
-rw-r--r-- | views/viewhelpers.h | 3 |
12 files changed, 140 insertions, 18 deletions
@@ -329,5 +329,6 @@ Version 0.4.5 Version 0.4.6 - added token {startsin} in displaymenuschedules +- added viewelement <vdrstatistics> in main menu diff --git a/dtd/displaymenu.dtd b/dtd/displaymenu.dtd index 30b34da..670ef67 100644 --- a/dtd/displaymenu.dtd +++ b/dtd/displaymenu.dtd @@ -175,6 +175,20 @@ condition CDATA #IMPLIED
>
+<!ELEMENT vdrstatistics (area|areascroll)*>
+<!ATTLIST vdrstatistics
+ detached CDATA #IMPLIED
+ delay CDATA #IMPLIED
+ fadetime CDATA #IMPLIED
+ shifttime CDATA #IMPLIED
+ shifttype CDATA #IMPLIED
+ shiftmode CDATA #IMPLIED
+ startx CDATA #IMPLIED
+ starty CDATA #IMPLIED
+ debug CDATA #IMPLIED
+ condition CDATA #IMPLIED
+>
+
<!ELEMENT currentschedule (area|areascroll)*>
<!ATTLIST currentschedule
detached CDATA #IMPLIED
@@ -264,7 +278,7 @@ >
<!ELEMENT menumain (background | header | datetime | time | colorbuttons | scrollbar | sortmode | timers |
- discusage | devices | systemload | systemmemory | temperatures | currentschedule |
+ discusage | devices | systemload | systemmemory | vdrstatistics | temperatures | currentschedule |
currentweather | lastrecordings | customtokens | menuitems)*>
<!ATTLIST menumain
x CDATA #REQUIRED
diff --git a/libtemplate/templateview.c b/libtemplate/templateview.c index 3fcdd86..869daf6 100644 --- a/libtemplate/templateview.c +++ b/libtemplate/templateview.c @@ -1293,6 +1293,7 @@ void cTemplateViewMenu::SetViewElements(void) { viewElementsAllowed.insert("discusage"); viewElementsAllowed.insert("systemload"); viewElementsAllowed.insert("systemmemory"); + viewElementsAllowed.insert("vdrstatistics"); viewElementsAllowed.insert("temperatures"); viewElementsAllowed.insert("timers"); viewElementsAllowed.insert("lastrecordings"); @@ -1383,6 +1384,9 @@ string cTemplateViewMenu::GetViewElementName(eViewElement ve) { case veSystemMemory: name = "System Memory"; break; + case veVDRStats: + name = "VDR Statistics"; + break; case veTemperatures: name = "Temperatures"; break; @@ -1511,6 +1515,8 @@ void cTemplateViewMenu::AddPixmap(string sViewElement, cTemplatePixmap *pix, vec ve = veSystemLoad; } else if (!sViewElement.compare("systemmemory")) { ve = veSystemMemory; + } else if (!sViewElement.compare("vdrstatistics")) { + ve = veVDRStats; } else if (!sViewElement.compare("temperatures")) { ve = veTemperatures; } else if (!sViewElement.compare("timers")) { diff --git a/libtemplate/templateviewelement.h b/libtemplate/templateviewelement.h index a291c7c..20c0906 100644 --- a/libtemplate/templateviewelement.h +++ b/libtemplate/templateviewelement.h @@ -48,6 +48,7 @@ enum eViewElement { veDiscUsage,
veSystemLoad,
veSystemMemory,
+ veVDRStats,
veTemperatures,
veTimers,
veLastRecordings,
diff --git a/scripts/README b/scripts/README index 5f22c35..a107b5c 100644 --- a/scripts/README +++ b/scripts/README @@ -1,10 +1,11 @@ -This Widget provide information about the system temperatures. +Scripts for: +- system temperatures - "temperatures" is called +- vdr statistics (vdr cpu load and memory usage) "vdrstats" is called -You must manually create a link to the corresponding script, for example: +You must manually create a link for each script to the script you want to use, for example: ln -s temperatures.default temperatures +ln -s vdrstats.default vdrstats -The command "temperatures" will be executed every time the widget is drawn, so please keep it short and fast. -The command can provide three temperatures: cpu, pc case and gpu temperature -The command can also be called from system information widget. So the output files must also begin with 01_ - 99_ for sort/position. +The scripts will be executed every time the according viewelement is displayed, so please keep it short and fast. -Please install lm-sensors and configure it for your system. See the default script for an example. +Please install lm-sensors and configure it for your system. diff --git a/scripts/temperatures.g2v b/scripts/temperatures.g2v index 79d0774..79d0774 100644..100755 --- a/scripts/temperatures.g2v +++ b/scripts/temperatures.g2v diff --git a/scripts/vdrstats.default b/scripts/vdrstats.default new file mode 100644 index 0000000..2d67ee0 --- /dev/null +++ b/scripts/vdrstats.default @@ -0,0 +1,17 @@ +#!/bin/bash + +# please update this script to fit your needs +# this script is call every time the according viewelement will be drawn, so keep it short and fast ;) + +OUTPUTFLDR="/tmp/skindesigner/" +mkdir -p ${OUTPUTFLDR} + +# there can be 2 files, vdrcpu and vdrmem + +rm -f ${OUTPUTFLDR}/vdrcpu ${OUTPUTFLDR}/vdrmem + +# vdr cpu usage, is 10th element in "top" list +top -n 1 | grep " vdr " | awk -F " " '{ print $10;}' > ${OUTPUTFLDR}/vdrcpu + +# vdr memory usage, is 11th element in "top" list +top -n 1 | grep " vdr " | awk -F " " '{ print $11;}' > ${OUTPUTFLDR}/vdrmem diff --git a/skinskeleton/xmlfiles/displaymenumain.xml b/skinskeleton/xmlfiles/displaymenumain.xml index ee5373f..0eeb538 100644 --- a/skinskeleton/xmlfiles/displaymenumain.xml +++ b/skinskeleton/xmlfiles/displaymenumain.xml @@ -17,7 +17,7 @@ {timers[channellogoexists]} true if channel logo exists {timers[isremotetimer]} true if timer is a remote timer from remotetimers plugin --> - <timers> + <timers detached="false"> </timers> <!-- Available Variables lastrecordings: 5 newest recordings @@ -33,7 +33,7 @@ {recordings[posterwidth]} width of poster {recordings[posterheight]} height of poster --> - <lastrecordings> + <lastrecordings detached="false"> </lastrecordings> <!-- Available Variables discusage: @@ -44,11 +44,12 @@ {discalert} true if disc usage is > 95% {vdrusagestring} localized VDR internal usage string --> - <discusage> + <discusage detached="false"> </discusage> <!-- Available Variables devices: signalstrength and -quality are only set if not mode="light" is used in <devices> + execution slow, should be detached {numdevices} number of available devices {devices[]} array with available devices {devices[num]} number of current device @@ -66,13 +67,13 @@ {devices[channelid]} ID of the currently tuned channel {devices[source]} source of the currently tuned channel --> - <devices mode="full|light"> + <devices mode="full|light" detached="false"> </devices> <!-- Available Variables systemload: {load} current system load --> - <systemload> + <systemload detached="false"> </systemload> <!-- Available Variables systemmemory: @@ -80,14 +81,23 @@ {usedmem} currently used system memory in MB {usedmempercent} currently used system memory in Percent --> - <systemmemory> + <systemmemory detached="false"> </systemmemory> + <!-- Available Variables vdrstatistics: + execution slow, should be detached + {vdrcpu} current cpu usage of vdr process in percent + {vdrmem} current mem usage of vdr process in percent + --> + <vdrstatistics detached="false"> + </vdrstatistics> + <!-- Available Variables tempreatures: + execution slow, should be detached {cputemp} current cpu temperature in °C {gputemp} current gpu temperature in °C --> - <temperatures> + <temperatures detached="false"> </temperatures> <!-- Available Variables currentschedule: @@ -111,7 +121,7 @@ {bannerwidth} width of banner in pixel {bannerheight} height of banner in pixel --> - <currentschedule> + <currentschedule detached="false"> </currentschedule> <!-- Available Variables currentweather: @@ -134,7 +144,7 @@ {pressure} pressure in HPo {ozone} ozone value in DU --> - <currentweather> + <currentweather detached="false"> </currentweather> <!-- Available Variables customtokens: @@ -142,7 +152,7 @@ For instance, use an appropriate script which runs periodically as cronjob and sets these custom tokens with svdrpsend or dbus2vdr --> - <customtokens> + <customtokens detached="false"> </customtokens> <menuitems x="0" y="0" orientation="vertical" width="100%" height="100%" align="center" numlistelements="8"> diff --git a/views/displaymenuview.c b/views/displaymenuview.c index a7e840d..d76095c 100644 --- a/views/displaymenuview.c +++ b/views/displaymenuview.c @@ -299,9 +299,10 @@ void cDisplayMenuMainView::DrawStaticViewElements(void) { bool cDisplayMenuMainView::DrawDynamicViewElements(void) { bool loadChanged = DrawLoad(); bool memChanged = DrawMemory(); + bool vdrChanged = DrawVdrStats(); bool devicesChanged = DrawDevices(); initial = false; - return loadChanged || memChanged || devicesChanged; + return loadChanged || memChanged || vdrChanged || devicesChanged; } @@ -445,6 +446,35 @@ bool cDisplayMenuMainView::DrawMemory(void) { return changed; } +bool cDisplayMenuMainView::DrawVdrStats(void) { + if (!ExecuteViewElement(veVDRStats)) { + return false; + } + bool changed = false; + if (DetachViewElement(veVDRStats)) { + cViewElement *viewElement = GetViewElement(veVDRStats); + if (!viewElement) { + viewElement = new cViewElement(tmplView->GetViewElement(veVDRStats), this); + viewElement->SetCallback(veVDRStats, &cDisplayMenuMainView::SetVDRStats); + AddViewElement(veVDRStats, viewElement); + viewElement->Start(); + changed = true; + } else { + if (!viewElement->Starting()) + changed = viewElement->Render(); + } + } else { + map < string, string > stringTokens; + map < string, int > intTokens; + changed = SetVDRStats(false, stringTokens, intTokens); + if (changed) { + ClearViewElement(veVDRStats); + DrawViewElement(veVDRStats, &stringTokens, &intTokens); + } + } + return changed; +} + void cDisplayMenuMainView::DrawTemperatures(void) { if (!ExecuteViewElement(veTemperatures)) { return; diff --git a/views/displaymenuview.h b/views/displaymenuview.h index acd4512..60a859e 100644 --- a/views/displaymenuview.h +++ b/views/displaymenuview.h @@ -57,6 +57,7 @@ private: void DrawDiscUsage(void); bool DrawLoad(void); bool DrawMemory(void); + bool DrawVdrStats(void); void DrawTemperatures(void); bool DrawDevices(void); void DrawCurrentSchedule(void); diff --git a/views/viewhelpers.c b/views/viewhelpers.c index c43a068..9163282 100644 --- a/views/viewhelpers.c +++ b/views/viewhelpers.c @@ -26,6 +26,8 @@ cViewHelpers::cViewHelpers(void) { lastEcmInfo.caid = -1; lastEcmInfo.pid = -1; lastEcmInfo.prid = -1; + lastVdrCPU = "undefined"; + lastVdrMEM = "undefined"; } cViewHelpers::~cViewHelpers() { @@ -257,6 +259,42 @@ bool cViewHelpers::SetSystemTemperatures(bool forced, stringmap &stringTokens, i return true; } +bool cViewHelpers::SetVDRStats(bool forced, stringmap &stringTokens, intmap &intTokens) { + cString execCommand = cString::sprintf("cd \"%s/\"; \"%s/vdrstats\"", SCRIPTFOLDER, SCRIPTFOLDER); + system(*execCommand); + + string vdrCPU = ""; + string vdrMEM = ""; + + cString itemFilename = cString::sprintf("%s/vdrcpu", SCRIPTOUTPUTPATH ); + ifstream file(*itemFilename, ifstream::in); + if( file.is_open() ) { + std::getline(file, vdrCPU); + file.close(); + } + + itemFilename = cString::sprintf("%s/vdrmem", SCRIPTOUTPUTPATH ); + ifstream file2(*itemFilename, ifstream::in); + if( file2.is_open() ) { + std::getline(file2, vdrMEM); + file2.close(); + } + + if (vdrCPU.size() == 0 || vdrMEM.size() == 0) + return false; + + if (!lastVdrCPU.compare(vdrCPU) && !lastVdrMEM.compare(vdrMEM)) { + return false; + } + lastVdrCPU = vdrCPU; + lastVdrMEM = vdrMEM; + + stringTokens.insert(pair<string,string>("vdrcpu", vdrCPU)); + stringTokens.insert(pair<string,string>("vdrmem", vdrMEM)); + return true; +} + + bool cViewHelpers::SetDummy(bool forced, stringmap &stringTokens, intmap &intTokens) { return true; } diff --git a/views/viewhelpers.h b/views/viewhelpers.h index 2ef4980..9640406 100644 --- a/views/viewhelpers.h +++ b/views/viewhelpers.h @@ -20,6 +20,8 @@ private: int lastMinute; double lastSystemLoad; int lastMemUsage; + string lastVdrCPU; + string lastVdrMEM; sDVBAPIEcmInfo lastEcmInfo; void RecName(string &path, string &name, string &folder); void RecPoster(const cRecording *rec, int &posterWidth, int &posterHeight, string &path, bool &hasPoster); @@ -49,6 +51,7 @@ public: bool SetSystemLoad (bool forced, stringmap &stringTokens, intmap &intTokens); bool SetSystemMemory (bool forced, stringmap &stringTokens, intmap &intTokens); bool SetSystemTemperatures (bool forced, stringmap &stringTokens, intmap &intTokens); + bool SetVDRStats (bool forced, stringmap &stringTokens, intmap &intTokens); bool SetDummy (bool forced, stringmap &stringTokens, intmap &intTokens); }; |