It is currently April 27th, 2024, 9:18 am

Help with Rainmeter Teamspeak Skin

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with Rainmeter Teamspeak Skin

Post by jsmorley »

I think eclectic-tech's solution is fine...
enderep12
Posts: 15
Joined: November 15th, 2018, 2:47 pm

Re: Help with Rainmeter Teamspeak Skin

Post by enderep12 »

Thanks for all the good suggestions, I think I like balala's solution more (at least for my use case) since I'm using a quite large second screen with a lot of free real estate, so I don't necessarily care about showing a maximum number of users. If the list is longer than, say, 10 users, it just can expand further downwards.

However when I switch the measure over to WebParser I get the following problem in my Rainmeter log:

Code: Select all

Fetching: file://C:\Users\enderep\AppData\Roaming\TSViewer\TSViewer.txt (TSViewer\TSViewer.ini - [measureTSViewer])
(Fetch error) The process cannot access the file, because it is currently in use by another process.  (ErrorCode=32) (TSViewer\TSViewer.ini - [measureTSViewer])
(Original error message is in German, I translated it roughly, hope it's understandable).

The problem seems to be that the WebParser cannot access the .txt file because it is in use (of course, because it's opened by Teamspeak to dump in the real-time channel data). Is there a way to circumvent this?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with Rainmeter Teamspeak Skin

Post by jsmorley »

enderep12 wrote: November 16th, 2018, 2:47 pm Thanks for all the good suggestions, I think I like balala's solution more (at least for my use case) since I'm using a quite large second screen with a lot of free real estate, so I don't necessarily care about showing a maximum number of users. If the list is longer than, say, 10 users, it just can expand further downwards.

However when I switch the measure over to WebParser I get the following problem in my Rainmeter log:

Code: Select all

Fetching: file://C:\Users\enderep\AppData\Roaming\TSViewer\TSViewer.txt (TSViewer\TSViewer.ini - [measureTSViewer])
(Fetch error) The process cannot access the file, because it is currently in use by another process.  (ErrorCode=32) (TSViewer\TSViewer.ini - [measureTSViewer])
(Original error message is in German, I translated it roughly, hope it's understandable).

The problem seems to be that the WebParser cannot access the .txt file because it is in use (of course, because it's opened by Teamspeak to dump in the real-time channel data). Is there a way to circumvent this?
I doubt it. It is unfortunate, and poor coding, that the Lua addon for Teamspeak opens the file in exclusive mode to write to it. That isn't necessary, as the only thing "writing" to the file is the Lua addon. There are no possible conflicts that need to be addressed like that.
enderep12
Posts: 15
Joined: November 15th, 2018, 2:47 pm

Re: Help with Rainmeter Teamspeak Skin

Post by enderep12 »

jsmorley wrote: November 16th, 2018, 3:00 pm I doubt it. It is unfortunate, and poor coding, that the Lua addon for Teamspeak opens the file in exclusive mode to write to it. That isn't necessary, as the only thing "writing" to the file is the Lua addon. There are no possible conflicts that need to be addressed like that.
Highly likely :D Since I'm absolutely not a developer and I have no real clue what I'm doing in regards to that plugin :D I'm happy enough that I got it working. Do you have a suggestion how to change the LUA-Code in order to make the write non-exclusive? The part where I open/write to it is the following:

Code: Select all

	if channelID == ownChannel then
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w")
		io.output(file)
		io.write("".. channelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
	else
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w")
		io.output(file)
		io.write("".. ownChannelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
	end
	io.close()
Would it help to put an io.close() within each part of the if/else? In theory this should close the file after each time the onChannelMove event is triggered and in between that (this means = in between the moments the file is ACTUALLY written into) it should be open to be read instead of keeping it open all the time
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with Rainmeter Teamspeak Skin

Post by jsmorley »

enderep12 wrote: November 16th, 2018, 3:08 pm Highly likely :D Since I'm absolutely not a developer and I have no real clue what I'm doing in regards to that plugin :D I'm happy enough that I got it working. Do you have a suggestion how to change the LUA-Code in order to make the write non-exclusive? The part where I open/write to it is the following:

Code: Select all

	if channelID == ownChannel then
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w")
		io.output(file)
		io.write("".. channelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
	else
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w")
		io.output(file)
		io.write("".. ownChannelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
	end
	io.close()
Would it help to put an io.close() within each part of the if/else?
The first thing I would try is to change all "w" to "w+" in the file open statements.
enderep12
Posts: 15
Joined: November 15th, 2018, 2:47 pm

Re: Help with Rainmeter Teamspeak Skin

Post by enderep12 »

jsmorley wrote: November 16th, 2018, 3:10 pm The first thing I would try is to change all "w" to "w+" in the file open statements.
Yup, that did it in part with moving the io.close after the for loops for the if/else. Thanks! The file is now properly closed after each write (which happens on a "onChannelMove" event (which is when somebody on the server changes channels):

Working Code:

Code: Select all

	if channelID == ownChannel then
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w+")
		io.output(file)
		io.write("".. channelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
		io.close()
	else
		local file = io.open(os.getenv('APPDATA') .. "/TSViewer/TSViewer.txt", "w+")
		io.output(file)
		io.write("".. ownChannelName .."\n")
		for i=1, #clientList do
			local tempClientId = clientList[i]
			local tempClientName = ts3.getClientVariableAsString(serverConnectionHandlerID, tempClientId, ts3defs.ClientProperties.CLIENT_NICKNAME)
			io.write("".. tempClientName .."\n")
		end
		io.close()
	end
Now balalas snippet is working as well and parsing the username correctly in my skin! Now for the channel name :D
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with Rainmeter Teamspeak Skin

Post by jsmorley »

The real issue I have with this is that the Lua apparently re-creates the entire file from scratch each time it is executed. This means that even in non-exclusive mode, WebParser could in theory hit the file and return nothing, or just a partial result, since the Lua could be in the middle of creating and populating the file.

In a perfect world, the Lua would open the file in "append" mode, and just add new stuff to it as needed, rather than re-creating the entire thing all the time. That would likely take some significant change to the logic of the addon though. I don't have Teamspeak, so I can't really get too far into that.
User avatar
balala
Rainmeter Sage
Posts: 16176
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with Rainmeter Teamspeak Skin

Post by balala »

enderep12 wrote: November 16th, 2018, 2:47 pm (Original error message is in German, I translated it roughly, hope it's understandable).
You can easily switch Rainmeter to English, from the Settings tab of the Manage Rainmeter dialog.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with Rainmeter Teamspeak Skin

Post by jsmorley »

balala wrote: November 16th, 2018, 3:20 pm You can easily switch Rainmeter to English, from the Settings tab of the Manage Rainmeter dialog.
That won't change the output of Windows API error messages, which that fetch error is...
enderep12
Posts: 15
Joined: November 15th, 2018, 2:47 pm

Re: Help with Rainmeter Teamspeak Skin

Post by enderep12 »

balala wrote: November 16th, 2018, 3:20 pm You can easily switch Rainmeter to English, from the Settings tab of the Manage Rainmeter dialog.
My Rainmeter is in English, but my Operating System is not, I think this is an error message that was generated from my OS.
jsmorley wrote: November 16th, 2018, 3:16 pm The real issue I have with this is that the Lua apparently re-creates the entire file from scratch each time it is executed. This means that even in non-exclusive mode, WebParser could in theory hit the file and return nothing, or just a partial result, since the Lua could be in the middle of creating and populating the file.

In a perfect world, the Lua would open the file in "append" mode, and just add new stuff to it as needed, rather than re-creating the entire thing all the time. That would likely take some significant change to the logic of the addon though. I don't have Teamspeak, so I can't really get too far into that.
I agree, but this exceeds my coding skills :) For now this is good enough for me, but there is one more problem that I'm sure you guys can help me with.

I switched everything over to balala's method (thanks again!), since I have a lot of screen real estate and I'm fine with the list being (theoretically) endless (it will not be, since my TS has a limited amount of slots anyway). But there seems to be an error with parsing the Channelname (or maybe I created the meter wrong).

This is my current .ini:
TSViewer.ini
This is how my skin looks like and as you can see the channel name is missing (not sure why - the red text is added with Paint, obviously :D in my skin the space is just black)
skin.png
EDIT: FIXED IT, I was missing a DynamicVariables=1 in the meter for channel name!
You do not have the required permissions to view the files attached to this post.
Last edited by enderep12 on November 16th, 2018, 3:28 pm, edited 1 time in total.