Module widget

A collection of Widget classes

Functions

temperature_color(temperature, low, high) Generate a temperature based color.

Tables

default_text_color Text color used by widgets if no other is specified.
default_graph_color Color used to draw some widgets if no other is specified.

Fields

default_font_family Font used by widgets if no other is specified.
default_font_size Font size used by widgets if no other is specified.

Class Renderer

Renderer:init(args)
Renderer:layout() Layout all Widgets and cache their backgrounds.
Renderer:update(update_count) Update all Widgets
Renderer:render(cr) Render to the given context

Class Widget

Widget.width Set a width if the Widget should have a fixed width.
Widget.height Set a height if the Widget should have a fixed height.
Widget:layout(width, height) Called at least once to inform the widget of the width and height it may occupy.
Widget:render_background(cr) Called at least once to allow the widget to draw static content.
Widget:update(update_count) Called before each call to Widget:render.
Widget:render(cr) Called once per update to do draw dynamic content.

Class Rows

Rows:init(widgets)

Class Columns

Columns:init(widgets)

Class Filler

Filler:init(args)

Class Frame

Frame:init(widget, args)

Class Text

Text:init(args)

Class StaticText

StaticText:init(text, args)

Class TextLine

TextLine:init(args)
TextLine:set_text(text) Update the text line to be displayed.

Class Bar

Bar:init(args)
Bar:set_fill(fraction) Set the fill-ratio of the bar

Class MemoryBar

MemoryBar:init(args)
MemoryBar:set_used(used) Set the amount of used memory as an absolute value.

Class Graph

Graph:init(args)
Graph:add_value(value) Append the latest value to be shown - this will displace the oldest value

Class LED

LED:init(args)
LED:set_brightness(brightness)
LED:set_color(color)

Class Cpu

Cpu:init(args)

Class CpuRound

CpuRound:init(args)

Class CpuFrequencies

CpuFrequencies:init(args)

Class MemoryGrid

MemoryGrid:init(args)

Class Gpu

Gpu:init() no options

Class GpuTop

GpuTop:init(args)

Class Network

Network:init(args)

Class Drive

Drive:init(path)


Functions

temperature_color(temperature, low, high)
Generate a temperature based color. Colors are chosen based on float offset in a pre-defined color gradient.

Parameters:

  • temperature number current temperature (or any other type of numeric value)
  • low number threshold for lowest temperature / coolest color
  • high number threshold for highest temperature / hottest color

Tables

default_text_color
Text color used by widgets if no other is specified.

Fields:

  • default_text_color {number,number,number,number}
default_graph_color
Color used to draw some widgets if no other is specified.

Fields:

  • default_graph_color {number,number,number,number}

Fields

default_font_family
Font used by widgets if no other is specified.
  • default_font_family string
default_font_size
Font size used by widgets if no other is specified.
  • default_font_size int

Class Renderer

Root widget wrapper Takes care of managing layout reflows and background caching.
Renderer:init(args)

Parameters:

  • args table of options
    • root Widget The Widget subclass that should be rendered, usually a Rows widget
    • width int Width of the surface that should be covered
    • height int Height of the surface that should be covered
Renderer:layout()
Layout all Widgets and cache their backgrounds. Call this once to create the initial layout. Will be called again automatically each time the layout changes.
Renderer:update(update_count)
Update all Widgets

Parameters:

  • update_count int Conky's $updates
Renderer:render(cr)
Render to the given context

Parameters:

  • cr cairo_t

Class Widget

Base Widget class.
Widget.width
Set a width if the Widget should have a fixed width. Omit (=nil) if width should be adjusted dynamically.
Widget.height
Set a height if the Widget should have a fixed height. Omit (=nil) if height should be adjusted dynamically.
Widget:layout(width, height)
Called at least once to inform the widget of the width and height it may occupy.

Parameters:

  • width int
  • height int
Widget:render_background(cr)
Called at least once to allow the widget to draw static content.

Parameters:

  • cr cairo_t Cairo context for background rendering (to be cached by the Renderer)
Widget:update(update_count)
Called before each call to Widget:render. If this function returns a true-ish value, a reflow will be triggered. Since this involves calls to all widgets' :layout functions, reflows should be used sparingly.

Parameters:

  • update_count int Conky's $updates

Returns:

    optional bool true(-ish) if a layout reflow should be triggered, causing all Widget:layout and Widget:render_background methods to be called again
Widget:render(cr)
Called once per update to do draw dynamic content.

Parameters:

  • cr cairo_t

Class Rows

Basic collection of widgets. Rows are drawn in a vertical stack starting at the top of the drawble surface.
Rows:init(widgets)

Parameters:

Class Columns

Display Widgets side by side
Columns:init(widgets)

Parameters:

Class Filler

Leave space between widgets. If either height or width is not specified, the available space inside a Rows or Columns widget will be distributed evenly between Fillers with no fixed height/width. A Filler may contain one other Widget which will have its dimensions restricted to those of the Filler.
Filler:init(args)

Parameters:

  • args table of options
    • width optional int
    • height optional int
    • widget optional Widget

Class Frame

Draw a static border and/or background around/behind another widget.
Frame:init(widget, args)

Parameters:

  • widget Widget Widget to be wrapped
  • args table of options
    • padding number or {number,...} Leave some space around the inside of the frame.
      - number: same padding all around.
      - table of two numbers: {top & bottom, left & right}
      - table of three numbers: {top, left & right, bottom}
      - table of four numbers: {top, right, bottom, left}
    • margin number or {number,...} Like padding but outside the border.
    • background_color optional {number,number,number,number}
    • border_color optional {number,number,number,number} (default transparent)
    • border_width optional number border line width (default 0)
    • border_sides optional {string,...} any combination of "top", "right", "bottom" and/or "left" (default: all sides)

Class Text

Common (abstract) base class for StaticText and TextLine.
Text:init(args)

Parameters:

  • args table of options
    • align optional string "left" (default), "center" or "right"
    • font_family optional string (default w.default_font_family)
    • font_size optional number (default w.default_font_size)
    • font_slant optional cairo_font_slant_t (default CAIRO_FONT_WEIGHT_NORMAL)
    • font_weight optional cairo_font_weight_t (default CAIRO_FONT_SLANT_NORMAL)
    • color optional {number,number,number,number} (default: default_text_color)

Class StaticText

Draw some unchangeable text. Use this widget for text that will never be updated.
StaticText:init(text, args)

Parameters:

  • text string Text to be displayed.
  • args optional table table of options, see Text:init

Class TextLine

Draw a single line of changeable text. Text line can be updated on each cycle via set_text.
TextLine:init(args)

Parameters:

TextLine:set_text(text)
Update the text line to be displayed.

Parameters:

  • text string

Class Bar

Progress-bar like box, similar to conky's bar. Can have small and big ticks for visual clarity, and a unit (static, up to 3 characters) written behind the end.
Bar:init(args)

Parameters:

  • args table of options
    • thickness int vertical size of the bar (default 6)
    • unit optional string to be drawn behind the bar - 3 characters will fit
    • ticks optional {number,...} relative offsets (between 0 and 1) of ticks
    • big_ticks optional int multiple of ticks to be drawn longer
    • color optional {number,number,number} (default: default_graph_color)
Bar:set_fill(fraction)
Set the fill-ratio of the bar

Parameters:

  • fraction number between 0 and 1

Class MemoryBar

Specialized unit-based Bar.
MemoryBar:init(args)

Parameters:

  • args table of options
    • total optional number Total amount of memory to be represented by this bar. If greater than 8, ticks will be drawn. If omitted, total RAM will be used, however no ticks can be drawn.
    • unit string passed to Bar:init (default "GiB")
    • thickness optional int passed to Bar:init
    • color optional {number,number,number} passed to Bar:init
MemoryBar:set_used(used)
Set the amount of used memory as an absolute value.

Parameters:

  • used number should be between 0 and args.total

Class Graph

Track changing data; similar to conky's graphs.
Graph:init(args)

Parameters:

  • args table of options
    • max number maximum expected value to be represented; may be expanded automatically as need arises
    • data_points int how many values to store (default 60)
    • upside_down bool Draw graph from top to bottom? (default false)
    • smoothness number Bézier curves smoothness. Set to 0 to draw straight lines instead, which may be slightly faster. (default 0.5)
    • width int fix width in pixels (optional)
    • height int fixeheight in pixels (optional)
    • color optional {number,number,number} (default: default_graph_color)
Graph:add_value(value)
Append the latest value to be shown - this will displace the oldest value

Parameters:

  • value number if value > args.max then the graphs vertical scale will be adjusted, causing it to get squished

Class LED

Round light indicator for minimalistic feedback.
LED:init(args)

Parameters:

  • args table of options
    • radius number size of the LED
    • brightness number between 0 and 1, how "on" should the LED be? Can be changed later with LED:set_brightness (default 0)
    • color optional {number,number,number} color of the LED, can be changed later with LED:set_color. (default: default_graph_color)
    • background_color optional {number,number,number,number} mostly visible when the LED is off. This allows you to choose a neutral background if you plan on changing the light color via LED:set_color. (default: darkened args.color)
LED:set_brightness(brightness)

Parameters:

  • brightness number between 0 and 1
LED:set_color(color)

Parameters:

  • color optional {number,number,number}

Class Cpu

Polygon-style CPU usage & temperature indicator. Looks best for CPUs with 4 to 8 cores but also works for higher numbers.
Cpu:init(args)

Parameters:

  • args table of options
    • cores int How many cores does your CPU have?
    • scale int radius of central polygon
    • gap int space between central polygon and outer segments
    • segment_size int radial thickness of outer segments

Class CpuRound

Round CPU usage & temperature indicator. Best suited for CPUs with high core counts.
CpuRound:init(args)

Parameters:

  • args table of options
    • cores int How many cores does your CPU have?
    • inner_radius int Size of inner circle
    • outer_radius int Max radius for core at 100%
    • grid int Number of grid lines to draw in the background. (optional)

Class CpuFrequencies

Visualize cpu-frequencies in a style reminiscent of stacked progress bars.
CpuFrequencies:init(args)

Parameters:

  • args table of options
    • cores int How many cores does your CPU have?
    • min_freq number What is your CPU's maximum frequency?
    • min_freq number What is your CPU's maximum frequency?
    • height int Maximum pixel height of the drawn shape (default 16)

Class MemoryGrid

Visualize memory usage in a randomized grid. Does not represent actual distribution of used memory. Also shows buffere/cache memory at reduced brightness.
MemoryGrid:init(args)

Parameters:

  • args table of options
    • rows optional int Number of rows to draw. For nil it will be determined based on Widget height.
    • columns optional int Number of columns to draw. For nil it will be determined based on Widget width.
    • point_size optional int edge length of individual squares (default 2)
    • gap optional int space between squares (default 1)
    • shuffle optional bool randomize? (default true)
    • color optional {number,number,number} (default: default_graph_color)

Class Gpu

Compound widget to display GPU and VRAM usage.
Gpu:init()
no options

Class GpuTop

Table of processes for the GPU, sorted by VRAM usage
GpuTop:init(args)

Parameters:

  • args table of options
    • lines optional int how many processes to display (default 5)
    • font_family optional string
    • font_size optional number
    • color optional {number,number,number} (default: default_text_color)

Class Network

Graphs for up- and download speed. This widget assumes that your conky.text adds some text between the graphs.
Network:init(args)

Parameters:

  • args table of options
    • interface string e.g. "eth0"
    • graph_height optional int passed to Graph:init
    • downspeed number passed as args.max to download speed graph (default 1024)
    • upspeed number passed as args.max to upload speed graph (default 1024)

Class Drive

Visualize drive usage and temperature in a colorized Bar. Also writes temperature as text. This widget is exptected to be combined with some special conky.text.
Drive:init(path)

Parameters:

  • path string e.g. "/home"
generated by LDoc 1.4.6 Last updated 2023-03-26 23:57:51