mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-08 04:57:32 -04:00
properly load all plugins to lua package path
This commit is contained in:
parent
87259f96cb
commit
12fa725505
8 changed files with 56 additions and 94 deletions
0
runtime/share/mezzaluna/base_config.lua
Normal file
0
runtime/share/mezzaluna/base_config.lua
Normal file
|
|
@ -1,5 +1,4 @@
|
|||
local env_conf = os.getenv("XDG_CONFIG_HOME")
|
||||
|
||||
if not env_conf then
|
||||
env_conf = os.getenv("HOME")
|
||||
if not env_conf then
|
||||
|
|
@ -8,13 +7,31 @@ if not env_conf then
|
|||
env_conf = mez.fs.joinpath(env_conf, ".config")
|
||||
end
|
||||
|
||||
local env_data = os.getenv("XDG_DATA_HOME")
|
||||
if not env_data then
|
||||
env_data = os.getenv("HOME")
|
||||
if not env_data then
|
||||
error("Couldn't determine potential data directory is $HOME set?")
|
||||
end
|
||||
|
||||
env_data = mez.fs.joinpath(env_data, ".local", "share", "mez")
|
||||
end
|
||||
|
||||
-- allow plugin loading in .local/share/mez/plugins
|
||||
local plugin_dir = mez.fs.joinpath(env_data, "plugins")
|
||||
|
||||
for _, plugin_name in ipairs(mez.fs.subdirs(plugin_dir)) do
|
||||
package.path = package.path .. ";" .. mez.fs.joinpath(plugin_dir, plugin_name, "lua", "?", "init.lua")
|
||||
package.path = package.path .. ";" .. mez.fs.joinpath(plugin_dir, plugin_name, "lua", "?.lua")
|
||||
end
|
||||
|
||||
-- allow loading files in the runtime directory
|
||||
package.path = package.path..";"..mez.fs.joinpath(mez.path.runtime, "?.lua")
|
||||
package.path = package.path .. ";" .. mez.fs.joinpath(mez.path.runtime, "?.lua")
|
||||
mez.inspect = require("inspect").inspect
|
||||
|
||||
mez.path.base_config = mez.fs.joinpath(mez.path.runtime, "master.lua")
|
||||
mez.path.base_config = mez.fs.joinpath(mez.path.runtime, "base_config.lua")
|
||||
|
||||
if not mez.path.config then
|
||||
mez.path.config = mez.fs.joinpath(env_conf, "mez", "init.lua")
|
||||
package.path = package.path..";"..mez.fs.joinpath(env_conf, "mez", "lua", "?.lua")
|
||||
package.path = package.path .. ";" .. mez.fs.joinpath(env_conf, "mez", "lua", "?.lua")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
---@module 'master'
|
||||
|
||||
---@class Master
|
||||
---@field default_config MasterConfig
|
||||
---@field config MasterConfig
|
||||
---@field state MasterState
|
||||
---@field builtins MasterBuiltins
|
||||
local M = {};
|
||||
|
||||
M.builtins = {
|
||||
}
|
||||
|
||||
---@class MasterConfig
|
||||
---@field master_ratio number
|
||||
---@field tag_count number
|
||||
local default_config = {
|
||||
master_ratio = 0.5,
|
||||
tag_count = 5,
|
||||
|
||||
}
|
||||
|
||||
---@class Tag
|
||||
---@field floating number[]
|
||||
---@field stack number[]
|
||||
|
||||
---@class MasterState
|
||||
---@field tag_id number
|
||||
M.state = {
|
||||
tag_id = 1
|
||||
}
|
||||
|
||||
M.setup = function(config)
|
||||
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
local test = function()
|
||||
-- View tests
|
||||
mez.api.spawn("alacritty")
|
||||
local focused_view = mez.view.get_focused_id()
|
||||
print(focused_view)
|
||||
|
||||
for i = 0,4 do
|
||||
mez.api.spawn("alacritty")
|
||||
end
|
||||
|
||||
local view_ids = mez.view.get_all_ids()
|
||||
for _, id in ipairs(view_ids) do
|
||||
print(id)
|
||||
mez.view.close(id)
|
||||
end
|
||||
|
||||
print(mez.view.get_title(0))
|
||||
print(mez.view.get_title(focused_view))
|
||||
print(mez.view.get_app_id(0))
|
||||
print(mez.view.get_app_id(focused_view))
|
||||
|
||||
mez.view.set_position(0, 100, 100)
|
||||
mez.view.set_position(focused_view, 200, 200)
|
||||
mez.view.set_size(0, 100, 100)
|
||||
mez.view.set_size(focused_view, 200, 200)
|
||||
|
||||
-- Output tests
|
||||
local focused_output = mez.output.get_focused_id()
|
||||
print(focused_output)
|
||||
|
||||
local output_ids = mez.output.get_all_ids()
|
||||
for _, id in ipairs(output_ids) do
|
||||
print(id)
|
||||
end
|
||||
|
||||
print(mez.output.get_name(0))
|
||||
print(mez.output.get_name(focused_output))
|
||||
print(mez.output.get_description(0))
|
||||
print(mez.output.get_description(focused_output))
|
||||
print(mez.output.get_model(0))
|
||||
print(mez.output.get_model(focused_output))
|
||||
print(mez.output.get_make(0))
|
||||
print(mez.output.get_make(focused_output))
|
||||
print(mez.output.get_serial(0))
|
||||
print(mez.output.get_serial(focused_output))
|
||||
print(mez.output.get_rate(0))
|
||||
print(mez.output.get_rate(focused_output))
|
||||
|
||||
local res = mez.output.get_resolution(0)
|
||||
print(res.width .. ", " .. res.height)
|
||||
end
|
||||
|
|
@ -52,7 +52,7 @@ pub fn init(device: *wlr.InputDevice) *Keyboard {
|
|||
|
||||
self.wlr_keyboard.data = self;
|
||||
|
||||
std.log.err("Adding new keyboard {s}", .{device.name orelse "(unnamed)"});
|
||||
std.log.info("Adding new keyboard {s}", .{device.name orelse "(unnamed)"});
|
||||
if (!server.seat.keyboard_group.wlr_group.addKeyboard(self.wlr_keyboard)) {
|
||||
std.log.err("Adding new keyboard {s} failed", .{device.name orelse "(unnamed)"});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ fn handleDestroy(listener: *wl.Listener(*wlr.LayerSurfaceV1), _: *wlr.LayerSurfa
|
|||
|
||||
fn handleMap(listener: *wl.Listener(void)) void {
|
||||
const layer_suraface: *LayerSurface = @fieldParentPtr("map", listener);
|
||||
std.log.debug("layer surface mapped", .{});
|
||||
layer_suraface.output.arrangeLayers();
|
||||
layer_suraface.allowKeyboard();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,3 +38,37 @@ pub fn joinpath(L: *zlua.Lua) i32 {
|
|||
_ = L.pushString(final_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// ---List sub-directories given an abosolute parent path
|
||||
/// ---@param string path
|
||||
/// ---@return string[] list of sub directories
|
||||
pub fn subdirs(L: *zlua.Lua) i32 {
|
||||
const nargs: i32 = L.getTop();
|
||||
if (nargs != 1) {
|
||||
L.raiseErrorStr("Expected exactly one path", .{});
|
||||
return 0;
|
||||
}
|
||||
|
||||
const path = L.checkString(1);
|
||||
|
||||
var dir = std.fs.openDirAbsoluteZ(path, .{ .iterate = true }) catch {
|
||||
L.raiseErrorStr("Directory does not exist", .{});
|
||||
};
|
||||
defer dir.close();
|
||||
var dir_it = dir.iterate();
|
||||
|
||||
L.newTable();
|
||||
|
||||
var i: i32 = 1;
|
||||
while(dir_it.next() catch {
|
||||
L.raiseErrorStr("An error has occured while getting subdirectories", .{});
|
||||
}) |entry| : (i += 1) {
|
||||
if (entry.kind != .directory and entry.kind != .sym_link ) continue;
|
||||
|
||||
L.pushInteger(i);
|
||||
_ = L.pushString(entry.name);
|
||||
L.setTable(-3);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue