Categories

Meta

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.

Audacity

Gimp

Inkscape

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.

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.

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.

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?

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 exportingQT_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.

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!

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.

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!

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

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.

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.

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 :-)

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.

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.

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

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

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.

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)