在Awesome WM中,根据您所使用的标签,可以使用不同的菜单吗?

时间:2013-02-11 20:02:17

标签: menu awesome-wm

在Awesome Window Manager中,您有一个主菜单,可以通过单击左上角的启动器,右键单击桌面或使用键绑定Mod + w来调用。我想做的是能够根据我所使用的标签设置不同的菜单。

例如,目前在我的Awesome配置中,我有4个标签:main,development,video和office。所以我想为每个不同的标签添加一个菜单:

main:终端,暂停,重启,关机 开发:终端,gvim,firefox, 视频:vlc,brasero 办公室:作家calc绘制留下深刻印象

这真的有可能吗?

1 个答案:

答案 0 :(得分:3)

我最终创建了一个函数来为每个标记创建不同的菜单:

更改鼠标和键盘键绑定的行以调用getTagMenu:

-- {{{ Mouse bindings: I USE PRIMARY BUTTON
root.buttons(awful.util.table.join(
awful.button({ }, 1, function () 
    menutag = getTagMenu() 
    menutag:show({keygrabber=true}) 
end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)

))

-- {{{ Key bindings: I use MENU KEY
globalkeys = awful.util.table.join(
awful.key({            }, "Menu", function () 
    menutag = getTagMenu() 
    menutag:show({keygrabber=true})
end))

现在功能:

function getTagMenu ()
tagID=awful.tag.getidx(awful.tag.selected(1))
screen[1]:add_signal("tag::history::update", function()
tagName = awful.tag.selected(1).name end)

if tagName == "main" then 
    menutag = awful.menu({ items = { 
    { "&gvim", "gvim" }, 
    { "&firefox", "firefox" }, 
    { "&software", "software-center" },
    { "&config", "zsh -c -i 'awe'" },
    { "sleep", "zsh -c -i 'gksu pm-suspend'" },
    { "logout", awesome.quit },
    { "restart", "zsh -c -i 'sudo shutdown -r now'" },
    { "shut", "zsh -c -i 'sudo shutdown -h now'"}}})
end

if tagName == "develop" then
    menutag = awful.menu({ items = { 
    { "&gvim", "gvim" }, 
    { "&sqlitestudio", "sqlitestudio" }, 
    { "&tkcon", "tkcon" } } } )
end

if tagName == "media" then
    menutag = awful.menu({ items = { 
    { "vlc", "vlc" } } } )
end

if tagName == "office" then
    menutag = awful.menu({ items = { 
    { "&write", "libreoffice --writer" },
    { "&calc", "libreoffice --calc" } } } ) 
end
return menutag
end