Sign up here and you can log into the forum!

Plugin: DoSomething - run command line from OSD

The WDTVExt plugin depot. Plugins/libraries/code only

Plugin: DoSomething - run command line from OSD   

Postby sailort » Fri Aug 27, 2010 3:14 pm

Hi all,

here is WDTVExt plugin which enables you to create "snippets" of command line commands and run them from OSD.
Functional snippets for reboot, pinging localhost (yes, localhost :-)) and pinging unavailable host are included for
educational purposes. Stoping/starting rtorrent is of course possible, just to make a "snippet" for it :-)

INSTALL:
- as usual and all other wdtvext plugins, unpack it into .wdtvext-plugins folder, reboot

HOW IT WORKS:
- should be understandable from PING.snippet
- reload snippet will reload all (max 9 currently) snippets in plugin directory
- each line starts with description what it means

[SNIPPETNAME|name of snippet to display in menu]

[NAME|Snippet action name to display]

[ICON|path to not focused image]

[ICONSELECTED|path to focused image]

[NAME|Action name]
- Action name can use variables referenced

[VAR|is editable|type|variable name|variable display name|value/command to evaluate]
- is editable accepted values [N - not editable, E - editable via webend, A - askable via osd]
- type [TEXT, NUMBER, EVALUATE - value of variable is evaluated in runtime, LIST - shows predefined list via osd, LISTEVALUATE - shows list populated using command]
- variablename - reference name to other variables/commands/regexps
- variabledisplayname - variable label to be displayed
- value/command to evaluate - if type is one of evaluated, value is interpreted as shell command an result become value, can use other variables referenced...

[VAROPTION|label|value]
- adds list item to variable

[COMMAND|command in/out display|command to execute, can use variables defined in VAR section referenced as [$varname$]]

[REGEXP|value to be found|Message to be displayed when found|regular expression, can use variables referenced...]

- basically, every COMMAND is executed with [$varname$] replaced with actual value of VAR, then every line of command output is checked against all REGEXP
and when successfull, displaying message defined with that regexp. Message could also contain [$varname$] which will be replaced with acttual values.

v100802: http://www.megaupload.com/?d=X8H4MAST
- first release
- check PING.snippet

v100829: http://www.megaupload.com/?d=5CHNSK4A
- now there are 4 lines of messages which scrolls as new messages are outed
- now variables can be used in regexp also
- added MOUNTSHARES snippet to see how can it work

v100829_2 http://www.megaupload.com/?d=MYS4YHM2
- resolved osd freezing (and reboot required afterwards)
- extended out lines to 7, now it looks like "do you remember iddqd"? you have to see it on ping :-)
- now you can output to "console" also command to be executed and command results
- see attached PING, MOUNTSHARES snippets
- now command has new attribute, which
1: output command
2: output result
3: output both

v100829_3: http://www.megaupload.com/?d=QSQ4X9ZR
- VAR/COMMAND/NAME now accepts pipe "|" characters - see PIPETEST.snippet
- max snippet count raised to 20
- code polishing, less debugg info (depdends on log level)
- small osd changes

v100830: http://www.megaupload.com/?d=34VZVVUI
- added Enable/Disable, Delete snippets (what will guess what could be next action? :D )
- don't mind osd acting under List control... this isn't bug, so please don't post it. If you don't like it, use previous version. Anyway this shouldn't have any negative side effect
- seems stable to me, hasn't freezed the box for a while (for anyone interested, it's not good idea to remove displayed menu items from menu :D )

v100831: http://www.megaupload.com/?d=AIUDV74O
- added Download snippets from SVN (though no snippets in SVN yet)
- reorganized menu, now it has only Execute/Manage on second level
- few bugs removed
- processing of REGEXP changed, now only REGEXP following COMMAND are processed, so every command can have its regexp to evaluate -> easier snippet code
- added snippets for rTorrent start/stop/status

v100903: http://www.megaupload.com/?d=0KGCXW6X
- webend - basic snippet variable configuration (need two reboots to work as it is adding itself to config)
- multi action snippets - now snippets can contain multiple actions selectable on execute via List.
- new SNIPPETNAME entry added - this is displayed on menu entry
- NAME used as action name in List
- every action can have it's own VAR|COMMAND|REGEXP
- a lot of effort into code stability -> now List survives even screensaver display
- no snippets added in this release -> Download them from SVN (Manage/Download snippets)
- rTorrent snippet now contains previous single snippets for START/STOP/STATUS and Move completed

v100905_2 http://www.megaupload.com/?d=DNOLYYEK
- now LIST variable could be "ASKABLE" via osd (ENTER shows next variable if exist, RETURN returns to previous variable)
- new VAR types - EVALUATE/LISTEVALUATE - those values/list items are populated runtime when displaying, even these commands could be dependent on other variables values
- check TESTVAR snippet
- added construct for S00options with some variables

v100907: [version in SVN]
- added multiline commands

v101017:
- variable evaluation optimised
- update via Reloader
- changed snippet SVN repository to separate plugin from snippets
- added MediaNavigation 2.5 configration snippet

TODO:
- webend configuration of snippet variables
(is anyone willing to do it for us? please, you just have to load text file and enable to edit VAR entries in webend, then save file back)
- OSD configuration of snippet variables

...post your snippets here :-)

Enjoy...
...and post comments.

T.
Last edited by sailort on Sun Oct 17, 2010 1:34 pm, edited 11 times in total.
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby migube » Fri Aug 27, 2010 9:44 pm

That sounds like a nice way to send some home automation commands, like wget commands to X10 items :)

tx
-----
WdTvLive - LG BD390 - Philips 47PFL8404h - Yamaha RXV-667 - DM7000 - Synology 107+ - HP Touchpad (Webos)
migube
Global Moderator
 
Posts: 162
Joined: Thu Apr 08, 2010 7:23 am

Re: Plugin: DoSomething - run command line from OSD   

Postby sailort » Sat Aug 28, 2010 1:23 am

v100829: http://www.megaupload.com/?d=5CHNSK4A
- now there are 4 lines of messages which scrolls as new messages are outed
- now variables can be used in regexp also
- added MOUNTSHARES snippet to see how can it work

Code: Select all
NAME|Mount shares
ICON|/osd/image/villa/home_music_album_sub_icon_n.png
ICONSELECTED|/osd/image/villa/home_music_album_sub_icon_f.png
VAR|user|E|wdtvl
VAR|pass|E|a
VAR|Share1Name|E|//192.168.1.30/TORR
VAR|Share1Folder|E|TORR
VAR|Share2Name|E|//192.168.1.30/BIG
VAR|Share2Folder|E|MOVIES
COMMAND|xmount [$Share1Name$] [$Share1Folder$] cifs user=[$user$],pass=[$pass$] 2>&1
COMMAND|xmount [$Share2Name$] [$Share2Folder$] cifs user=[$user$],pass=[$pass$] 2>&1
REGEXP|failed|Can't mount [$Share1Folder$]. Share unavailable?|(?:/usb/[$Share1Folder$] )(.*?)(?=: No route)
REGEXP|failed|Can't mount [$Share2Folder$]. Share unavailable?|(?:/usb/[$Share2Folder$] )(.*?)(?=: No route)
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby sailort » Sat Aug 28, 2010 3:03 pm

v100829_2 http://www.megaupload.com/?d=MYS4YHM2
- resolved osd freezing (and reboot required afterwards)
- extended out lines to 7, now it looks like "do you remember iddqd"? you have to see it on ping :-)
- now you can output to "console" also command to be executed and command results
- see attached PING, MOUNTSHARES snippets
- now command has new attribute, which
1: output command
2: output result
3: output both
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby recliq » Sun Aug 29, 2010 12:22 am

looks nice, will play around with it this evening when i'm back home... ;)
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5024
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: Plugin: DoSomething - run command line from OSD   

Postby sailort » Sun Aug 29, 2010 2:28 am

v100829_3: http://www.megaupload.com/?d=QSQ4X9ZR
- VAR/COMMAND/NAME now accepts pipe "|" characters - see PIPETEST.snippet
- max snippet count raised to 20
- code polishing, less debugg info (depdends on log level)
- small osd changes
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby RMerlin » Sun Aug 29, 2010 7:56 pm

I've been wanting for a while to request a simple plugin that would send a WOL signal to a pre-determined MAC address (i.e. would let you wake up your PC from the UI - doing it automatically through S00-Customs isn't ideal as I don't always want my file server to wake up as I start the WDTV). I guess that should be fairly easy to do using this new extension. Thanks!

EDIT: looks like there's even already an existing snippet for WOL :)
WDLXTV Webend maintainer. Visit http://www.lostrealm.ca/wdlxtv to see my other WDLXTV projects.
If you like my work, please consider donating.
User avatar
RMerlin
WDLXTV Team
 
Posts: 3236
Joined: Sat Jun 26, 2010 9:25 am
Location: Montreal, Canada

Re: Plugin: DoSomething - run command line from OSD   

Postby sailort » Mon Aug 30, 2010 2:03 am

v100830: http://www.megaupload.com/?d=34VZVVUI
- added Enable/Disable, Delete snippets (what will guess what could be next action? :D )
- don't mind osd acting under List control... this isn't bug, so please don't post it. If you don't like it, use previous version. Anyway this shouldn't have any negative side effect
- seems stable to me, hasn't freezed the box for a while (for anyone interested, it's not good idea to remove displayed menu items from menu :D )
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby sailort » Tue Aug 31, 2010 1:18 pm

v100831: http://www.megaupload.com/?d=AIUDV74O
- added Download snippets from SVN (though no snippets in SVN yet)
- reorganized menu, now it has only Execute/Manage on second level
- few bugs removed
- processing of REGEXP changed, now only REGEXP following COMMAND are processed, so every command can have its regexp to evaluate -> easier snippet code
- added snippets for rTorrent start/stop/status

Enjoy and post opinions, ideas....
If you like my work and want to buy me a bottle of wine, you can do it this way. Thanks for your support.
sailort
Developer
 
Posts: 363
Joined: Sat Apr 24, 2010 6:42 am

Re: Plugin: DoSomething - run command line from OSD   

Postby hemantp » Wed Sep 01, 2010 7:06 am

I guess I can have rtorrent download status as I had mentioned in http://forum.wdlxtv.com/viewtopic.php?f=38&t=1361#p10707 by just adding "cat /tmp/rtlog" as a snippet?

I won't need my script (RtorrentStatus.plugin.js) then as this is quite generic!

Btw, the file 100831 is "Temporary unavailable" on Megaupload :(

-
Hemant

EDIT: Got it.. just after I posted this!
hemantp
n00b
 
Posts: 5
Joined: Sun Jun 13, 2010 11:25 pm

Next

Return to WDTVExt plugins

Who is online

Users browsing this forum: No registered users and 1 guest