mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
changed details to individual values
This commit is contained in:
parent
bc7a76cdd0
commit
9fe54377df
3 changed files with 126 additions and 51 deletions
|
|
@ -32,11 +32,12 @@ mez.input.add_keymap("alt", "q", {
|
||||||
|
|
||||||
mez.input.add_keymap("alt", "v", {
|
mez.input.add_keymap("alt", "v", {
|
||||||
press = function ()
|
press = function ()
|
||||||
local id = mez.view.get_focused_id()
|
local id = mez.output.get_focused_id()
|
||||||
|
|
||||||
local details = mez.view.get_details(id);
|
print(mez.output.get_name(id))
|
||||||
print(details.title);
|
print(mez.output.get_serial(id))
|
||||||
print(details.app_id);
|
print(mez.output.get_model(id))
|
||||||
|
print(mez.output.get_make(id))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ pub fn get_resolution(L: *zlua.Lua) i32 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_details(L: *zlua.Lua) i32 {
|
// Return the serial of the output
|
||||||
|
pub fn get_serial(L: *zlua.Lua) i32 {
|
||||||
const nargs: i32 = L.getTop();
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
if(nargs != 1) {
|
if(nargs != 1) {
|
||||||
|
|
@ -95,41 +96,103 @@ pub fn get_details(L: *zlua.Lua) i32 {
|
||||||
|
|
||||||
L.checkType(1, .number);
|
L.checkType(1, .number);
|
||||||
|
|
||||||
const output_id: u64 = @as(u64, @intCast(L.toInteger(1) catch {
|
errdefer L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
L.raiseErrorStr("Arg is not convertable to an int", .{});
|
const output_id: u64 = @intCast(try L.toInteger(1));
|
||||||
}));
|
|
||||||
|
|
||||||
if(server.root.outputById(output_id)) |output| {
|
if(server.root.outputById(output_id)) |output| {
|
||||||
L.newTable();
|
if(output.wlr_output.serial == null) return 0;
|
||||||
|
|
||||||
if(output.wlr_output.description) |detail| {
|
|
||||||
_ = L.pushString("description");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(output.wlr_output.model) |detail| {
|
|
||||||
_ = L.pushString("model");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(output.wlr_output.make) |detail| {
|
|
||||||
_ = L.pushString("make");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = L.pushString("name");
|
|
||||||
_ = L.pushString(std.mem.span(output.wlr_output.name));
|
|
||||||
L.setTable(-3);
|
|
||||||
|
|
||||||
if(output.wlr_output.serial) |detail| {
|
|
||||||
_ = L.pushString("serial");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.serial.?));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the make of the output
|
||||||
|
pub fn get_make(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
errdefer L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
const output_id: u64 = @intCast(try L.toInteger(1));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
if(output.wlr_output.make == null) return 0;
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.make.?));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the model of the output
|
||||||
|
pub fn get_model(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
errdefer L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
const output_id: u64 = @intCast(try L.toInteger(1));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
if(output.wlr_output.model == null) return 0;
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.model.?));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the description of the output
|
||||||
|
pub fn get_description(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
errdefer L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
const output_id: u64 = @intCast(try L.toInteger(1));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
if(output.wlr_output.description == null) return 0;
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.description.?));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the name of the output
|
||||||
|
pub fn get_name(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 argument, found", .{nargs});
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
errdefer L.raiseErrorStr("Arg is not convertable to an int", .{});
|
||||||
|
const output_id: u64 = @intCast(try L.toInteger(1));
|
||||||
|
|
||||||
|
if(server.root.outputById(output_id)) |output| {
|
||||||
|
_ = L.pushString(std.mem.span(output.wlr_output.name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ pub fn set_focused(L: *zlua.Lua) i32 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_details(L: *zlua.Lua) i32 {
|
pub fn get_title(L: *zlua.Lua) i32 {
|
||||||
const nargs: i32 = L.getTop();
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
if(nargs != 1) {
|
if(nargs != 1) {
|
||||||
|
|
@ -126,20 +126,31 @@ pub fn get_details(L: *zlua.Lua) i32 {
|
||||||
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
if(server.root.viewById(view_id)) |view| {
|
if(server.root.viewById(view_id)) |view| {
|
||||||
L.newTable();
|
if(view.xdg_toplevel.title == null) return 0;
|
||||||
|
|
||||||
if(view.xdg_toplevel.title) |detail| {
|
|
||||||
_ = L.pushString("title");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(view.xdg_toplevel.app_id) |detail| {
|
|
||||||
_ = L.pushString("app_id");
|
|
||||||
_ = L.pushString(std.mem.span(detail));
|
|
||||||
L.setTable(-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(view.xdg_toplevel.title.?));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_app_id(L: *zlua.Lua) i32 {
|
||||||
|
const nargs: i32 = L.getTop();
|
||||||
|
|
||||||
|
if(nargs != 1) {
|
||||||
|
L.raiseErrorStr("Expected 1 arguments, found {d}", .{nargs});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
L.checkType(1, .number);
|
||||||
|
|
||||||
|
const view_id: u64 = @as(u64, @intCast(L.toInteger(1) catch { L.raiseErrorStr("Arg is not convertable to an int", .{}); }));
|
||||||
|
|
||||||
|
if(server.root.viewById(view_id)) |view| {
|
||||||
|
if(view.xdg_toplevel.app_id == null) return 0;
|
||||||
|
|
||||||
|
_ = L.pushString(std.mem.span(view.xdg_toplevel.app_id.?));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue