📜 ⬆️ ⬇️

Using Rainmeter Skin in Enterprise

image Good day, dear habravchane. Many use the Rainmeter for purely visual improvements to the desktop of the operating system, but I got the idea to use it as an add-on to the desktop for users in the enterprise. For example, system information for the user and administrator, access to administrative functions from the panel, launch shortcuts (RPD, URL, BAT), etc.

How did it all begin?

Somehow during the release of Iconia Tab on the x86 platform, I used Windows 7, and under the touchscreen, this brainchild of Microsoft doesn’t fit and had to invent some tricks. Once I came across an article in which some intelligent person came up with a skin for Rainmeter in the form of several keys that played the role of CTRL + C, CTRL + V and their ilk. So I first met Rainmeter. But this acquaintance then was short-lived, since I soon sold the tablet and bought more finger oriented on the Android OS. But after a while I returned to the Rainmeter skins in the form of a clock and a sound card switch, as I had more than one thing in my system at that time, and it was necessary to transfer the sound output to headphones, speakers or TV. Somewhere at the same time at work there was a need to control the labels on the computers of users, by itself I wanted to somehow use the crutches, and not to raise the domain and push everything you need there. At first it was decided to try using RocketDock, but he showed himself from the worst side, and then he stopped working adequately. It was then that I remembered Rainmeter, which could solve this problem, as well as replace desktop widgets with PING statistics to servers and remote objects.

This is how the widget looked with ping to the servers, and there were about 5-10 of these. By itself, all this was inconvenient, it was necessary to configure on each administrator computer separately, and it all ate a large amount of RAM. This is how my epic on programming a versatile widget for the organization in which I work began.

General Description Rainmeter

The common description of the program slightly incorrectly reflects its essence, since in fact the Rainmeter is a kind of scripting language for writing your own widgets for Windows. In no way, its capabilities are not limited to displaying statistics on the used CPU and RAM resources. For those who do not know what it is, we look at the screenshots, or by scoring Google “Rainmeter” we look at the pictures.
Rainmeter can be different:
')




Only flight of fancy or hardware of your computer can limit you. In fact, people write skins for the program, who is in that much. Sometimes masterpieces are made, and sometimes clocks or panels that are dull. I do not consider myself at least some pros in writing skins for Rainmeter, but I can describe the general principles for you.

The program has a management console through which we can set the configuration of various skins, as well as watch logs, create themes.



The skins themselves are stored in the user 's folder “my documents \ Rainmeter \ Skins” , where the folders with your skins are already stored. I have for example IT-Solutions , and in it the index.ini file. So, the main skin code is stored just in such INI files. In simple terms, the code itself is objects and dimensions. Measurements are objects that are not displayed on their own in the body of the skin, but collect some information, for example, about the CPU load. Objects - as such, are skin interface elements, such as: images, text, and so on. In general, the “programming” of the skin is built on this all.



And this is how this code looks in work.

In principle, nothing complicated, 1 element of data collection (plug-in for Rainmeter), 2 text elements (title and content), 2 image elements (edit key and orange bar). Each object has its own parameters that can be modified in the code. All parameters indicate exactly how they are written, it is very difficult to get confused. The program also has the ability to work with LUA code, but everything is organized through special functions for input and output of data from LUA to the Rainmeter and back.

What should be implemented in the skin for the company?

I want to immediately note that the creation of even a plain-skinned one is some kind of development. The problem is that no one can help especially with this, you have to think about the necessity and their implementation in the code. I started by saying that we need to receive data on the status (on the network, not on the network) of servers, remote sites and central switches, but we also had to somehow display all the keys on the desktop of all users to navigate through the URL or launch RDP connect. Of course, immediately thought that you can add some other features. It was decided to add quick access to administrative functions, a personal notebook (local), beautiful watches, computer statistics (to make it easier to diagnose users by phone), as well as in thought the general calendar of work for the sections \ departments \ enterprises and notebooks for divisions. Well, it would be nice to add your own Christmas tree to the desktop of users in the new year, otherwise they themselves start downloading trees with viruses in the kit.

First try

It was also necessary not to forget that different users have different screen resolutions, as well as different preferences in the appearance of the desktop. For the first time, pushing off from the standard scheme of writing skins, I set to work. The code of one of the panels was quickly sawn, and a decent watch was also found. I threw in the keys, mounted the clock, created a panel that would be sized to fit the screen, taking into account the panel. But after a couple of days of work, it was suddenly realized that if the address of the RDP server or the URL of a page was changed, it would be very difficult to change the same values ​​for each user. I decided to rewrite everything anew, but, already focusing on the network component and as it turned out, I did not lose. In Rainmeter, there is an Include function, which works very well at connecting files stored on a Samba resource. I can give the following code as an example:

[CONFIG_LOADER] @Include=#SERVER_SKIN_PATH#./configs/@config-loader.cfg 


Variables in Rainmeter have the form # ololo # , and they must also be declared in a separate [Variables] object. By the way, the work of variables can cause very strong discomfort for those who are accustomed to the usual programming languages ​​or even php. Sometimes the variables simply do not work, and you cannot understand the reason, because logically everything is fine, and especially in another place the same approach works, it is not here. But you have no compiler at all, no error output. Although it may be in the logs, I have never looked into it.

 [Variables] SERVER_SKIN_PATH=\\nas.ag\soft\IT-Solutions.v7 PANEL_WIDTH=300 PANEL_HEIGHT=#WORKAREAHEIGHT# PANEL_TOPPLACE_X=(#SCREENAREAWIDTH# - #PANEL_WIDTH#) PANEL_TOPPLACE_Y=0 PANEL_SOLIDCOLOR=0,0,0,200 PANEL_PADDING_SIZE=10 PANEL_PADDING_SIDE=5 PANEL_SPACING=5 


And in objects the call of variables looks as follows:

 [PANEL] Meter=Image X=#PANEL_TOPPLACE_X# Y=#PANEL_TOPPLACE_Y# W=#PANEL_WIDTH# H=#PANEL_HEIGHT# SolidColor=#PANEL_SOLIDCOLOR# ;RightMouseDownAction=!Execute [ ] 


As I could see, variables are best declared at the beginning of the file and always in the correct sequence. If you use another in the variable, then do not forget to set the donor variable first. For example:

 SCREENWIDTH=1024 PANELWIDTH=#SCREENWIDTH# - 700 


Between mathematical operations and values, spaces are definitely needed, if you write a "formula", then each mathematical expression must be enclosed in brackets:

 PANELWIDTH=(#SCREENWIDTH# – 700) + 10 


And it turned out that I had only the index.ini in the local folder with a bunch of include and a config file with the local configuration, in which data such as username were included to query for this samba configuration file variable. At that moment I didn’t think much about the speed of such a skin, but I thought about the amount of memory that such a skin can begin to use. The final solution seemed simple to me, to increase the skin update timing from 1 second to 10 or 30, and possibly a minute. Based on this position, I programmed the skin in the form of one integral project, how sites are programmed, the entry point as index.ini , and everything else is loaded depending on the conditions. Unfortunately, the conditions in Rainmeter can not directly affect the download of certain files, not counting some crutches through LUA or the standard functions of windows, caused by the conditions in the script. As a result, it turned out that when the script was initialized, all the elements were loaded at once, and I gave them the display parameters, visible or not.

 DynamicVariables=1 Hidden=[VARIABLES_HIDE_CONTENT_LOCAL] 


This is how, in a variable, I defined skin layers, which at one time or another would have to be visible. At first, everything worked out with a bang, but with the addition of all the new functionality, the skin began to take up too much space in memory (although for our computers with 4GB of RAM on board this is not a problem), but at the same time it began to noticeably slow down. I had to figure out how to get around this problem. At first I dug in the direction of the conditions of connection of various components, but often rested on a small number of possibilities in the Rainmeter. I had to return to the scheme, where each layer is a separate file (entry point) for the Rainmeter. In general, I am initially a web programmer, I often use php in my work, and I know firsthand about crutches. But doing something in the Rainmeter is more complicated than outputting one image and a couple of lines of text is associated with powerful crutches, and if you want to still realize the idea, you have to resort to using things that are not obvious at first glance. For example, LUA (I met him recently, purely because of Rainmeter) or use the functions of Windows and others like writing scripts in cmd or powershell.

A bit about nesting files in the skin. A skin is considered a folder in Rainmeter \ Skins with ini files attached to it. If there are several such files, only one of them can be active in one such folder. When you turn on the next, the previous one turns off. Of course, such a problem can be circumvented by creating subfolders and placing new ini files there if necessary. This option was adopted by me for the final implementation of the project. And the fact that we have at this time?

Project Development Plan

The final project is called “IT-Solutions” . I will use it bundled with Windows 7 x86 installed on our office computers. For myself, I created a notation system. The skin consists of two “blocks”, “block” - these are the main elements of the skin, in essence it is a skin panel and a workspace. The panel is placed in the right corner with a width of 300 pixels, and the rest of the space, if necessary, can take up the workspace or as I called this element “Content”. And that we receive in the form of blocks 2 elements: “Panel” and “Content”. Each block is determined by its specific “grid” - this is the location of the functional elements of the block. For example, the panel has top, content and footer. In the top we have the panel switching keys, the main modules hang in the content, and the non-replaceable statistics module in the footer. Modules are skin components that contain some specific code set, for example, a key module or a clock. There are also groups of elements, they are combined with each other by reference to one variable, which determines the visibility of elements at a given time on the skin. Coordinates (grid) was calculated manually, hence a large number of configurations, since you have to specify the exact dimensions and coordinates of absolutely all elements. And you also need to take into account the possibility of different screen resolutions.

At the request of the guys who very often travel on business trips, the local notebook was also listed. It is necessary that the skin does not stop working without connecting to the network, which means that we need to store local content in it. Statistics in the footer and content notebook. These two modules are stored in the skin locally and can be used by the user without connecting to the enterprise network.



If the local part of the skin is loaded first with us, then for those sitting in the enterprise network, you need to load some additional functions and for this purpose a system of layers was invented. Each block is divided into several layers. For the panel, these are the local, user, and “pinger” layers. Exactly at this moment of development, it was decided to apply modularity. The division of the entire skin into its component parts, which can later be used in different places.

It goes without saying that the content in the skin is updated remotely and without the need for an individual update on each of the computers, from here I concluded that you need to load the rest of the giblets from a samba resource. So the rest of the code is mainly located at \\ nas.ag \ soft \ rainmeter \ on the production drive. Only the calling code is stored in local files, but sometimes we may need to refine it and LUA will come to our rescue in this case. In the initializer file, I embedded the LUA file, which will check the relevance of the skin version, and if there is a mismatch, it will download files from the server and then restart the skin. In the local part, located in the skin folder, we have the following files:


Of course, all these conventions used only in my skin. When switching to another layer, the first one turns off. This possibility allowed me to realize switching between layers without additional crutches. When all the layers were in the same ini file, switching between them worked faster, but at the same time the initial loading of the skin took a very long time (about 2-5 seconds).

Let's talk a little more about index.ini - this file is an initializer, it loads the general configuration into itself (to access network components), and then loads an initialization script from the LUA network, which includes version checking and skin update, if necessary . Next we have a LUA script that switches the layer, since if there is a network, you need to load layer2 , which contains special content for users.

Local files:
 / IT-Solutions /@CONTENT Layer1.ini Layer2.ini /@PANEL Layer1.ini Layer2.ini Layer3.ini /@WINDOWS Content.ini Panel.ini /backgrounds CONTENT.cfg PANEL.cfg /configs @config-loader.cfg Config.cfg Styles.cfg User.cfg Variables.cfg /LUA initialize.lua /modules Notepad.cfg Statistic.cfg / Resources /img Edit.png Refresh.png Notepad.txt 


As you can see, a considerable number of different files are used for decoration. Block layers, configuration for backdrops (backgrounds), configurations of various kinds (@ config-loader - download network configuration files, config - general configuration, sytles - text display styles, user - user configuration, variables - variables), LUA initialization script, a couple modules and some files for them.

From the network side everything is a bit more complicated, but, in general, everything is in the same vein. Each layer in the skin requests the corresponding file from the network and draws itself from it.



The following modules were allocated for network operation.



In the end, everything looks like this:







Things like "calendar" and "tasks" have not yet been completed. Access to admin functions is provided through the execas program. As one of the access keys, an HTML file with JS code is used, which automatically authorizes each of the users on Yandex mail. The pop-up access window in “ pinger ” allows you to immediately access, via various types of clients, the necessary address. And this whole mess eats no more than 30 MB of RAM, as opposed to 100 MB, at a time when all the code was loaded from one file.



, . , - , Rainmeter . 2 index.ini , , . , . , , , , , “ Cowon Clock ”.

Future plans

. , , . , ( ), . - , Rainmeter . . , 10 . , , . , , . , . , . , .
: , HD ( ), .

Afterword

Thanks for the tip. , , , ? .

, , , , . 700 , DSL wifi . , , , , . , , , . , , . , , . , , - , .

It would seem, why not do the same thing in C # or Delphi, the choice of many adequate development environments and languages, but the point is to test. When programming such a skin, all the time you have to invent something for yourself, look for non-logical solutions to the problem. But you know, it works. Moreover, none of those who may come to work after me will be able to maintain the system, but if you leave behind you instructions and software developed with a very low level of entry, you can hope that former ptushniki will be able to come to the least programming and love this thing.
, , , . , , , . . , , , , .

Hanging shortcuts in the “Keys” section allow users to no longer remember boring addresses and connection instructions. It would seem that something difficult to remember such addresses as: wiki.ag or phones.ag, but you won’t believe, almost no one remembers them. But services are created for a reason. Wiki engine is needed in the enterprise for documentation and not only for programmers or network administrators, but also for communications workers, accountants, lawyers and economists. A lot of instructions can be stored there and some data about those works that in the future will have to be done again. How often did it happen that a burned hard disk, on the computer of the chief accountant, buried the work of the entire accounting department for a week. In the same place ten programs and each of which demands the special approach. Somewhere a hardware key is required, somewhere a certificate,but somewhere you need to podshamanit the configuration, since the addresses of the bank’s servers have changed, and the bank hasn’t been able to update the client’s bank’s version, because the people who wrote the first version have long since quit. As everyone knows, there is no life behind the MKAD, and as it was correctly noted, usually in enterprises one or several software engineers do the work of a communications man and installer and system administrator, and at leisure they also need to concoct a site for the office.and in their leisure time they also need to concoct a website for an office.and in their leisure time they also need to concoct a website for an office.

Well, having discussed the possibilities of Rainmeter with a couple of colleagues, we came to the conclusion that statistics about the computer would be very useful for us. Diagnose by phone will be easier. After all, when a user says that the Internet does not work for him - this does not mean that he really does not work. It is possible that someone was mistaken with entering the address in the browser. And asking for a look at the color of the labels at the bottom of the panel is still easier than asking to ping. Yes, we have the ability to connect remotely to the working sessions of users, but sometimes this is unnecessary, since the issue can be solved in one phrase.

In the course of working on the skin I used official documentation and articles on the sites:


Google

Source: https://habr.com/ru/post/229869/


All Articles