In Awesome WM is it possible to have different menus depending in which tag you are in?

StackOverflow https://stackoverflow.com/questions/14819866

  •  09-03-2022
  •  | 
  •  

Domanda

In Awesome Window Manager you have a main menu which can be invoked by clicking on the launcher in the top-left, right-clicking on the desktop, or using the keybinding Mod+w. What I would like to do is to be able to have different menus depending on which tag I am on.

For example, currently in my Awesome configuration I have 4 tags: main, development, video and office. So I would like a menu for each different tag like this:

main: terminal, suspend, restart, shutdown development: terminal, gvim, firefox, video: vlc, brasero office: writer calc draw impress

Is this really possible?

È stato utile?

Soluzione

I finally created a function to create a different menu for each tag:

Change line for mouse and keyboard key-bindings to call 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))

And now the function:

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top