This skin is another showcase for the new Lua capabilities in Rainmeter 1.4. It will allow you to read any text file (I see it being useful for logs, notes, todo lists, etc) and display any number of lines from the file in reverse order from the bottom (like the unix "tail" function)
You must install the latest Rainmeter 1.4 beta (at least r676) from http://Rainmeter.net.
Then just install this skin:
Open the skin .ini and the .lua file included to see how to use this, and for some general tips on using Lua in Rainmeter skins.
This could easily be extended, using for instance the built-in Regular Expression support in Lua to have it only display lines with a certain pattern like "error" or something. There is a very good site for learning Lua here: http://lua-users.org/wiki/LuaTutorial
It is currently September 15th, 2024, 8:13 am
LuaTailFile - A skin to read logs, todo lists, etc.
-
- Developer
- Posts: 22743
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
LuaTailFile - A skin to read logs, todo lists, etc.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 1
- Joined: February 9th, 2011, 2:35 pm
Re: LuaTailFile - A skin to read logs, todo lists, etc.
I can see this coming in really handy for parsing an XML file or something of that nature. Once i get some time i'll get on that.
-
- Posts: 1
- Joined: February 28th, 2011, 10:54 am
Re: LuaTailFile - A skin to read logs, todo lists, etc.
jsmorley wrote:This could easily be extended, using for instance the built-in Regular Expression support in Lua to have it only display lines with a certain pattern like "error" or something. There is a very good site for learning Lua here: http://lua-users.org/wiki/LuaTutorial
How would I go about doing this? I have an application that outputs the status of Services on a PC to a text file, I'd like to read the textfile using this skin. How would I go about only outputting certain lines from my log file? I LUA knowledge is shocking and I am not a coder by nature
Appreciate the help
-
- Developer
- Posts: 22743
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: LuaTailFile - A skin to read logs, todo lists, etc.
You will really need to use that Lua tutorial site and learn a bit about Lua to edit that part of the skin.
However, changing the loop that is in the .lua file now with
Replacing "error" with whatever pattern you are looking for in the lines, should be a good start.
However, changing the loop that is in the .lua file now with
Code: Select all
while true do
local sLine = io.read()
if sLine == nil then break end
if string.find(sLine, "error") ~= nil then
tAllLines[iCount] = sLine
iCount = iCount + 1
end
end
-
- Posts: 2
- Joined: March 15th, 2011, 3:08 pm
Re: LuaTailFile - A skin to read logs, todo lists, etc.
I'm fiddling about with a variant of this skin and script - putting IRC channel logs on the desktop.
Right now, my trouble is that the resulting text is not UTF-8 - it looks like an ANSI-interpretation of a UTF-8 encoded file.
Danish chars æøå ÆØÅ look like æøå ÆØÅ
Since it's really only 6 different chars that bug me, I've set out to simply do substitution. In the rainmeter manual, it says that all measures can have substitution.
However, it doesn't seem to work at all, when I put
Did anyone else overcome trouble like this? I'd be happy to hear about it
Right now, my trouble is that the resulting text is not UTF-8 - it looks like an ANSI-interpretation of a UTF-8 encoded file.
Danish chars æøå ÆØÅ look like æøå ÆØÅ
Since it's really only 6 different chars that bug me, I've set out to simply do substitution. In the rainmeter manual, it says that all measures can have substitution.
However, it doesn't seem to work at all, when I put
in the [Measure] paragraphSubstitute="æ":"æ", "ø":"ø", "Ã¥":"å", "Æ":"Æ", "Ø":"Ø", "Ã…":"Å"
Did anyone else overcome trouble like this? I'd be happy to hear about it
-
- Moderator
- Posts: 995
- Joined: June 10th, 2009, 12:44 pm
- Location: Sweden
Re: LuaTailFile - A skin to read logs, todo lists, etc.
First of: Have you made sure that the logs you are reading are in UTF-8?
If saved as UTF-8, rainmeter will get the correct characters.
Second: Have you tried using CodePage=Number ?
http://rainmeter.net/cms/Plugins-WebParser
Third: You could check and see if Lua fixes it for you.
Use string.gsub(something, something, something)
http://lua-users.org/wiki/StringLibraryTutorial
If saved as UTF-8, rainmeter will get the correct characters.
Second: Have you tried using CodePage=Number ?
http://rainmeter.net/cms/Plugins-WebParser
Third: You could check and see if Lua fixes it for you.
Use string.gsub(something, something, something)
http://lua-users.org/wiki/StringLibraryTutorial
I don't think, therefore I'm not.
-
- Posts: 2
- Joined: March 15th, 2011, 3:08 pm
Re: LuaTailFile - A skin to read logs, todo lists, etc.
Yes, I'm sure that the files are saved as UTF-8 - It's Mirc log files; they display flawless with Notepad, but flawed with Wordpad.
Second: I'm not using the webparser plugin - actually I've tried, but it needs exclusive rights when opening the file, and Mirc seems to keep the file open - so no go
Third: Thanks for the suggestion, I'll look into it.
First of all, I'm going to try and use this skin as-is, since (like I told ealier) I'm using a variant of it. Then we could definitely be on the same page, when talking about it
[EDIT]: I've just tried and used this skin as-is. Just like my own fiddlings, it displays the chars wrongly. I've verified (using firefox), that the encoding of the file is indeed UTF-8.
[Second EDIT]: Your suggestion around gsub() seems to work.
I've added some lines in the second loop in the update function:
Now, Rainmeter displays IRC channels correctly on my monitor
I'm not a coder, so if anyone can find a more effective solution, it would be highly appreciated
Again, thanks a bunch - also for the speedy reply
Second: I'm not using the webparser plugin - actually I've tried, but it needs exclusive rights when opening the file, and Mirc seems to keep the file open - so no go
Third: Thanks for the suggestion, I'll look into it.
First of all, I'm going to try and use this skin as-is, since (like I told ealier) I'm using a variant of it. Then we could definitely be on the same page, when talking about it
[EDIT]: I've just tried and used this skin as-is. Just like my own fiddlings, it displays the chars wrongly. I've verified (using firefox), that the encoding of the file is indeed UTF-8.
[Second EDIT]: Your suggestion around gsub() seems to work.
I've added some lines in the second loop in the update function:
Code: Select all
function Update()
hReadingFile = io.input(sFileToRead)
tAllLines = {}
iCount = 1
while true do
local sLine = io.read()
if sLine == nil then break end
tAllLines[iCount] = sLine
iCount = iCount + 1
end
for i = 1, iLinesToRead do
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("æ","æ")
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("ø","ø")
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("Ã¥","å")
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("Æ","Æ")
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("Ø","Ø")
tAllLines[iCount-i]=tAllLines[iCount-i]:gsub("Ã…","Å")
tMeters[i]:SetText(tAllLines[iCount-i])
end
io.flush(hReadingFile)
end -- function Update
I'm not a coder, so if anyone can find a more effective solution, it would be highly appreciated
Again, thanks a bunch - also for the speedy reply
-
- Posts: 24
- Joined: June 25th, 2011, 5:09 pm
Re: LuaTailFile - A skin to read logs, todo lists, etc.
Hello all!
I am a Lua scripter, and I am really happy that you've added Lua support - it makes my life easier Just some note about the codes above:
Why don't you use this instead?
About gsub'ing the strange characters: an easier way to use os.setlocale("Hungarian_Hungary.1252") (in my case, change it to yours, or use os.setlocale("") ), or open the file in binary mode (local hReadingFile = io.open(sFileToRead,"rb") ).
Great work, developers
By the way, what about LuaJIT?
I am a Lua scripter, and I am really happy that you've added Lua support - it makes my life easier Just some note about the codes above:
Code: Select all
function Update()
hReadingFile = io.input(sFileToRead)
tAllLines = {}
iCount = 1
while true do
local sLine = io.read()
if sLine == nil then break end
tAllLines[iCount] = sLine
iCount = iCount + 1
end
for i = 1, iLinesToRead do
tMeters[i]:SetText(tAllLines[iCount-i])
end
io.flush(hReadingFile)
end -- function Update
Code: Select all
function Update()
local hReadingFile = io.open(sFileToRead)
tAllLines = {}
for sLine in hReadingFile:lines() do
table.insert(tAllLines,sLine)
end
local iCount = #tAllLines
for i = 1, iLinesToRead do
tMeters[i]:SetText(tAllLines[iCount-i])
end
hReadingFile:close() -- Don't forget to close it,
end -- function Update
Great work, developers
By the way, what about LuaJIT?
-
- Developer
- Posts: 22743
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: LuaTailFile - A skin to read logs, todo lists, etc.
Glad to have someone who is actually using Lua outside of Rainmeter around. Someone with some expertise in Lua, to maybe answer the occasional question about it on these forums, would be welcome indeed. The answer to your question is that I first laid eyes on Lua when our developer MattKing first started trying to hook it up with Rainmeter not long ago, and that code above was probably the second or third snippet of Lua code I ever wrote. That it worked at all made me happy!Yggdrasil wrote:Hello all!
I am a Lua scripter, and I am really happy that you've added Lua support - it makes my life easier Just some note about the codes above:
Why don't you use this instead?
Welcome aboard!
-
- Posts: 24
- Joined: June 25th, 2011, 5:09 pm
Re: LuaTailFile - A skin to read logs, todo lists, etc.
It's my pleasure if I can help you to make RainMeter better
If you (or somebody else) have a question, please don't hesitate to contact me, I work with Lua since 2004, so I can say I'm experienced Lua is an easy-to-learn language, and that's what make it the best (imho). So, if you open a topic for Lua, I help everybody with pleasure.
Regards
If you (or somebody else) have a question, please don't hesitate to contact me, I work with Lua since 2004, so I can say I'm experienced Lua is an easy-to-learn language, and that's what make it the best (imho). So, if you open a topic for Lua, I help everybody with pleasure.
Regards