Module luakit

Luakit core API

This module is builtin and does not need to be manually loaded.
Some functions and fields are not available from web processes.

Functions

luakit.quit ()

Quit luakit immediately, without asking modules for confirmation.

luakit.get_selection (clipboard)

Get the contents of the X selection.

Parameters

  • clipboard
    Type: string
    The name of the X clipboard to use (one of "primary", "secondary" or "clipboard").

Return Values

  • string
    The contents of the named selection.

luakit.set_selection (text, clipboard)

Set the contents of the X selection.

Parameters

  • text
    Type: string
    The UTF-8 string to be copied to the named selection.
  • clipboard
    Type: string
    The name of the X clipboard to use (one of "primary", "secondary" or "clipboard").

luakit.spawn (cmd, callback)

Spawn a process asynchronously.

Parameters

  • cmd
    Type: string
    The command to execute. It is parsed with a simple shell-like parser.
  • callback
    Type: function
    Optional
    A callback function to execute when the spawned process is terminated. It receives two parameters reason and status, which are the reason for the process exit and the exit status code respectively. reason can be one of "exit", indicating normal termination; "signal", indicating the process was killed with a signal; and "unknown".

luakit.spawn_sync (cmd)

Spawn a process synchronously.

This will block the luakit UI until the process exits.

Parameters

  • cmd
    Type: string
    The command to execute. It is parsed with a simple shell-like parser.

Return Values

  • number
    The exit status of the command.
  • string
    A string containig data printed on stdout.
  • string
    A string containig data printed on stderr.

luakit.time ()

Get the time since Luakit startup.

Return Values

  • number
    The number of seconds Luakit has been running.

luakit.uri_encode (str)

Escape a string for use in a URI.

Parameters

  • str
    Type: string
    The string to encode.

Return Values

  • string
    The escaped/encoded string.

luakit.uri_encode (str)

Unescape an escaped string used in a URI.

Returns the unescaped string, or nil if the string contains illegal characters.

Parameters

  • str
    Type: string
    The string to decode.

Return Values

  • string
    The unescaped/decoded string, or nil on error.
  • string
    Error message.

luakit.idle_add (cb)

Add a function to be called regularly when Luakit is idle. If the function returns false, or if an error is encountered during execution, the function is automatically removed from the set of registered idle functions, and will not be called again.

The provided callback function is not called with any arguments; to pass context to the callback function, use a closure.

Parameters

  • cb
    Type: function
    The function to call when Luakit is idle.

luakit.idle_remove (cb)

Remove a function previously registered with idle_add.

Parameters

  • cb
    Type: function
    The function to removed from the set of idle callbacks.

Return Values

  • boolean
    true if the callback was present (and removed); false if the callback was not found.

luakit.register_scheme (scheme)

Register a custom URI scheme.

Registering a scheme causes network requests to that scheme to be redirected to Lua code via the signal handling interface. A signal based on the scheme name will be emitted on a webview widget when it attempts to load a URI on the registered scheme. To return content to display, as well as an optional mime-type, connect to the signal and return a string with the content to display.

This interface is used to register the luakit:// scheme, but is not limited to this prefix alone.

Example

Registering a scheme foo will cause URIs beginning with foo:// to be redirected to Lua code. A signal scheme-request::foo will be emitted on a webview in response to a foo:// load attempt, and should be handled to provide contentt.

Parameters

  • scheme
    Type: string
    The network scheme to register.

Properties

luakit.enable_spell_checking

Type: boolean
Default: false
Read-write
Whether spell checking is enabled.

luakit.spell_checking_languages

Type: {string}
Read-write
The set of languages to use for spell checking, if spell checking is enabled.

Each item in the table is a code of the form lang_COUNTRY, where lang is an ISO-639 language code, in lowercase, and COUNTRY is an ISO-3166 country code, in uppercase.

When setting a new value for this property, any unrecognized codes are discarded and a warning is logged, but no error is generated.

This property has a default value based on the user's locale. Setting this value to {} will reset it to the default value.

Signals

"page-created"

This signal is only emitted on the web process of the newly-created page.

Emitted after the creation of a page object; i.e. after a new webview widget has been created in the UI process.

Usage

luakit.add_signal("page-created", function (page)
    -- Add more signals to page
end)

Parameters

  • page
    Type: page
    The new page object.

Fields

luakit.config_dir

Type: string
Read-only
The configuration directory path (default: $XDG_CONFIG_HOME).

luakit.data_dir

Type: string
Read-only
The data directory path (default: $XDG_DATA_HOME).

luakit.cache_dir

Type: string
Read-only
The cache directory path (default: $XDG_CACHE_HOME).

luakit.verbose

Type: boolean
Read-only
Whether luakit is using verbose logging. true if logging in verbose or debug mode.

luakit.install_path

Type: string
Read-only
The luakit installation path.

luakit.version

Type: string
Read-only
The luakit version.

luakit.windows

Type: {widget}
Read-only
An array of all active window widgets.

Attribution

Authors

  • Aidan Holm
  • Mason Larobina
  • Paweł Zuzelski

Copyright