It is currently November 15th, 2019, 3:43 am

displaying command line output

Tips and Tricks from the Rainmeter Community
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

displaying command line output

moshi » October 10th, 2013, 10:07 am

sometimes Rainmeter lacks a measure or a plugin, but you know a command line application that shows the information you want to display.
in this example we use a Windows port of the UNIX cal command. it displays a calendar. it is available here: http://home.comcast.net/~mjvincent/
Untitled-1.jpg
now, that could be quite useful if you want to display a calendar, but hate the math that would be required to do that in Rainmeter.

first of all, we need to create a text file that Rainmeter can read. we use > as redirection option to write the command line output to a text file. http://technet.microsoft.com/en-us/library/bb490982.aspx

so, let's create a batchfile called cal.bat in the same folder where cal.exe is:

Code: Select all

cal.exe > cal.txt
when you run this batchfile, it will create a text file called cal.txt.
of course you can also add command line option as in this example to create a calendar for the whole year:

Code: Select all

cal.exe -y > cal.txt
you can now already use the WebParser or Quote plugin to display the content of this text file with Rainmeter.

the bad part is that every time you run this batchfile a console window will pop up. this can be solved by creating a Visual Basic Script called cal.vbs in the same folder:

Code: Select all

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run "cal.bat", 0
Set WshShell = Nothing
now you just have to run the script everytime you need the output to be updated and you will be fine.
Untitled-2.jpg
example skin attached.
You do not have the required permissions to view the files attached to this post.
User avatar
thatsIch
Posts: 464
Joined: August 7th, 2012, 9:18 pm

Re: displaying command line output

thatsIch » October 10th, 2013, 8:34 pm

as always: a pretty nice solution :)
User avatar
Mordasius
Posts: 1063
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: displaying command line output

Mordasius » October 11th, 2013, 6:24 pm

Nice one moshi :)

I'm forever clicking on the taskbar calendar to look at days and dates and this makes it so much easier to show the entire year with a single click.

Is there any particular reason why we need UpdateDivider=600 in the [Launch] Calc? The whole thing seems to work just fine with UpdateDivider=-1 in [Launch] and FinishAction=[!UpdateMeter *][!Redraw] in [Calendar]
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: displaying command line output

moshi » October 11th, 2013, 9:24 pm

i don't think there is a FinishAction for the Quote plugin.
but yes, for a yearly calendar it probably updates too often, it's a leftover from the monthly calendar i tested first.

for your usage scenario, i would suggest to set Update=-1.
launch the skin from an other skin, shortcut, whatever.
but use a script, that first executes the batch file to write the text file, then maybe waits for 100 ms or so (as rendering the skin is probably faster than writing the text file) and last activates the skin.


edit: or just use the task scheduler to run the batch file on Januray 1st ;)
User avatar
jsmorley
Developer
Posts: 19710
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: displaying command line output

jsmorley » October 11th, 2013, 9:31 pm

moshi wrote:i don't think there is a FinishAction for the Quote plugin.
There is not. Never really been any call for one, as the FinishAction concept is intended to deal with plugins that are "threaded" and may not finish whatever activity they are designed for before the next "update" of the skin. It is meant to have a way to have a skin react to the completion of the work the plugin is doing, a way to make what is in effect a "parallel" process behave as if it were "serial".

Quote plugin is not threaded in that way (at least I don't think it is, someone can just slap me in the head if I am wrong) and so FinishAction would not be really any different than OnChangeAction or OnUpdateAction if you see what I mean.
User avatar
moshi
Posts: 1851
Joined: November 13th, 2012, 9:53 pm

Re: displaying command line output

moshi » October 12th, 2013, 12:31 pm

this tip became obsolete pretty fast. check out:
http://rainmeter.net/forum/viewtopic.php?f=18&t=16715