GTK Global Menu

Long time no see. There has been a lot going on since my last blog post which was about Plasma 5.10 but I didn’t feel like blogging for a long time. However, there is something super exciting for the upcoming Plasma 5.13 release I want to share with you:

LibreOffice with global menu

gedit with title bar menu button

For the past couple of weeks I have been working on a way to get GTK applications talk to Plasma’s Global Menu feature. I came up with a little helper application called gmenu-dbusmenu-proxy that talks both GMenu and DBusMenu protocols. This way no adjustment on Plasma’s side is needed, it just sees a regular global menu enabled application.

Not only does it support a fully fledged menu bar, if available, but also the little application menu with settings, about, and quit:

d-feet with its application menu tucked away in the title bar

It doesn’t stop there, though, it also works in conjunction with appmenu-gtk-module (or unity-gtk-module for pre-Gnome Ubuntu) enabling global menu for a wide selection of applications, including Gimp, Inkscape, Sublime Text, Audacity, and many more. There’s also a quite extensive mapping table for menu icons, although not all applications provide action names I can work with.

The code has just been merged so you can grab it from git right now or soon from your distro’s daily package repository. It sits in plasma-workspace/gmenu-dbusmenu-proxy. Please give it a try so we can iron out any glitches applications might expose! I’m curious to hear what applications you’re using and how it’s working out for you, specifically how they behave when run with and without the following additional configuration steps:

For LibreOffice you need to install libreoffice-gtk2 or libreoffice-gtk3 and then export SAL_USE_VCLPLUGIN=gtk (or gtk3). For Gimp, Inkscape, and others you need to install appmenu-gtk-module and export GTK_MODULES=appmenu-gtk-module (substitute unity for appmenu in older versions of Ubuntu and KDE neon). GTK3 applications such as gedit and shotwell should work right away. What now needs to be figured out with distributions is how to achieve the best possible user experience out of the box.

Many thanks to Konstantin, current maintainer of appmenu-gtk-module, for helping me understand the quirks in the protocol, and Rokas Kupstys for extensively testing my implementation.

What about HUD?

Update: Since this suggestion comes up a lot: Yes, porting the “appmenu runner” has been on my wishlist for a long time. Unfortunately, it’s far from trivial to get all the applications to export their menus whilst also keeping them shown inside the window. I could pull it off for Qt apps (by submitting a patch for an enabling flag) and perhaps GTK (by not setting the “shell shows menu” option) but there could be others that would have their menus rendered inaccessible. I might give it a try but for the time being it will only work when actually enabling global menu.

77 thoughts on “GTK Global Menu”

  1. Wow, that’s awesome! I like global menu very much, now it’s even better!

    1. That’s it. I am going back to KDE if this will make it to Kubuntu 18.04. Missing of global menu is my biggest disappointment with Ubuntu ditching Unity desktop.

      1. If I’m right that could be done without serious problems when menu is global, but rendered by kwin as usual menu under header. But that needs changes of kwin and it was frozen for x11 in 5.12.

      2. GREAT!!! =D

        Please do give it a try!!!

        Having it running for Qt and GTK will be great (even if that does not work in a few other tk it will already be very useful)

        Thanks (hope you’ll blog about it when it’s ready)

  2. Awesome as you stream the menu is it also possible to search after a menu entry or a shortcut?

  3. Amazing work!

    Any chance we will see something like unity locally integrated menu?

    I’ve been hanging out for them since switching to kde.

    1. You mean showing the menu in the title bar on hover? I would love that.

      Unfortunately I’m not very good at QPainter (used to draw the window decoration) and I also don’t want to use libdbusmenu inside KWin. Currently, KWin just reads some window properties to find out if a window has a menu and then calls an external kded module that actually queries the app and shows the popup menu.

    1. Not yet. It is designed in such a way that it doesn’t really care where it gets the information about which DBus service to talk to but as of now it relies on GTK writing that as X properties on the window.

      I could imagine that we would need to support GTK’s menu Wayland protocol, if such thing exists, in KWin and forwarding that information to the proxy somehow.

  4. <3
    add a menu item search like apple does in the help menu of apps it's super handy and menus would actually be usable

  5. I just builded plasma-workspace broulik/gmenu-dbusmenu-proxy branch on a current Debian sid, but I couldn’t get the GTK global menu to work neither with any GTK2 or GTK3 app, also it didn’t work with Libreoffice with GTK3.
    I’ve installed appmenu-gtk2-module and appmenu-gtk3-module versions 0.6.92-1 and exported the variables, but the global menu didn’t appear on the panel or the menu button with the window decoration, but for example, in GIMP and the other apps it didn’t appear any menu below the window decoration neither.
    Is there a way I can debug or provide more info?

    1. I assume you added a global menu applet or menu window button and launched the gmenudbusmenuproxy binary? You can get some more debug output by exporting
      QT_LOGGING_CATEGORY='kde.dbusmenuproxy.debug=true;kde.dbusmenuproxy.info=true'

      It’s now merged to master which has some additional fixes over the feature branch I worked on. Debian Sid was one of the distributions I developed and mainly tested it on, so I’m surprised you’re having no luck with it.

      1. Sorry for the confusion, it was my bad, I was using the Debian packaging scripts to generate the packages and I missed the gmenudbusmenuproxy binary among other files. Now I added them and it’s working perfect!!!
        Thank you!

        Josep

  6. It would be nice if someone could check spacefm, I don’t have it setup for kde5 to mess around with…, vbox is a little messy right now, and need iso’s and etc.
    That’s the only app I have probs with global menu in kde4.
    It’s why I had to uninstall the gtk part of the global menu on my setup, kde4.
    It spammed a bunch of errors in the terminal, something to do with the sub menu’s, maybe because they’re customizable or some other error on spacefm’s end..
    If it doesn’t work, it would be nice to have some way to exclude the app in the newer kde5 ver of the global menu.

    1. Spacefm doesn’t seem to work but I only just tried a pretty old version (1.0.5)

  7. Finally! Finally! Finally! :D
    I don’t use much gtk or none-Qt programs but I can’t avoid them completely so there is Libre, Firefox, Thunderbird, Filezilla, Inkscape and few others. Now our experience on Plasma will be more coherent and on pair with other DEs with global menus. THANKS!

    I have a question. At the moment I use AWC (Active Window Control) for global menus because it offers a lot more control over the look and behavior of menus with window control buttons. Also, the menu itself behaves better than default Plasma one (it is opening and the following cursor after initial click while system menu isn’t or wasn’t, maybe that has changed?). I’m not sure if AWC is using system global menus or does something on its own. Do you know if AWC will support all those menus after installing and configuring the needed packages? Or is it a question to AWC developer?

    At this time AWC is the missing piece to how menu and windows title bar behaved on Unity – perfection! (getting rid of the title bar in the maximized state, showing control buttons in the panel and all the options for that – size, placement, behavior, look, aurorae theme, etc.).

    Since Wayland is still far in the woods, I don’t care if it doesn’t work on it just yet. I hope it will be sorted out eventually but for now, X session rocks and Wayland is just experiment, nothing usable in the long run.
    Again, thanks for that! Can’t wait to try it out!

    1. I think AWC has a copy of Plasma’s global menu applet code in it or at least uses libdbusmenu-qt, so it should just work.

  8. Two important things:
    – When you mention projects/packages please link to them. It will make our life easier and your blog gain on SEO.
    – Where can we give feedback or submit bugs for gmenu-dbusmenu-proxy?

    So far I installed gmenu-dbusmenu-proxy and appmenu-gtk-module, rebooted and it works great! Tested on AWC so I guess my question from the previous comment is answered, it works out of the box with Active Window Control.
    Here is the list of the programs I could check.
    Those who work out of the box: Filezilla, Gimp, Inkscape, Sound Converter, PoEdit, Bleachbit, GrSync.
    There is no menu in: Firefox, Thunderbird, Libre (how do I get that libreoffice-gtk3 packages? I don’t see them in repo nor in AUR), GParted, PlayOnLinux, Spotify, Vivaldi, Opera.

    I didn’t export anything thou. Was that a command or should I edit some config? Menus seem to work fine without it after reboot.

    I suspect that Firefox, Thunderbird, Vivaldi, and Opera are complex programs on their owns and they might never support global menus, although… they do on Unity (Firefox at least, not sure about the others) so that’s still a possibility. I know that some programs do their own thing with the menu so they will not likely to work till a developer won’t change it (like Vivaldi).

    Anyway, it’s so much better now! There are few missing spots but in overall, gtk programs menus seem to work out of the box after installation of those two packages. AWESOME! :D

    1. > Where can we give feedback or submit bugs for gmenu-dbusmenu-proxy?

      I’ll request a bugzilla category for that first thing Monday morning, it will likely be plasmashell → gmenu-dbusmenu-proxy, or even its completely own component on bugzilla.

      Firefox and Thunderbird are to be expected, they use GTK but don’t create a “real” GTK menu. Ubuntu has patches for them but they’re not upstream. I don’t know what the LibreOffice GTK VCL plugin packages are called in Arch.

      1. Thanks. Bugzilla is not the friendliest but it’s better than nothing. Github’s Issues is the nicest place to submit bugs IMO but in this case, it’s obviously not possible.

        So far no one can localize arch names for libreoffice-gtk3 on Arch. In LO 6.1 there should be support for KDE so probably global menus should start to work then but that is planned for 6-12th August this year. Till then we may stick with libreoffice-gtk3, assuming I will find it ;P. So far I see no package that would resemble it on repo or AUR. Maybe Arch community somehow omitted it? Hmm… Will investigate.

        Also, I realized that gparted won’t have global menus because it’s opening as root with its settings so grub-customizer and other apps that start with root won’t have global menus until Wayland forces them to root actions instead of the whole UI.

  9. Awesome !

    BTW do you know about the Active Window Control plasmoid ?
    https://github.com/kotelnik/plasma-applet-active-window-control

    It enables to mimic the Unity behaviour. It can display the window title, the global menu, which can optionally be hidden. It’s super powerful & configurable… It can also hide the window decoration for fullscreen window and display close / minimize etc. buttons.

    Along with your work, one could implement a default “unity-like-bar” top panel :-)

    Cheers !

    1. I’m well aware of it but since it already exists, I didn’t feel the need to implement it in Plasma. I might, to provide a better out of box experience, but I don’t have any concrete plans on that.

  10. Man this is great!!
    As a sublime user you have no idea how irritating that its global menus don’t work
    Will give this a try asap

  11. Hello,

    It’s very interesting GlobalMenu and useful.

    It doens’t work however for Firefox and Thunderbird, though others are supported (LibreOffice, Gimp, Chromium).

    I am on Archlinux.

    KR.

    Piotr.

    1. Piotr, how did you enable global menus in Libre? It doesn’t work for me and there is no libreoffice-gtk3 package on Arch side unless it’s in arch repo which I don’t have access to being on Manjaro.

      Chromium/Chrome and electron apps have global menus on Plasma since the beginning.

      Kai Uwe answered me that menus in Firefox and Thunderbird are planned so we have to be patient.

  12. I have tried it on openSUSE Tumbleweed with KDE 5.12.2.

    Libreoffice, gimp etc. work perfectly. But there is problem with Sublime Text 3. The global menu is shown, and you can click it. But all the submenu buttons are grey, and I can’t click them.

    Here is the screenshot: https://pasteboard.co/HbeR49a.png

    1. Interesting. I explicitly tried with Sublime Text recently and had no issues. I’ll try to give it a try with Suse.

      1. I just removed ~/.config/sublime-text-3 folder and tried again.

        The global menu works fine. But after I pressed ctrl-+ shortcut or changed it’s theme, the global menu broken as before.

      2. I am confused now.
        Just now I think maybe it’s the problem of sublime text 3 dev build. And I tried the stable version. The global menu works well. Then I changed to dev build and I found that it was updated to Build 3517 from Build 3516.

        And the result is the global menu works well with sublime text 3 build 3517, though I’m still confused.

        Thanks for your amazing work !

  13. Will be giving this a test, I had only just the other week tried out global menu’s and realised hey weren’t working with gtk apps so I had to abandon my desktop layout I was playing around with.

  14. A possible solution for the HUD could be to have KWIN draw the menu under the windowbar instead of the app, using the Global menu infrastructure. As that would require some work, most would simply be okay with using the existing menu button and gaining HUD functionality. I know I would be okay with that. Thanks for the great work so far this is truly advancing the Linux desktop and giving users more options.

    1. I think that is not a viable option to do. I’d rather invest the time to paint the menu on the titlebar itself like Unity did then.

  15. That’s great news! If only there was the name of the application and the desktop menu, it would be perfect

  16. How to install on KDE Neon? Unstable . I juts install appmenu-gtk but can’t find module in repo / .deb , if any can help, just answer what package i need to install , where i can get it. Will be nice. Oh and i export that module in ~/.profile & .bashrc. But without package isn’t woorking. Thx

  17. You add new feature whereas old one like appmenu/globalmenu doesn’t work correctly. I mean the issue happens after restore session and it is randomly showing appmenu in title bar
    Bug reported at September last year: Bug 384392

    1. I don’t use session restore, sorry. It’s probably the apps starting too soon before the menu service is ready.

  18. I’m tested on Archlinux , last plasma LTS release and two packages from AUR : gmenu-dbusmenu-prox, appmenu-gtk-modules-git. Working good, but random crash my PLASMASHELL when i try open sometimes gtk app. And i must restart PlasmaShell. Anyway looks good :) .

    One Question, in Ubuntu it’s possible to install external thing like JAyatana to work with Jetbrains Apps etc.

    Thx for answer.

  19. How I can enable this for my “Visual Studio Code”? I can’t do it.
    I use Manjaro KDE and my .xprofile is this:

    export SAL_USE_VCLPLUGIN=gtk3
    export GTK_MODULES=appmenu-gtk-module

      1. Thank you Kai Uwe, this comand works for me in Manjaro KDE:
        sudo pacman -S libdbusmenu-glib
        greetings!

    1. I installed libdbusmenu-glib from official arch repo and working good in VSC , but it’s old. Like another libs. I found to AUR version of UBUNTU and it’s brand new ;d

      libdbusmenu-glib-ubuntu

      oh, and if u want firefox working to, i installed firefox from aur , again ubuntu version.

  20. This feature is awesome. Trying it right now on Manjaro. Looks very promising.
    I have some issue with GTK3 applications.
    For instance Tilix, Evince native GTK3 applications post global menu but nothing happens if you click it.
    Am I missing some library/module for this to work on native GTK3 applications?
    I’ve added
    export GTK_MODULES=appmenu-gtk-module
    export SAL_USE_VCLPLUGIN=gtk
    to my /etc/profile
    Don’t use SAL_USE_VCLPLUGIN=gtk3 because LibreOffice global menu behaves strange(for instance File menu can’t be opened although it is visible)

  21. The package gmenu-dbusmenu-proxy-git from AUR is broken with the new actualization in Manjaro KDE :/

  22. A bit off topic.
    Global menus work great on my main computer. On my work laptop I never used them till now. I’m on the same system (Manjaro) on other computer and I don’t get chromium/chrome and electron global menus.
    The thing is: there is no way to find what am I missing. No documentation, no forum thread, nothing. I hope you can advise me what package am I missing (probably)?
    Thanks!

  23. This is super cool, thanks :)

    I have installed the following packages from AUR:
    – gmenu-dbusmenu-proxy-git
    – appmenu-gtk-module-git
    – plasma5-applets-active-window-control-git

    It works for me with:
    – Meld and sublime 3 ( this is not required “export GTK_MODULES=appmenu-gtk-module” )
    But it doesn’t with Java app like Phpstorm

  24. Will it include the “dummy” menu that the gtk appmenu uses when you are on the desktop “http://i.imgur.com/aMyPEiZ.png”

  25. I have tried on Arch. It’s fantastic!
    Now, I switch to KDE Neon with panel size 21. Global Menu lost alignment.

  26. I’m mostly use a Jetbranins Applications (Java i guess) . Will be nice to support that type of apps.

    One Idea for author, maybe when user is on “Desktop” and Plasma Use by Default Icons for desktop… will be nice to use appmenu from Dolphin? (or any default app set in settings) . that last it’s more inteligence. But… this solution give some “time” for us. I think it good solution .

  27. Would it be possible to have a keyboard shortcut to open the hamburger global menu?

  28. Hi there!

    Installin in arch package gmenu-dbusmenu-proxy-git i get in the final this :
    erro: file owned by ‘gmenu-dbusmenu-proxy-git’ and ‘plasma-workspace’: ‘etc/xdg/autostart/gmenudbusmenuproxy.desktop’

    erro: file owned by ‘gmenu-dbusmenu-proxy-git’ and ‘plasma-workspace’: ‘usr/bin/gmenudbusmenuproxy’

    Is it normal?

    Best Regards!

  29. What KDE has been accomplishing on every front is nothing short of amazing! I believe the KDE story to be among the greatest success stories in the histories of GNU/Linux & FOSS.
    It wasn’t so long ago that KDE’s very future seemed cloudy and very much in doubt. Then the turnaround happened. An incredible one at that and the fire has only grown hotter.
    KDE is on serious point and has only kicked it up a notch. Plasma is just spectacular. Krista, digikam and everything else in KDE’s application library are fine examples of FOSS done right.
    Linux really has made computing fun again KDE made it awesome! Thanks for your efforts it is very much appreciated.

  30. I came here thanks to a Google search. The global menu for GTK works fine but does not show the icons unfortunately.
    As for HUD, I use it with a krunner plugin, which I think is the most elegant solution.

Leave a Reply to Ann Cancel reply

Your email address will not be published. Required fields are marked *