How to change AwesomeWM tag names?

4k views Asked by At

I am trying to customize my Awesome Window Manager to change the tag numbers into Roman numbers (changing 1 for I, 2 for II...). In order to achieve this, I am modifying my /etc/xdg/awesome/rc.lua file, specially the {{tags}} section.

I have found this blog post, in which he manages to edit the tag names at will, have a look at the top left corner:

detail of the tag modification

I also read the rc.lua file attached to the theme, and realized the technique used for what I want to do is a for loop in combination with some tables.

This is the code snippet of interest in the file:

-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
tagnames = { "irc",  "mpd", "net", "usr", "png", "msg", }
taglayouts = {
        awful.layout.suit.tile.top,
        awful.layout.suit.tile.bottom,
        awful.layout.suit.floating,
        awful.layout.suit.fair,
        awful.layout.suit.floating,
        awful.layout.suit.floating }

for s = 1, screen.count() do
    -- Each screen has its own tag table.
    tags[s] = {}
    for tagnumber = 1, 6 do
        -- Add tags and name them.
        tags[s][tagnumber] = tag(tagnames[tagnumber])
        -- Add tags to screen one by one, giving them their layouts at the same time.
        tags[s][tagnumber].screen = s
        awful.layout.set(taglayouts[tagnumber], tags[s][tagnumber])
    end
    -- I'm sure you want to see at least one tag.
    tags[s][1].selected = true
end
-- }}}

...and this is my rc.lua file:

-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
tagnames = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", }
taglayouts = {
        awful.layout.suit.tile.top,
        awful.layout.suit.tile.bottom,
        awful.layout.suit.floating,
        awful.layout.suit.fair,
        awful.layout.suit.floating,
        awful.layout.suit.floating }

 for s = 1, screen.count() do
    -- Each screen has its own tag table.
    -- tags[s] = awful.tag({  "1", "2", "3", "4", "5", "6", "7", "8",$

      tags[s] = {}

      for tagnumber = 1, 9 do
                tags[s][tagnumber] = tag(tagnames[tagnumber])
                tags[s][tagnumber].screen = s
                awful.layout.set(taglayouts[tagnumber], tags[s][tagnumber])
      end

      tags[s][1].selected = true
 end
--- }}}

As you can see, they are pretty the same, with the difference that I have nine tags instead of six (I changed the code according to it). When I try to debug the setup using Xephyr, an error appears in the console and I am only able to see my wallpaper:

    error while running function
stack traceback:
    [C]: in global 'tag'
    /etc/xdg/awesome/rc.lua:100: in main chunk
error: /etc/xdg/awesome/rc.lua:100: bad argument #2 to 'tag' (table expected, got string)
error while running function
stack traceback:
    [C]: in global 'tag'
    /etc/xdg/awesome/rc.lua:100: in main chunk
error: /etc/xdg/awesome/rc.lua:100: bad argument #2 to 'tag' (table expected, got string)
E: awesome: main:605: couldn't find any rc file

I can't see where the error is, as I am not able to detect any language violation in the error line tags[s][tagnumber] = tag(tagnames[tagnumber]): it's just filling the tags array with my custom names, telling it to treat them as a tag and not as a random string.

UPDATE: I have just realized that there are six layouts in taglayouts, the same number as tags in the original Lua file. I think I should have nine tag layouts, but I don't know which one should I add. Also, I don't see this as a critical impediment for the code to compile properly, as the error line does not have anything to do with the layout list.

UPDATE 2: Added three more awful.layout.suit.floating to taglayouts. Same error.

2

There are 2 answers

0
xvlaze On BEST ANSWER

Following another answer, I replaced my {Tags} section with:

-- {{{ Tags
-- Define a tag table which hold all screen tags.

tagnum = { "I", "II", "III", "IV", "V", "VI", "VII",
"VIII", "IX" }

for i = 1, 9 do
awful.tag.add((tagnum[i]), {
        layout = awful.layout.suit.tile,
        master_fill_policy = "master_width_factor",
        gap_single_client = true,
        gap = 15,
        screen = s,
})

end

-- }}}

This creates i number of tags, their name defined in the tagnum table. This is only useful if you want to create identical tags, but it will always be much cleaner than having to type i definitions.

A MUCH BETTER, CLEANER WAY:

The initial solution was useful, but it had a problem: when starting AwesomeWM, you won't appear in a defined tag, but in all of them at the same time. That is, if you open a terminal, you will open it in every tag you have unless you previously selected one with Mod4+TagNum (following default conf.).

Trying to solve this problem, I compared the default configuration file with the modded one, and I realized it all worked well in the default one. So I started modifying the code in order to find a solution. In all, I have discovered that with a minimal modification of the default code you are able to customize your tag names at will. This is how I did it:

-- {{{ Tags
tags = {}
-- Generates tags with custom names
for s = 1, screen.count() do
        tags[s] = awful.tag({ "I", "II", "III", "IV", "V", "VI", "VII", "IX" }),
end
-- }}}

P.S. I keep the old solution in case someone would wish to use the code for another purpose.

0
Emmanuel Lepage Vallee On

Not an official answer yet, but yesterday I wrote more doc about this:

https://github.com/awesomeWM/awesome/pull/1279/files#diff-df495cc7fcbd48cd2698645bca070ff9R39

It is for Awesome 4.0, but in this case not much changed, so the example is almost valid (the gap property is not available in 3.4/3.5).

Also, if you wish to setup complex tags, I would suggest my Tyrannical module (Awesome 3.5+) or Shifty (Awesome 3.2-3.4). It is designed to make this much easier.