2013-02-11 88 views
4

在真棒窗口管理器中,您可以通過點擊左上角的啓動器,右鍵單擊桌面或使用鍵綁定Mod + w來調用主菜單。我想要做的是能夠根據我所在的標籤獲得不同的菜單。在令人敬畏的WM中,有可能有不同的菜單,具體取決於您所在的標籤?

例如,目前在我的真棒配置中,我有4個標籤:main,development,video和office。所以我想對於每一個不同的標籤這樣的菜單:

主:終端,暫停,重啓,關機 發展:終端,GVIM,火狐, 視頻:VLC,Brasero的 辦公室:筆者計算的抽籤打動

這真的有可能嗎?

回答

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 
相關問題