Module luakit
Luakit core API
This library provides a set of infrastructure and utility functions for controlling luakit, accessing and modifying current settings, running background programs, and more.
Functions
luakit.quit ()
Quit luakit immediately, without asking modules for confirmation.
luakit.spawn (cmd, callback)
Spawn a process asynchronously.
Parameters
-
cmdType: stringThe command to execute. It is parsed with a simple shell-like parser (
g_shell_parse_argv
). -
callbackType: functionOptionalA callback function to execute when the spawned process is terminated, of type
process_exit_cb
.
luakit.spawn_sync (cmd)
Spawn a process synchronously.
Parameters
-
cmdType: stringThe command to execute. It is parsed with a simple shell-like parser (
g_shell_parse_argv
).
Return Values
-
numberThe exit status of the command.
-
stringA string containig data printed on
stdout
. -
stringA string containig data printed on
stderr
.
luakit.time ()
Get the time since Luakit startup.
Return Values
-
numberThe number of seconds Luakit has been running.
luakit.uri_encode (str)
Escape a string for use in a URI.
Parameters
-
strType: stringThe string to encode.
Return Values
-
stringThe escaped/encoded string.
luakit.uri_decode (str)
Unescape an escaped string used in a URI.
Returns the unescaped string, or nil
if the string contains illegal
characters.
Parameters
-
strType: stringThe string to decode.
Return Values
-
stringThe unescaped/decoded string, or
nil
on error. -
stringError 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
-
cbType: functionThe function to call when Luakit is idle, of type
idle_cb
.
luakit.idle_remove (cb)
Remove a function previously registered with idle_add
.
Parameters
-
cbType: functionThe 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
-
schemeType: stringThe network scheme to register.
luakit.wch_upper (key)
Convert a key or key name to uppercase.
Parameters
-
keyType: stringThe key or key name to convert.
Return Values
-
stringThe converted key. This will be the same as
key
if the key is already uppercase or if case conversion does not apply to the key.
luakit.wch_lower (key)
Convert a key or key name to lowercase.
Parameters
-
keyType: stringThe key or key name to convert.
Return Values
-
stringThe converted key. This will be the same as
key
if the key is already lowercase or if case conversion does not apply to the key.
luakit.clear_favicon_database ()
Clear the favicon cache database.
Properties
luakit.config_dir
luakit.data_dir
luakit.cache_dir
luakit.verbose
true
if logging in verbose
or
debug
mode.
luakit.install_path
install_paths.install_dir
instead
luakit.install_paths
luakit.version
luakit.webkit_version
luakit.windows
luakit.enable_spell_checking
false
luakit.spell_checking_languages
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.
luakit.selection
"primary"
, "secondary"
or "clipboard"
).
Primary
When the user selects some text with the mouse, the primary selection is filled automatically with the contents of that text selection.
Secondary
The secondary selection is not used as much as the primary and clipboard selections, but is included here for completeness.
Clipboard
The clipboard selection is filled with the contents of the primary selection when the user explicitly requests a copy operation.
luakit.resource_path
package.path
; it is a semicolon-separated list
of paths, and paths appearing earlier in the list will be searched first when
looking for resource files.
By default, it includes the current directory and the luakit installation directory.
Signals
"page-created"
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
-
pageType: pageThe new page object.
Callback Types
process_exit_cb (reason, status)
Callback type for spawn
.
Parameters
-
reasonType: stringThe reason for process termination. Can be one of
"exit"
, indicating normal termination;"signal"
, indicating the process was killed with a signal; and"unknown"
. -
statusType: integerThe exit status code of the process. Its meaning is system-dependent.
idle_cb ()
Idle callback function type.
Return true
to keep the callback running on idle.
Returning false
or nil
will cause the callback to be
automatically removed from the set of registered idle functions.
Return Values
-
booleanWhether the callback should be kept running on idle.
Attribution
Copyright
- 2016 Aidan Holm
- 2010 Mason Larobina
- Paweł Zuzelski