diff --git a/environments/river/home.nix b/environments/river/home.nix index 05c3527..3de32a9 100644 --- a/environments/river/home.nix +++ b/environments/river/home.nix @@ -30,6 +30,8 @@ in { ]; services.cliphist.enable = true; + xdg.configFile."river-luatile/layout.lua".source = ./layout.lua; + wayland.windowManager.river = { enable = true; extraSessionVariables = { diff --git a/environments/river/layout.lua b/environments/river/layout.lua index a6a97fc..9473868 100644 --- a/environments/river/layout.lua +++ b/environments/river/layout.lua @@ -21,31 +21,6 @@ function _get_output(name) return outputs[name] end -function inspect(tbl) - local result = "{" - for k, v in pairs(tbl) do - -- Check the key type (ignore any numerical keys - assume its an array) - if type(k) == "string" then - result = result .. "[\"" .. k .. "\"]" .. "=" - end - - -- Check the value type - if type(v) == "table" then - result = result .. inspect(v) - elseif type(v) == "boolean" then - result = result .. tostring(v) - else - result = result .. "\"" .. v .. "\"" - end - result = result .. "," - end - -- Remove leading commas from the result - if result ~= "" then - result = result:sub(1, result:len() - 1) - end - return result .. "}" -end - -- The most important function - the actual layout generator -- -- The argument is a table with: @@ -65,7 +40,6 @@ end -- This example is a simplified version of `rivertile` function handle_layout(args) local output = _get_output(args.output) - print(inspect(output)) -- Prevent mcount from growing too much. We can't do that in the set function. output.mcount = math.min(output.mcount, args.count) @@ -82,7 +56,6 @@ function handle_layout(args) table.insert(ret, { outer_gaps, outer_gaps, args.width - outer_gaps * 2, args.height - outer_gaps * 2 }) end end - print("monocle", inspect(ret), args.count) return ret end @@ -116,7 +89,6 @@ function handle_layout(args) side_h, }) end - print("tiling", inspect(ret), args.count) return ret end @@ -162,3 +134,30 @@ function set_layout(name) output.layout = name end end + +-- Just an helper function to print tables. +function inspect(tbl) + local result = "{" + for k, v in pairs(tbl) do + -- Check the key type (ignore any numerical keys - assume its an array) + if type(k) == "string" then + result = result .. "[\"" .. k .. "\"]" .. "=" + end + + -- Check the value type + if type(v) == "table" then + result = result .. inspect(v) + elseif type(v) == "boolean" then + result = result .. tostring(v) + else + result = result .. "\"" .. v .. "\"" + end + result = result .. "," + end + -- Remove leading commas from the result + if result ~= "" then + result = result:sub(1, result:len() - 1) + end + return result .. "}" +end + diff --git a/modules/wm/ags/modules/wm.js b/modules/wm/ags/modules/wm.js index d57e99c..1c88d7c 100644 --- a/modules/wm/ags/modules/wm.js +++ b/modules/wm/ags/modules/wm.js @@ -68,7 +68,10 @@ const TagItem = ({ occupied, selected, urgent, i, output, label }) => /** @param {{monitor: number } & import("types/widgets/label").LabelProps} props */ export const Layout = ({ monitor, ...props }) => - Widget.Label(props).hook( + Widget.Label({ + className: "module", + ...props, + }).hook( river, (self) => { const output = getOutput(monitor);