From 15372f7dcfc027cd5bf767584de0e826cc876612 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 8 Apr 2020 17:44:01 +0200 Subject: utils: work with screen objects rather than indices --- utils.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'utils.lua') diff --git a/utils.lua b/utils.lua index 51d159a..ebb1995 100644 --- a/utils.lua +++ b/utils.lua @@ -4,26 +4,26 @@ local awful = require("awful") -- mapping from logical screen indices to indices corresponding to their -- physical layout -local function map_screen_physical(n) +local function screen_physical(n) local function screen_cmp(s1, s2) - return s1[2].geometry.x < s2[2].geometry.x + return s1.geometry.x < s2.geometry.x end local screens = {} - for s = 1, screen.count() do - screens[s] = {s, screen[s]} + for s in screen do + screens[s.index] = s end table.sort(screens, screen_cmp) if screens[n] ~= nil then - return screens[n][2] + return screens[n] end return nil end function M.screen_focus_physical(n) - local s = map_screen_physical(n) + local s = screen_physical(n) if s then awful.screen.focus(s) end -- cgit v1.2.3