Access to all selected tasks in my taskslist. Awesome WM
I defined the following tasklist:
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = bindings.tasklist_mouse,
widget_template = {
{
layout = wibox.layout.fixed.vertical,
{
{
left = 100,
right = 100,
bottom = 5,
widget = wibox.container.margin,
},
id = "overline",
bg = beautiful.underline_color,
shape = gears.shape.rectangle,
widget = wibox.container.background
},
{
layout = wibox.layout.fixed.horizontal,
{
{
id = "icon_role",
widget = wibox.widget.imagebox,
resize = true,
forced_width = 20
},
margins = 5,
widget = wibox.container.margin
},
{
id = "text_role",
widget = wibox.widget.textbox
},
},
},
id = "background_role",
widget = wibox.container.background,
shape = gears.shape.rectangle,
create_callback = function(self, c, index, objects)
for i, task in ipairs(objects) do
print(task.name)
end
end
},
}
I would like to iterate through all the selected tasks, in the functions "create_callback" and "update_callback", and if the task is selected, change the color to "overline" item. I tried using "awful.tasklist.filter.currenttags" but didn't work.
To iterate over all selected tags for a screen, you can use
s.selected_tags.Example from https://github.com/awesomeWM/awesome/blob/485661b706752212dac35e91bb24a0e16a677b70/tests/test-awful-client.lua#L231 :
(This code comes from a test and thus doesn't do anything too useful. It still iterates over all tags.)
I think you do not actually want to iterate over all tags for this. The caller of
update_callbackalready does the iteration for you. In this function, you just need to do the actual update that you want to do.Untested example (I am guessing
overlinehas a.bgproperty based on how you create it, I half-guess thatt.selectedis a thing (at leastgit grep .selectedfinds something) and the colors are only a proof of concept and can obviously be replaced):