Awesome tasklist

On the Wiki edits , unfortunately, very little information on configuring Awesome window manager. Therefore, I decided to contribute my five cents to the popularization of this wonderful WM. This article parses the taskbar.

Taskbar - Displays by default clients with active tag / s.

Before you start, copy the libraries to your home directory if you haven’t done so yet.

mkdir -p ~/.config/awesome/themes
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/rc.lua
cp -R /usr/share/awesome/lib/* ~/.config/awesome/
cp -R /usr/share/awesome/themes/* ~/.config/awesome/themes/


In general, the awful / widget / tasklist.lua file is responsible for processing the taskbar .

So if you want to get acquainted with all the features of the taskbar, study this file. Also, for the operation of this file, other lua libraries will be required (functions called from there, etc.), they are registered at the beginning of the file, these are the same require. Keep in mind that the code for 3.4 and 3.5 in the tasklist library, as well as the names of functions in them, are quite significantly different.

To-do list management


The following keys are available for managing open clients:

Mod4 + Shift + r - Redraw the active window.
Mod4 + m - Expand in full screen.
Mod4 + n - Collapse.
Mod4 + Control + n - Restore.
Mod4 + f - Full screen mode.
Mod4 + Shift + c - Kill the selected client.
Mod4 + t - Attach on top of all.

By the way, if these keys do not fix you, you can redefine them at any time, for this, find the awful.key function in rc.lua that is responsible for the keys you need and change them.

Parsing rc.lua


When parsing rc.lua, you can find the following code associated with the taskbar:

mytasklist = {}							--создаем таблицу панели задач
mytasklist.buttons = awful.util.table.join(			--прикрепляем клавиши мыши к панели задач
              awful.button({ }, 1, function (c)			--нажатие левой кнопки
                 if c == client.focus then		        --свернуть/развернуть приложение
                   c.minimized = true
                 else
                   -- Without this, the following
                   -- :isvisible() makes no sense
                   c.minimized = false
                   if not c:isvisible() then
                     awful.tag.viewonly(c:tags()[1])
                   end
                   -- This will also un-minimize
                   -- the client, if needed
                   client.focus = c
                   c:raise()
                 end
               end),
               awful.button({ }, 3, function ()			--нажатие правой клавиши
                  if instance then			        --отображает список всех клиентов/приложений
                    instance:hide()
                    instance = nil
                  else
                    instance = awful.menu.clients({
                    theme = { width = 250 }
                  })
                  end
                end),
                awful.button({ }, 4, function ()	--колесо прокрутки
                    awful.client.focus.byidx(1)	        --перейти на следующий клиент
                    if client.focus then client.focus:raise() end
                 end),
                 awful.button({ }, 5, function ()	--колесо прокрутки
                   awful.client.focus.byidx(-1)	        --перейти на предыдущий клиент
                   if client.focus then client.focus:raise() end
                 end))
....
    -- Create a tasklist widget  - создание виджета tasklist
    mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
.... 
    layout:set_middle(mytasklist[s])		--Располагаем список задач в центре панели


If you do not need scrolling on the taskbar, then comment out / delete the code responsible for it:

--awful.button({ }, 4, function ()						--колесо прокрутки
--                      awful.client.focus.byidx(1)				--перейти на следующий клиент
--                      if client.focus then client.focus:raise() end
--                     end),
--awful.button({ }, 5, function ()						--колесо прокрутки
--                      awful.client.focus.byidx(-1)			--перейти на предыдущий клиент
--                      if client.focus then client.focus:raise() end
--                     end))
--И добавьте завершающую скобку после закомментированного кода, иначе выдаст ошибку
)


Options for the right mouse button


Close application


So that when you right-click, we can close the application (as in OpenBox or Tint2), and not open the menu list, redo the code (or comment out it if you do not plan to use the right key for the taskbar).

awful.button({ }, 3, function ()
                      if instance then
                        instance:hide()
                        instance = nil
                      else
                        instance = awful.menu.clients({
                        theme = { width = 250 }
                        })
                      end
                     end),


To the next:

awful.button({ }, 3, function (c)
    c:kill()
end ),


Alternative menu




If you are not satisfied with the standard context menu in the taskbar, then you can replace it with the one you need, the following is just one of the possible options.

First, replace the standard awful.button call with the following:

awful.button({ }, 3, function (c)
          if instance then
              instance:hide()
              instance = nil
           else
              instance = context_menu(c)
           end
         end ),


Then, somewhere at the beginning of the rc.lua file, add the context_menu function:

function context_menu(c)
    if c.minimized then                               --меняем текст элемента меню в зависимости от состояния
         cli_min = "Развернуть"
    else
         cli_min = "Свернуть"
    end
    if c.ontop then
         cli_top = "★ Поверх всех"
     else
         cli_top = "  Поверх всех"
    end
    if awful.client.floating.get(c) then
         cli_float = "★ Floating"
     else
         cli_float = "  Floating"
     end
     --создаем список тегов(в виде подменю), для перемещения клиента на другой тег
     tag_menu = { }
     for i,t in pairs(tags.names) do
          if not tags[c.screen][i].selected then			--удаляем из списка выбранный тег/теги
              table.insert(tag_menu, { tostring(t), function() awful.client.movetotag(tags[c.screen][i]) end } )
          end
     end
     taskmenu = awful.menu({ items = { { "Переместить на", tag_menu },
                                       { cli_min, function() c.minimized = not c.minimized end },
                                       { "Fullscreen", function() c.fullscreen = not c.fullscreen end, beautiful.layout_fullscreen },
                                       { cli_float,  function() awful.client.floating.toggle(c) end },
                                       { cli_top, function() c.ontop = not c.ontop end },
                                       { "Закрыть", function() c:kill() end },
                                     width = 150
                                     } )
     taskmenu:show()
     return taskmenu
end


Display only icons or text


If you are not comfortable with displaying text and icons at the same time (for example, you are a big fan of Unity or Win7), then you can configure Awesome to display only icons or only text in applications. There is one drawback, if there is no icon assigned to the application, then there will be nothing to display accordingly (I had this situation with the xterm terminal, if you have a similar situation, then assign a default icon for applications that do not have their own icons (described below).

Open ~ / .config / awesome / awful / widget / tasklist.lua and in the function widget_tasklist_label_common () (for 3.4) or tasklist_label (for 3.5)
replace return text, bg .... with the following code:
return not theme.tasklist_only_icon and text or '', bg, status_image, not tasklist_disable_icon and c.icon or nil

Then, create a variable in your theme.lua with the following content:
--для отображения только иконок
theme.tasklist_only_icon = true
--для отображения только текста
tasklist_disable_icon = true


Note: Do not define both of these variables at the same time, otherwise you will not see your tasks at all.



There is another way to remove text in Awesome 3.4 (unfortunately in 3.5 the code of the called function was changed and therefore this method does not work in it), but here we will perform all manipulations only with the rc.lua file. Find the following code:

mytasklist[s] = awful.widget.tasklist(function(c)
                        return awful.widget.tasklist.label.currenttags(c, s)
                end, mytasklist.buttons)


And replace it with:

 mytasklist [s] = awful.widget.tasklist (function (c)
                              local task = {awful.widget.tasklist.label.currenttags (c, s)}
                              return '', task [2], task [3], task [4]
                          end, mytasklist.buttons)


In principle, this code is similar to the first, only here we perform an additional action.

In a similar way, you can delete the icons in Awesome 3.4. Open your rc.lua, find:

mytasklist[s] = awful.widget.tasklist(function(c)
                      return awful.widget.tasklist.label.currenttags(c, s)
                end, mytasklist.buttons)


And replace it with:

 mytasklist[s] = awful.widget.tasklist(function(c)
                              local task = { awful.widget.tasklist.label.currenttags(c, s) }
                              return task[1], task[2], task[3], nil
                          end, mytasklist.buttons)


Default icon


For some applications, default icons are not installed (usually terminals), and if, for example, you use only the icons in the taskbar, or use the display of applications in tags, then you simply will not see applications without icons. To solve this problem, edit the tasklist_update function in the ~ / .config / awesome / awful / widget / tasklist.lua file.

в функции tasklist_update перед строкой table.insert вставьте следующий код:
if not c.icon then
    c.icon = capi.image("path/to/icon/default_icon.png")
end


Customize Appearance


To configure the taskbar, in theme.lua you can define the following variables:

Awesome 3.5
theme.tasklist_fg_normal - the color of the text of the taskbar, if the value is not defined, then the value theme.fg_normal
theme.tasklist_bg_normal - the background color of the taskbar if the value is not defined , then the theme.bg_normal
theme.tasklist_fg_focus value is used - the text color of the active application, if the value is not defined, the theme.fg_focus
theme.tasklist_bg_focus value is used - the background color of the active application, if the value is not defined, the theme.bg_focus theme.tasklist_fg_urgent value is
used- the color of the text of the "urgent" application, if not defined, then the value from theme.fg_urgent
theme.tasklist_bg_urgent will be used - the background color of the "urgent" application, if not defined, then the value of theme.bg_urgent
theme.tasklist_fg_minimize will be used - the color of the text of the minimized application if not defined, then the value from theme.fg_minimize
theme.tasklist_bg_minimize will be used - the background color of the minimized application, if not defined, then the value from theme.bg_minimize
theme.bg_image_normal will be used - allows you to set the image for the currently inactive
theme.bg_image_ clients focus - allows you to set the background image for the active client
theme.bg_image_urgent - allows you to set the background image for the "urgent" client
theme.bg_image_minimize - allows you to set the background image for the minimized client
theme.tasklist_disable_icon - allows you to turn off the display of icons if the value is true

theme.tasklist_font - font for the taskbar, if not defined, then the font from theme.font will

be used. For the following elements, you can use only symbols ( not icons )
theme.tasklist_sticky - allows you to set the text for the “sticky” client, if the value is not set, then ""
theme.tasklist_ontop is used- allows you to set the text / symbol for the application “on top of all”, if the value is not set, then use '
theme ' theme.tasklist_floating - the text for the application in “floating” mode, if the value is not set, then use ''
theme.tasklist_maximized_horizontal - text for horizontally expanded application, if installed, then use ⬌
theme.tasklist_maximized_vertical - text for vertically deployed application, if installed, then use ⬍

Awesome 3.4


There are much fewer customization options here, this is another reason to upgrade to a newer version.
theme.tasklist_fg_focus - the text color of the active application, if the value is not defined, use the theme.fg_focus
theme.tasklist_bg_focus - the background color of the active application, if the value is not defined, the theme.bg_focus
theme.tasklist_fg_urgent is used - the text color of the “urgent” application, if not defined, then the value from theme.fg_urgent
theme.tasklist_bg_urgent will be used - the background color of the "urgent" application; if not defined, then theme.bg_urgent theme.tasklist_fg_minimize will be used
- the text color of the minimized application, if not defined, then the value from theme.fg_minimize
theme.tasklist_bg_minimize will be used - the background color of the minimized application, if not defined, the value from theme.bg_minimize
theme.tasklist_floating_icon will be used - the icon for the application in the "floating"
theme.tasklist_font mode - the font for the taskbar; if not defined, the font from theme.font will be used

Panel Height


If you are not satisfied with the standard height of the taskbar, you can change it, for this, find the code in rc.lua responsible for creating the mywibox container and change it as follows:

mywibox[s] = awful.wibox({ position = "top", height = 24, screen = s })


Here you can change its location, top - above, bottom - below. height is the height of the panel. Or you can even create a second panel for yourself by moving the taskbar from top to bottom (for example 3.4):

bottomwibox = {}
bottomwibox[s] =  awful.wibox({ position = "bottom", height = 27, screen = s })
bottomwibox[s].widget = {
              {
                  mylauncher,
                  layout = awful.widget.layout.horizontal.leftright
              },
          mytasklist[s],
          layout = awful.widget.layout.horizontal.rightleft
      }


Open Application Order


By default, a new application is displayed to the left of previously opened ones. But if you’re used to something else, for example, in Gnome or KDE, you can configure your newly opened applications to open on the right, i.e. the task list was sorted by launch, where the first in the list would be the first open application, and the last, respectively, last.

To do this, open the file ~ / .config / awesome / awful / widget / tasklist.lua . All manipulations with these files are best done when they are in the home directory, so that if you ruin something, you can easily restore them.

So, find in this file the function function tasklist_update in it there is the following line:

Awesome 3.4
table.insert(shownclients,c)

Replace it with:
table.insert(shownclients, 1, c)

Awesome 3.5
table.insert(clients, c)

Replace it with:
table.insert(clients, 1, c)

Restart awesome.

Width of applications in the task list


If you are not happy with the fact that one running application can occupy all available space on the taskbar, then this behavior can be slightly changed. To do this, you need to edit the file ~ / .config / awesome / awful / widget / tasklist.lua

Awesome 3.4
Find the new function, change it in it:

layout = layout.horizontal.flex


For the option of arranging widgets that suits you. Their complete list is in the awful / widget / layout horizontal.lua and vertical.lua files:

layout = layout.horizontal.leftright


Awesome 3.5
Find the tasklist.new function then replace:

local w = base_widget or flex.horizontal()


For example, with the following code:

local w = base_widget or fixed.horizontal()


And at the top of the file add:

local fixed = require("wibox.layout.fixed")


If the proposed version does not suit you, you can experiment with layouts, they are in the ~ / .config / awesome / wibox / layout directory

True, the width of each client will depend on the name, in principle, this can also be fixed if you need a fixed clients width, for this you need to change the widget_tasklist_label_common (3.4) or tasklist_label (in 3.5) function in the tasklist.lua file:

At the top of the file, place:

local string = string


Then, before the line `` if capi.client.focus == c then '' place the following code:

if #name >20 then
    name = string.sub(name,1,20)
end


Here we restrict the name to 20 characters, if you need a different value, change it.

There is one more nuance, when changing the used layout (layout), applications now stop scaling, and as a result of them now there are 5 pieces on the panel, of course this can be changed, but a lot of changes will be needed and they are already beyond the scope of this article.

List of clients


By default, in the rc.lua file, the following code is used to process the list of clients and display them in the context menu:

Awesome 3.5
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)


Awesome 3.4
mytasklist[s] = awful.widget.tasklist(function(c) 
                               return awful.widget.tasklist.label.currenttags(c,s)
                          end, mytasklist.button)


Those. Having studied this code, you can understand that on the taskbar, clients for the current tag will be displayed. If this state of affairs does not make you obsolete, for example, you can display all clients from all tags, for this you need to replace the corresponding function with one of the following:

Awesome 3.4
awful.widget.tasklist.label.allscreen - to display clients from all
awful screens . widget.tasklist.label.alltags - to display clients from all tags of the current screen awful.widget.tasklist.label.currenttags - to display clients from all tags of the current screen
awful.widget.tasklist.label.focused - to display
only clients in focus

Awesome 3.5
awful.widget.tasklist.filter.allscreen - to display clients from all screens
awful.widget.tasklist.filter.alltags - to display clients from all tags of the current screen
awful.widget.tasklist.filter.currenttags - to display clients from the current tag
awful.widget.tasklist.filter.minimizedcurrenttags - to display minimized clients on the current tag
awful.widget.tasklist.filter.focused - to reflect only clients in focus

In addition, there are a number of applications that will not be displayed in the client list, this function is written in the following code:
Awesome 3.5 - tasklist.lua - function tasklist_update:

if not (c.skip_taskbar or c.hidden
            or c.type == "splash" or c.type == "dock" or c.type == "desktop")
            and filter(c, s) then
            table.insert(clients, c)
        end


A similar code is used in 3.4, but without the string `` and filter (c, s) ''. Those. here we skip part of the clients, if you still need some of them, delete the code responsible for them.

Signals


Signals is the message system that the Awesome kernel sends out to manage widgets, clients, tags, etc. You can familiarize yourself with the signal system in more detail here .

So, the following signals are supported:

    tag.attached_connect_signal(screen, "property::selected", u) 
    tag.attached_connect_signal(screen, "property::activated", u)
    capi.client.connect_signal("property::urgent", u)
    capi.client.connect_signal("property::sticky", u)
    capi.client.connect_signal("property::ontop", u)
    capi.client.connect_signal("property::floating", u)
    capi.client.connect_signal("property::maximized_horizontal", u)	
    capi.client.connect_signal("property::maximized_vertical", u)
    capi.client.connect_signal("property::minimized", u)
    capi.client.connect_signal("property::name", u)
    capi.client.connect_signal("property::icon_name", u)
    capi.client.connect_signal("property::icon", u)
    capi.client.connect_signal("property::skip_taskbar", u)
    capi.client.connect_signal("property::screen", u)
    capi.client.connect_signal("property::hidden", u)
    capi.client.connect_signal("tagged", u)
    capi.client.connect_signal("untagged", u)
    capi.client.connect_signal("unmanage", u)
    capi.client.connect_signal("list", u)
    capi.client.connect_signal("focus", u)
    capi.client.connect_signal("unfocus", u)


The names of the signals speak for themselves, the only thing is that the first 2 capture events from the tags in order to display the current list of clients on it when changing the tag. After this event is received, the u function will be called:

u = function () tasklist_update(screen, w, buttons, filter, data, style, uf) end


Those. taskbar will be updated. So if you are going to change some property for the client somewhere, you need not worry, it will be caught and processed correctly. If the signal you need is not here, then you can always create your own.

References


Xephyr - allows you to open Awesome in the new X-server. Those. if you periodically experiment with source codes, then use Xephyr for experiments.
Radical is a powerful and extensible menu system.
Hints - window hints for focusing on the window.

Also popular now: