add option to choose between client class or name in the taskbar

This commit is contained in:
Rene Kievits
2022-09-25 02:10:21 +02:00
parent 747b8a9787
commit 210682e955
2 changed files with 12 additions and 15 deletions

View File

@@ -198,6 +198,13 @@ User_config = {
"backlight" "backlight"
}, },
--[[
If true the taskbar will shot the client name instead of the class name.
Default: false
]] --
taskbar_use_name = true,
--[[ --[[
This is the default terminal, Alacritty is the default. This is the default terminal, Alacritty is the default.
]] -- ]] --

View File

@@ -93,28 +93,18 @@ local list_update = function(widget, buttons, label, _, objects)
task_widget:buttons(create_buttons(buttons, object)) task_widget:buttons(create_buttons(buttons, object))
local text, _ = label(object, task_widget.container.layout_it.title) local client_string = User_config.taskbar_use_name and object.name or object.class
if object == capi.client.focus then if object == capi.client.focus then
if text == nil or text == '' then if client_string == nil or client_string == '' then
task_widget.container.layout_it.title:set_margins(0) task_widget.container.layout_it.title:set_margins(0)
else else
local text_full = text:match('>(.-)<') task_tool_tip:set_text(client_string)
if text_full then
if object.class == nil then
text = object.name
else
text = object.class:sub(1, 20)
end
task_tool_tip:set_text(text_full)
task_tool_tip:add_to_object(task_widget) task_tool_tip:add_to_object(task_widget)
else task_widget.container.layout_it.title:set_text(client_string:sub(1, 20))
task_tool_tip:remove_from_object(task_widget)
end
end end
task_widget:set_bg(Theme_config.tasklist.bg_focus) task_widget:set_bg(Theme_config.tasklist.bg_focus)
task_widget:set_fg(Theme_config.tasklist.fg_focus) task_widget:set_fg(Theme_config.tasklist.fg_focus)
task_widget.container.layout_it.title:set_text(text)
else else
task_widget:set_bg(Theme_config.tasklist.bg) task_widget:set_bg(Theme_config.tasklist.bg)
task_widget.container.layout_it.title:set_text('') task_widget.container.layout_it.title:set_text('')