История изменений
Исправление dissident, (текущая версия) :
Ну вот я упростил немного и убрал лишнюю проверку (screen == nil or awful.widget.tasklist.filter.currenttags(c, screen)
- особо читаемей не стало:
-- {{{ Mine
-- {{{ From https://www.reddit.com/r/awesomewm/comments/gd4qxl/get_index_of_client_in_tasklist/ with some modifications
local function fixed_indexing_filter(c)
if not c then
return false
end
if not (c.skip_taskbar or c.hidden or c.type == "splash" or c.type == "dock" or c.type == "desktop") then
return true
end
return false
end
function focused_screen_current_tag_client_iterator()
local focused_screen = awful.screen.focused()
local selected_tag_filter = function (c) return c.first_tag == focused_screen.selected_tag end
local first_client_taskbar_idx = 1
return awful.client.iterate(selected_tag_filter, first_client_taskbar_idx, focused_screen)
end
-- Returns client index in the taskbar (first on the left will have index = 1)
local function client_taskbar_idx(client)
local client_taskbar_idx = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c) then
client_taskbar_idx = client_taskbar_idx + 1
if (c == client) then
return client_taskbar_idx
end
end
end
return nil
end
-- }}}
-- Returns total number of clients in the currently selected tag
local function selected_tag_number_of_clients()
local number_of_clients = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c) then
number_of_clients = number_of_clients + 1
end
end
return number_of_clients
end
-- Switches focus to the client of index in the taskbar = taskbar_idx:
-- * client with 1st taskbar item will have index 1
-- * client with 2nd taskbar item will have index 2
-- * etc
local function client_focus_by_taskbar_idx(taskbar_idx)
-- User wants to focus a non-existing client, e.g. there are only 2 opened in
-- focused screen selected tag clients and user wants to focus 3rd one, as there is
-- no 3rd one just do nothing
if taskbar_idx < 1 or taskbar_idx > selected_tag_number_of_clients() then
return
end
local focused_client = awful.client.next(0)
if focused_client ~= nil then
local focused_client_taskbar_idx = client_taskbar_idx(focused_client)
if focused_client_taskbar_idx ~= nil then
local relative_idx = taskbar_idx - focused_client_taskbar_idx
awful.client.focus.byidx(relative_idx)
end
end
end
-- }}}
-- }}}
(awful.key - байндинги уже не всобачиваю, там тоже самое).
Ай Lua как Lua. Вон WoW весь на ней построен. Эта match3 игра где надо апгрейды в виде выигрыша делать дому там, саду, русская, на мобилко, суперпопулярная, в Lua. И ниче, нормально.
Кому-то надо Haskell.
Исправление dissident, :
Ну вот я упростил немного и убрал лишнюю проверку (screen == nil or awful.widget.tasklist.filter.currenttags(c, screen)
- особо читаемей не стало:
-- {{{ Mine
-- {{{ From https://www.reddit.com/r/awesomewm/comments/gd4qxl/get_index_of_client_in_tasklist/ with some modifications
local function fixed_indexing_filter(c)
if not c then
return false
end
if not (c.skip_taskbar or c.hidden or c.type == "splash" or c.type == "dock" or c.type == "desktop") then
return true
end
return false
end
function focused_screen_current_tag_client_iterator()
local focused_screen = awful.screen.focused()
local selected_tag_filter = function (c) return c.first_tag == focused_screen.selected_tag end
local first_client_taskbar_idx = 1
return awful.client.iterate(selected_tag_filter, first_client_taskbar_idx, focused_screen)
end
-- Returns client index in the taskbar (first on the left will have index = 1)
local function client_taskbar_idx(client)
local client_taskbar_idx = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c) then
client_taskbar_idx = client_taskbar_idx + 1
if (c == client) then
return client_taskbar_idx
end
end
end
return nil
end
-- }}}
-- Returns total number of clients in the currently selected tag
local function selected_tag_number_of_clients()
local number_of_clients = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c) then
number_of_clients = number_of_clients + 1
end
end
return number_of_clients
end
-- Switches focus to the client of index in the taskbar = taskbar_idx:
-- * client with 1st taskbar item will have index 1
-- * client with 2nd taskbar item will have index 2
-- * etc
local function client_focus_by_taskbar_idx(taskbar_idx)
-- User wants to focus a non-existing client, e.g. there are only 2 opened in
-- focused screen selected tag clients and user wants to focus 3rd one, as there is
-- no 3rd one just do nothing
if taskbar_idx < 1 or taskbar_idx > selected_tag_number_of_clients() then
return
end
local focused_client = awful.client.next(0)
if focused_client ~= nil then
local focused_client_taskbar_idx = client_taskbar_idx(focused_client)
if focused_client_taskbar_idx ~= nil then
local relative_idx = taskbar_idx - focused_client_taskbar_idx
awful.client.focus.byidx(relative_idx)
end
end
end
-- }}}
-- }}}
(awful.key - байндинги уже не всобачиваю, там тоже самое).
Ай Lua как Lua. Вон WoW весь на ней построен. Эта match3 игра где надо апгрейды в виде выигрыша делать дому там, саду, русская, на мобилко, суперпопулярная, в Lua. И ниче, нормально.
Кому-то надо Haskell.
Исходная версия dissident, :
Ну вот я упростил немного и убрал лишнюю проверку (screen == nil or awful.widget.tasklist.filter.currenttags(c, screen)
- особо читаемей не стало:
-- {{{ Mine
-- {{{ From https://www.reddit.com/r/awesomewm/comments/gd4qxl/get_index_of_client_in_tasklist/ with some modifications
local function fixed_indexing_filter(c, screen)
if not c then
return false
end
if not (c.skip_taskbar or c.hidden or c.type == "splash" or c.type == "dock" or c.type == "desktop") then
return true
end
return false
end
function focused_screen_current_tag_client_iterator()
local focused_screen = awful.screen.focused()
local selected_tag_filter = function (c) return c.first_tag == focused_screen.selected_tag end
local first_client_taskbar_idx = 1
return awful.client.iterate(selected_tag_filter, first_client_taskbar_idx, focused_screen)
end
-- Returns client index in the taskbar (first on the left will have index = 1)
local function client_taskbar_idx(client)
local client_taskbar_idx = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c, client_screen) then
client_taskbar_idx = client_taskbar_idx + 1
if (c == client) then
return client_taskbar_idx
end
end
end
return nil
end
-- }}}
-- Returns total number of clients in the currently selected tag
local function selected_tag_number_of_clients()
local number_of_clients = 0
for c in focused_screen_current_tag_client_iterator() do
if fixed_indexing_filter(c) then
number_of_clients = number_of_clients + 1
end
end
return number_of_clients
end
-- Switches focus to the client of index in the taskbar = taskbar_idx:
-- * client with 1st taskbar item will have index 1
-- * client with 2nd taskbar item will have index 2
-- * etc
local function client_focus_by_taskbar_idx(taskbar_idx)
-- User wants to focus a non-existing client, e.g. there are only 2 opened in
-- focused screen selected tag clients and user wants to focus 3rd one, as there is
-- no 3rd one just do nothing
if taskbar_idx < 1 or taskbar_idx > selected_tag_number_of_clients() then
return
end
local focused_client = awful.client.next(0)
if focused_client ~= nil then
local focused_client_taskbar_idx = client_taskbar_idx(focused_client)
if focused_client_taskbar_idx ~= nil then
local relative_idx = taskbar_idx - focused_client_taskbar_idx
awful.client.focus.byidx(relative_idx)
end
end
end
-- }}}
-- }}}
(awful.key - байндинги уже не всобачиваю, там тоже самое).
Ай Lua как Lua. Вон WoW весь на ней построен. Эта match3 игра где надо апгрейды в виде выигрыша делать дому там, саду, русская, на мобилко, суперпопулярная, в Lua. И ниче, нормально.
Кому-то надо Haskell.