我正在尝试自定义我的Awesome Window Manager将标签号码更改为罗马数字(I为1,II为2)。为了实现这一点,我正在修改我的/etc/xdg/awesome/rc.lua文件,特别是{{tags}}部分。
我找到this blog post,他设法随意编辑标签名称,看看左上角:
我还阅读了主题附带的rc.lua file,并意识到我想要做的技术是与一些表结合使用的for循环。
这是文件中感兴趣的代码段:
-- {{{ 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
-- }}}
...这是我的rc.lua文件:
-- {{{ 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
--- }}}
正如你所看到的,它们是相同的,不同之处在于我有九个标签而不是六个(我根据它更改了代码)。当我尝试使用Xephyr调试设置时,控制台中出现错误,我只能看到我的壁纸:
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
我无法看到错误的位置,因为我无法在错误行tags[s][tagnumber] = tag(tagnames[tagnumber])
中检测到任何语言违规:它只是用我的自定义名称填充tags数组,告诉它将它们视为标签而不是随机字符串。
更新:我刚刚意识到taglayouts中有六个布局,与原始Lua文件中的标签数量相同。我想我应该有九个标签布局,但我不知道应该添加哪一个。此外,我不认为这是正确编译代码的关键障碍,因为错误行与布局列表没有任何关系。
更新2:又向awful.layout.suit.floating
添加了三个taglayouts
。同样的错误。
答案 0 :(得分:2)
在另一个答案之后,我将{Tags}部分替换为:
-- {{{ 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
-- }}}
这将创建i个标签,其名称在tagnum
表中定义。这仅在您想要创建相同的标签时才有用,但它总是比必须键入i定义更清晰。
更好,清洁方式:
初始解决方案很有用,但它有一个问题:启动AwesomeWM时,您不会出现在已定义的标签中,而是出现在所有这些标签中。也就是说,如果你打开一个终端,你将在你拥有的每个标签中打开它,除非你之前选择了一个使用Mod4 + TagNum(在默认情况下)。
试图解决这个问题,我将默认配置文件与修改后的配置文件进行了比较,我意识到它在默认配置文件中运行良好。所以我开始修改代码以找到解决方案。总而言之,我发现只需对默认代码进行最小修改,您就可以随意自定义标记名称。我就这样做了:
-- {{{ 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。我保留旧的解决方案,以防有人希望将代码用于其他目的。
答案 1 :(得分:1)
尚未正式回答,但昨天我写了更多关于此的文档:
https://github.com/awesomeWM/awesome/pull/1279/files#diff-df495cc7fcbd48cd2698645bca070ff9R39
适用于Awesome 4.0,但在这种情况下没有太大变化,因此该示例几乎有效(gap
属性在3.4 / 3.5中不可用。)
另外,如果你想设置复杂的标签,我会建议我的Tyrannical模块(Awesome 3.5+)或Shifty(Awesome 3.2-3.4)。它旨在使这更容易。