2024-01-12 04:58:35 +01:00
local cqueues = require ( " cqueues " )
local client = require ( " pinnacle.grpc.client " )
2024-01-15 02:53:43 +01:00
---The entry point to configuration.
---
---This module contains one function: `setup`, which is how you'll access all the ways to configure Pinnacle.
2024-01-12 04:58:35 +01:00
---@class PinnacleModule
2024-01-13 00:20:34 +01:00
local pinnacle = {
version = " v0alpha1 " ,
}
2024-01-12 04:58:35 +01:00
2024-01-15 02:53:43 +01:00
---The Pinnacle module.
---
---This module holds all the other configuration modules (Window, Input, etc.), and allows you to
---quit the compositor using the `quit` method.
2024-01-12 04:58:35 +01:00
---@class Pinnacle
---@field private config_client Client
---@field input Input
2024-01-13 03:15:58 +01:00
---@field output Output
---@field process Process
---@field tag Tag
---@field window Window
2024-01-12 04:58:35 +01:00
local Pinnacle = { }
2024-01-15 02:35:54 +01:00
---Quit Pinnacle.
2024-01-12 04:58:35 +01:00
function Pinnacle : quit ( )
self.config_client : unary_request ( {
service = " pinnacle.v0alpha1.PinnacleService " ,
method = " Quit " ,
request_type = " pinnacle.v0alpha1.QuitRequest " ,
data = { } ,
} )
end
---Setup Pinnacle.
2024-01-15 03:03:58 +01:00
---
---You must pass in a function that takes in the `Pinnacle` module (it's more like a class but it's pretty much a module). The module is how you'll access the other config modules.
---
---If you want to do a multi-file config, you should have other files return a function taking in necessary modules.
---Or you could cheat and stick the modules into globals :TrollFace:
---
2024-01-12 04:58:35 +01:00
---@param config_fn fun(pinnacle: Pinnacle)
function pinnacle . setup ( config_fn )
require ( " pinnacle.grpc.protobuf " ) . build_protos ( )
2024-01-13 00:20:34 +01:00
2024-01-12 04:58:35 +01:00
local loop = cqueues.new ( )
2024-01-13 00:20:34 +01:00
2024-01-12 04:58:35 +01:00
local config_client = client.new ( loop )
---@type Pinnacle
local self = {
config_client = config_client ,
input = require ( " pinnacle.input " ) . new ( config_client ) ,
2024-01-13 03:15:58 +01:00
process = require ( " pinnacle.process " ) . new ( config_client ) ,
window = require ( " pinnacle.window " ) . new ( config_client ) ,
output = require ( " pinnacle.output " ) . new ( config_client ) ,
tag = require ( " pinnacle.tag " ) . new ( config_client ) ,
2024-01-12 04:58:35 +01:00
}
setmetatable ( self , { __index = Pinnacle } )
config_fn ( self )
2024-01-13 00:20:34 +01:00
loop : loop ( )
2024-01-12 04:58:35 +01:00
end
return pinnacle