Ubuntu / Linux news and application reviews.

A while back I wrote about TopMenu, a panel plugin that provides global menu (AppMenu) support for MATE, then also included support for Xfce and LXDE.

The problem with TopMenu is that it only partially supports GTK3, it doesn't support LibreOffice, and with Ubuntu 16.04, it doesn't support Qt (4 or 5) applications.

Here's where Vala Panel AppMenu comes in.

Vala Panel AppMenu is a global menu panel applet for Xfce, MATE and Vala panels, which uses unity-gtk-module as its backend, and it works with all the applications supported by Unity's AppMenu.

Global Menu Linux Mint Vala Panel AppMenu

As a result, Vala Panel AppMenu provides global menu support for GTK2, GTK3, Qt4 and Qt5 applications, as well as applications like Firefox, Thunderbird, Google Chrome / Chromium, and LibreOffice.

For MATE, Vala Panel AppMenu requires MATE Panel built with GTK3 (so for Ubuntu, it requires Ubuntu MATE 16.10 and newer). Its README also mentions that to build Vala Panel AppMenu, you'll need GTK 3.12 or newer, GLib 2.40 or newer, valac 0.24 or newer and libbamf 0.5.0 or newer.

Here's Vala Panel AppMenu in action with Chromium, Firefox, Gedit (GTK3), LibreOffice, VLC (Qt5), and Thunar (GTK2): 

Global Menu Xubuntu Xfce Vala Panel AppMenu

Global Menu Xubuntu Xfce Vala Panel AppMenu

Global Menu Xubuntu Xfce Vala Panel AppMenu

Global Menu Xubuntu Xfce Vala Panel AppMenu

Global Menu Xubuntu Xfce Vala Panel AppMenu

Global Menu Xubuntu Xfce Vala Panel AppMenu

Here's an Ubuntu MATE 16.10 screenshot as well:

Global Menu Ubuntu MATE Vala Panel AppMenu

Vala Panel AppMenu is not perfect though, and I did encounter a few issues in my test:
  • when no window is focused / the desktop is empty, a menu containing "Desktop" and "Files" is displayed by the Vala AppMenu applet. These menu items don't work, at least in Ubuntu, and using them can cause the Xfce / MATE panel to crash;
  • Qt5 supports the AppMenu feature by default, without using any additional packages (I'm not sure which version introduced this feature), however, there's a bug with this and Vala AppMenu which causes the global menu for Qt5 applications to be displayed for a few seconds after the app is closed. This doesn't occur if the appmenu-qt5 package is installed though;
  • MATE only: GTK2 applications have the menu displayed on both the panel and in the application window. If someone can find a way to solve this, please let us know in the comments!;
  • MATE only: there's no easy way of moving the applet to the desired position, but it can be done using Dconf Editor;
  • there's no way of changing the global menu font color, and that can be problematic with some themes. For example, the menu font is dark on a dark panel background using the default Xubuntu 16.04 theme (Greybird). This doesn't occur with Numix GTK theme (which is installed by default in Xubuntu) or Greybird in Xubuntu 16.10.

You may also want to check out the Vala Panel AppMenu issues page on GitHub.


Install and set up Vala AppMenu in Ubuntu (MATE/Xubuntu) or Linux Mint (Xfce) via PPA


If you don't use Ubuntu or Linux Mint, you can grab the Vala Panel AppMenu source from GitHub.

Arch Linux users can install Vala Panel AppMenu via AUR.

For Ubuntu or Linux Mint, see the instructions below.


1. Install Vala AppMenu.

Vala AppMenu is available in the WebUpd8 MATE and Xfce PPA.

For Ubuntu MATE, the plugin is only available for Ubuntu 16.10, because it requires MATE Panel built with GTK3, and that is only the case for Ubuntu 16.10 and newer.

For Xfce, the Vala AppMenu plugin is available for Xubuntu 16.10 and 16.04, as well as Linux Mint Xfce 18.x.

To add the WebUpd8 MATE and Xfce PPA and update the software sources, use the following commands:
sudo add-apt-repository ppa:webupd8team/mate
sudo apt update

Then, install the Vala AppMenu plugin / applet:

- for Xfce (Xubuntu 16.10, 16.04 / Linux Mint Xfce 18.x):
sudo apt install xfce4-vala-appmenu-plugin unity-gtk3-module unity-gtk2-module appmenu-qt appmenu-qt5

- for MATE (Ubuntu MATE 16.10):
sudo apt install mate-applet-vala-appmenu unity-gtk3-module unity-gtk2-module appmenu-qt appmenu-qt5

2. Disable the menu from being displayed in application windows (so it's only displayed on the panel; without this, you'll get double menus, in both the panel and application windows).

2.A. for Xfce, simply run the command below:
xfconf-query -c xsettings -p /Gtk/ShellShowsMenubar -n -t bool -s true
xfconf-query -c xsettings -p /Gtk/ShellShowsAppmenu -n -t bool -s true

2.B. for MATE, you'll need to edit the ~/.config/gtk-3.0/settings.ini file (if this file doesn't exist, create it) and in this file, add the following under "[Settings]":
gtk-shell-shows-app-menu=true
gtk-shell-shows-menubar=true
Here are step by step instructions for doing this. Firstly, create the ~/.config/gtk-3.0/ folder in case it doesn't exist, by using the following command:
mkdir -p ~/.config/gtk-3.0/
Then open ~/.config/gtk-3.0/settings.ini with Pluma text editor:
pluma ~/.config/gtk-3.0/settings.ini
If this file has a "[Settings]" section, paste under it the following:
gtk-shell-shows-app-menu=true
gtk-shell-shows-menubar=true
If the file is empty, paste the following in this file:
[Settings]
gtk-shell-shows-app-menu=true
gtk-shell-shows-menubar=true
... and save the file.

Unfortunately, for MATE, this will not disable the menu from being displayed in app windows for GTK2 (I mentioned this in the issues section above).

3. Restart the session (logout, then log back in).

4. Add the Vala AppMenu applet to the panel (and how to change its position on the MATE panel).

4.A. For Xfce, right click the panel on which you want to add Vala AppMenu to, and select Panel > Panel Preferences (I prefer this to directly adding the applet to the panel, because it also allows moving it to the desired position), and on the Items tab, click "+" and add "AppMenu Plugin" to the panel:


You can move Vala AppMenu to the desired position on the panel via the Items tab from the Xfce4 Panel Preferences.

If you have TopMenu installed, make sure you don't mix the two!

4.B. For MATE, right click the panel, select "Add to panel", then search for "Global Application Menu" and click "Add":


Unfortunately there's no easy way of moving the applet to the desired position on the panel. That's because the Vala Panel AppMenu responds in the same way to both left and right click, and there's no area to access its context menu.

To change the global menu position on the MATE panel, you'll need Dconf Editor, which can be installed using the following command:
sudo apt install dconf-editor

Next, launch Dconf Editor, navigate to org > mate > panel > objects and in the "objects" tree, you should see some items called "object-1", "object-2" and so on. Start from the last object and see which has the "applet-iid" value set to "AppMenuAppletFactory:AppMenuApplet".

Note: you may have multiple applets ("object-1", "object-2", etc.) with the "applet-iid" value of "AppMenuApplet..." - in that case you'll need to change the settings for the last one (the higher number).

The "position" value represents the number of pixels between the left-hand side of the panel and the applet position. So once you find the right applet, change its position value to suit your needs (try to approximate it, if the other applets are locked, a lower value than the actual position will work in some cases).

In my case, I have a menu, a Firefox launcher, and a separator and I want to move the global menu next to them, so I set the "position" value to "100":

Global Menu Ubuntu MATE Vala Panel AppMenu

After you change the position, you'll need to restart the MATE panel to apply the changes (or logout/login). To do this, open a terminal and type:
mate-panel --replace &

5. Optional: enable Vala Appmenu (global menu) for Firefox and Thunderbird.

By default, Vala AppMenu will only display the Thunderbird and Firefox Unity actions (quicklists) on the panel. To enable the full Firefox and Thunderbird menu on the panel, you must launch Firefox and Thunderbird with "UBUNTU_MENUPROXY=0".

You can do this automatically (by copying the Firefox and Thunderbird .desktop files from /usr/share/applications to ~/.local/share/applications/ so they are not overwritten when they receive updates, and modify the .desktop files there) for both Firefox and Thunderbird, by using the commands below:
mkdir -p ~/.local/share/applications/
cp /usr/share/applications/firefox.desktop ~/.local/share/applications/
sed -i 's/^Exec=/Exec=env UBUNTU_MENUPROXY=0 firefox %u/' ~/.local/share/applications/firefox.desktop
cp /usr/share/applications/thunderbird.desktop ~/.local/share/applications/
sed -i 's/^Exec=/Exec=env UBUNTU_MENUPROXY=0 thunderbird %u/' ~/.local/share/applications/thunderbird.desktop


Undo the changes


Below you'll find the exact steps required to undo the changes made by following the instructions mentioned above.

1. Remove Vala AppMenu:
sudo apt purge xfce4-vala-appmenu-plugin mate-applet-vala-appmenu

If you are sure (Important! don't remove these packages if you also use Unity) that the Unity GTK module and AppMenu packages are not used by any other packages on your system, also purge them by using the following command:
sudo apt purge unity-gtk3-module unity-gtk2-module appmenu-qt appmenu-qt5

2. Undo the MATE/Xfce menu disable settings

2.A. For Xfce, use the following commands:
xfconf-query -c xsettings -p /Gtk/ShellShowsMenubar -n -t bool -s false
xfconf-query -c xsettings -p /Gtk/ShellShowsAppmenu -n -t bool -s false

2.B. For MATE, open ~/.config/gtk-3.0/settings.ini with a text editor - the command below uses Pluma to open this file:
pluma ~/.config/gtk-3.0/settings.ini
And from this file, remove the following two lines:
gtk-shell-shows-app-menu=true
gtk-shell-shows-menubar=true
If this file was created by following the instructions in this article (was empty or it didn't exist before), you can simply remove it by using the following command:
rm ~/.config/gtk-3.0/settings.ini

3. Restart the session (logout, then log back in)

4. If you applied the optional Thunderbird and Firefox tweaks mentioned above, you can undo this step by simply removing their .desktop files from ~/.local/share/applications/. To do this from a terminal, use the following commands:
rm ~/.local/share/applications/firefox.desktop
rm ~/.local/share/applications/thunderbird.desktop

Thanks to WebUupd8 reader omg2090 for the tip and information (check out his comment for how to build this from source and an extra tweak).