Skip to content

Thank you for such an incredible project #276

@CRAG666

Description

@CRAG666

I couldn't find any other way to express my gratitude for such an incredible WM.
I was one of the first users of Newm, and it was an incredible project with an amazing workflow. However, the project was discontinued. Then I switched to Hyprland, and I was never able to replicate my workflow until I found your plugin. It gave me back hope of replicating the flow; I recovered about 70% of it, but it was functional for me. Then you archived it and created this incredible project. At first, I was happy with what it offered (which is a lot), but I still remembered how great Newm was, so I decided to try the Lua scripts, and wow, it was wonderful! I recovered 90% of the workflow I had with Newm, and that made me so happy. I regained my motivation to work for everything. Thank you so much. I hope you can see what the Newm workflow was like and maybe give me some tips. For now, and for anyone who finds it useful, I'm sharing my Lua scripts to achieve something similar. Thanks again.

-- grid_NxM.lua
--
-- Layout automatico tipo "baldosas" (matriz MAX_PER_COL x N) para scroll.
-- Version minima: solo reacciona a view_map. Cuando una columna llega a
-- MAX_PER_COL ventanas, la siguiente abre columna nueva.

local args, state = ...
local scroll = require("scroll")

local arg1 = args and args[1]
local OFF = (arg1 == "off")
local MAX_PER_COL = tonumber(arg1) or 2

local IGNORE_APPS = {
  ["dialog"]                                = true,
  ["pwvucontrol"]                           = true,
  ["nm-connection-editor"]                  = true,
  ["xdg-desktop-portal-gtk"]                = true,
  ["imv"]                                   = true,
  ["org.kde.polkit-kde-authentication-agent-1"] = true,
  ["polkit-gnome-authentication-agent-1"]   = true,
}

local function on_view_map(view, _)
  if not scroll.view_mapped(view) then return end

  local app_id = scroll.view_get_app_id(view)
  if app_id and IGNORE_APPS[app_id] then return end

  local container = scroll.view_get_container(view)
  if not container then return end
  if scroll.container_get_floating(container) then return end

  local workspace = scroll.container_get_workspace(container)
  if not workspace then return end

  -- Subir hasta el top-level (la columna). En scroll: workspace -> columna
  -- (top-level) -> container del view (bottom-level) -> view. Asi
  -- llegamos a la columna en 1-2 hops sin escanear todo el workspace.
  local column = container
  while true do
    local parent = scroll.container_get_parent(column)
    if not parent then break end
    column = parent
  end

  local count = #scroll.container_get_views(column)
  local desired = (count >= MAX_PER_COL) and "horizontal" or "vertical"
  if scroll.workspace_get_mode(workspace).mode ~= desired then
    scroll.workspace_set_mode(workspace, { mode = desired })
  end
end

-- Idempotencia
local prev = scroll.state_get_value(state, "view_map_id")
if prev then
  scroll.remove_callback(prev)
  scroll.state_set_value(state, "view_map_id", nil)
end

if OFF then return end

scroll.state_set_value(state, "view_map_id",
  scroll.add_callback("view_map", on_view_map, nil))
-- focus_diag.lua
--
-- Mueve el foco en diagonal dentro de una grilla de scroll.
--
-- Uso:
--   lua $lua_scripts/focus_diag.lua <ul|ur|dl|dr>
--
-- Direcciones:
--   ul = up-left      ur = up-right
--   dl = down-left    dr = down-right
--
-- Si la columna destino tiene menos filas que la posicion actual, hace
-- "clamp" a la fila valida mas cercana (no se queda sin foco). Si la
-- columna destino esta fuera de rango, no hace nada.

local args, state = ...
local scroll = require("scroll")

local DIRS = {
  ul = { dcol = -1, drow = -1 },
  ur = { dcol =  1, drow = -1 },
  dl = { dcol = -1, drow =  1 },
  dr = { dcol =  1, drow =  1 },
}

local dir = args and args[1]
local delta = dir and DIRS[dir]
if not delta then return end

local focused = scroll.focused_view()
if not focused then return end

local container = scroll.view_get_container(focused)
if not container then return end
if scroll.container_get_floating(container) then return end

local ws = scroll.container_get_workspace(container)
if not ws then return end

local cols = scroll.workspace_get_tiling(ws)

-- Localizar la columna y fila del view enfocado.
local cur_col, cur_row
for ci, col in ipairs(cols) do
  local views = scroll.container_get_views(col)
  for vi, v in ipairs(views) do
    if v == focused then
      cur_col, cur_row = ci, vi
      break
    end
  end
  if cur_col then break end
end

if not cur_col then return end

local target_col = cols[cur_col + delta.dcol]
if not target_col then return end

local target_views = scroll.container_get_views(target_col)
if #target_views == 0 then return end

local target_row = cur_row + delta.drow
if target_row < 1 then target_row = 1 end
if target_row > #target_views then target_row = #target_views end

local target_view = target_views[target_row]
local target_container = scroll.view_get_container(target_view)
if target_container then
  scroll.container_set_focus(target_container)
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions