Rainmeter Snippets
This is a collection of useful "snippets" of Lua script code for users of Rainmeter, a desktop customization tool for Windows. It is maintained by the Rainmeter development team, and hosted on GitHub.
General
Deliminate
A function that separates a string into parts by a given delimiter.SortRandom
A function that sorts a given table into a random order.Switch
A function that emulates a switch statement.MinValue / MaxValue
A function that returns the minimum or maximum numeric or alphabetical value of a set.
Conversions
Colors
Functions that convert color codes from RGB to HEX, and vice versa.Convert Temperatures
Converts temperatures between Celsius and Fahrenheit.
File Input & Output
Read & Write a File
Functions that read and write any string to or from a text file.Read INI
A function that parses an INI formatted text file into a table, with the structureTable[Section][Parameter] = Value
.Write INI
A function that writes an INI formatted text file from a given table, with the structureTable[Section][Parameter] = Value
.
Math
Add Commas
Returns an input number as a string formatted with commas.Add Suffix
Returns the ordinal suffix for an input number.AutoScale
A function that scales a number of bytes, with an optional number of decimal places. Returns a second string value with the scale suffix.Average
A function that averages a list of numbers.Round
Rounds a number (num) to any optional number of decimal places (idp)Clamp
Constrains a number between low and high values.
Methods
Detect Value Change
A simple method for "watching" a data value in the skin (variable, measure or option) and taking action when the value changes.Nested Expressions
A method for parsing a string with nested expressions such as variables (i.e.{SomeVariable{SomethingElse}}
).Set Meter & Measure Options
A simple method for setting multiple options on the same meter or measure.
Rainmeter
Root Config Name
A function that takes a Rainmeter skin's config name and returns the root config name for that skin.
Strings
- Parse File Path
A function that breaks down a file or folder path and returns the components as a table. - Change Case
A set of function to change a string to either Sentence Case or Title Case.
Time
Convert Time
A function that converts Unix epoch timestamps into Windows FILETIME timestamps (in seconds) and vice versa.Parse 12-Hour Time
A function that takes a number (1-12) and a string ('AM' or 'PM') and returns the equivalent 24-hour figure.Format Seconds Into Time Intervals
A function that takes a number of seconds, and returns values for weeks, days, hours, minutes, and seconds.