Skip to content

[FEAT] improve dynamic main width / multi monitor support #13

@sand4rt

Description

@sand4rt

this is possible now to have a dynamic main with. (hyprland example):

require('zen').setup({
  main = {
    width = function()
      local ok, result = pcall(function()
        local handle = assert(io.popen("hyprctl monitors -j"))
        local output = handle:read("*a")
        handle:close()
        return output
      end)

      if not ok then return nil end

      local monitors = vim.json.decode(result)
      local width_map = {
        [1366] = 80,   -- HD laptop
        [1440] = 85,   -- WXGA+
        [1600] = 95,   -- HD+ laptop
        [1920] = 110,  -- 1080p
        [2560] = 148,  -- 1440p / QHD
        [2880] = 158,  -- Retina 15"
        [3440] = 185,  -- Ultrawide 1440p
        [3840] = 198,  -- 4K
        [5120] = 240,  -- 5K / Super Ultrawide
      }

      for _, mon in ipairs(monitors) do
        if width_map[mon.width] then
          return width_map[mon.width]
        end
      end
    end,
  },
})

but it would be nice to support a table where the minitor name + the width is specified:

require('zen').setup({
  main = {
    width = {
        "*" = 148,
        monitor_name1 = 80,
        monitor_name2 = 85,
        monitor_name3 = 95,
        monitor_name4 = 110,
      }
   }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions