Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rift.lua

Lua Mach IPC client for Rift WM.

Build

cd rift.lua
make

The makefile uses Lua headers from pkg-config when available, checking Lua 5.5 first, otherwise it uses the bundled lua-5.4.7 headers.

make LUA=/opt/homebrew/bin/lua  # match headers to a specific Lua executable
make LUA_PC=lua5.5              # prefer a specific Lua pkg-config module for headers
make USE_SYSTEM_LUA=0           # force bundled Lua headers
make LINK_LUA=1                 # explicitly link Lua for non-embedded use cases

Outputs: rift.lua/bin/rift.so

Load

package.cpath = "./bin/?.so;" .. package.cpath
local rift = require("rift")

Connect

local client, err = rift.connect()
if not client then error(err) end

client:reconnect() reconnects and returns the same client object.

Request/Response API

local resp, err = client:send_request([[{"get_workspaces":{"space_id":null}}]])
if not resp then error(err) end
  • Input is raw JSON string.
  • Output is decoded Lua table.

Event Streaming

Supported events:

  • workspace_changed
  • windows_changed
  • window_title_changed
  • stacks_changed
  • * (all)

Callback mode (recommended)

client:subscribe({ "*" }, function(env)
  -- env.INFO: raw JSON string
  -- env.EVENT: event name (e.g. "windows_changed")
  -- env.DATA: decoded table
  print(env.EVENT)
end)

subscribe(events, callback) returns immediately and auto-dispatches callbacks.

Notes

  • If you subscribe to *, you will receive all Rift broadcast event types listed above.
  • Keep your Lua process alive to keep receiving events.

Acknowledgements

https://github.com/FelixKratz/SbarLua

About

lua client for rift-wm

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages