我試圖自定義我的真棒窗口管理器,將標籤號碼更改爲羅馬數字(更改1爲I,2爲II ...)。爲了實現這一點,我正在修改我的/etc/xdg/awesome/rc.lua文件,特別是{{tags}}部分。如何更改AwesomeWM標籤名稱?
我發現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])
中的任何語言違規:它只是用我的自定義名稱填充標籤數組,告訴它把它們當作標籤而不是隨機字符串。
更新:我剛剛意識到在taglayouts中有六個佈局,與原始Lua文件中的標記數量相同。我想我應該有九個標籤佈局,但我不知道應該添加哪一個。另外,我不認爲這是代碼正確編譯的重要障礙,因爲錯誤行與佈局列表沒有任何關係。
UPDATE 2:增加了三個awful.layout.suit.floating
到taglayouts
。同樣的錯誤。
錯誤不是語言違規。錯誤說'表預期,得到字符串',所以問題是你傳遞一個字符串,而不是一個表。我可以看到他們在你所關注的教程中做了什麼,但所有這些文件都至少有一年的歷史。查看文檔,它應該是'mytagone = tag({name =「one」})形式'' – DavisDude
注意,不要編輯'/ etc/xdg/awesome/rc.lua',創建自己的' 〜/ .config/awesome/rc.lua' – Camusensei
那麼我應該怎麼做我的代碼? – xvlaze