Skip to content

aquarockslug/tofi-lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

tofi-lua

A Lua wrapper for tofi, a dmenu/rofi replacement for Wayland.

Installation

LuaRocks

luarocks install tofi-lua

Usage

local tofi = require("tofi")

-- Basic usage with options and choices
local menu = tofi
    .options({
        width = "33%",
        height = "33%",
        ["outline-width"] = 4,
        ["prompt-text"] = "Choose:",
        anchor = "center"
    })
    .choices({ "Choice A", "Choice B", "Choice C" })

-- Open the menu and get the result
local result = menu.open()

if result then
    print("You selected: " .. result)
end

API

tofi.options(opts)

Returns a new opener with the specified options.

  • opts: Table of tofi command line options (e.g., { width = "50%", anchor = "top" }).

tofi.choices(items)

Returns a new opener with the specified choices.

  • items: Array of strings to display.

tofi.open()

Opens the tofi window. Returns the selected string, or nil/empty string if cancelled.

tofi.info()

Returns a table containing current choices and options.