Bug 2033572

Summary: [RFE] Provide options to edit and add to the right-click menu
Product: Red Hat Enterprise Linux 8 Reporter: Anthony Russell <anrussel>
Component: gnome-shell-extensionsAssignee: Florian Müllner <fmuellner>
Status: CLOSED ERRATA QA Contact: Michael Boisvert <mboisver>
Severity: medium Docs Contact: Marek Suchánek <msuchane>
Priority: medium    
Version: 8.4CC: amike, brclark, charles.v.carlson, fmuellner, jadahl, jwboyer, mboisver, mclasen, mkolbas, oholy, sbarcomb, tpelka, tpopela
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gnome-shell-extensions-3.32.1-32.el8 Doc Type: Enhancement
Doc Text:
.Custom right-click menu on the desktop You can now customize the menu that opens when you right-click the desktop background. You can create custom entries in the menu that run arbitrary commands. To customize the menu, see link:https://access.redhat.com/articles/7003141[Customizing the right-click menu on the desktop].
Story Points: ---
Clone Of:
: 2160553 (view as bug list) Environment:
Last Closed: 2023-05-16 08:37:43 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2160553    

Comment 20 Florian Müllner 2022-06-27 13:36:37 UTC
I was asked to provide instructions for using the custom-menu-panel extension (https://extensions.gnome.org/extension/4295/custom-menu-panel/) in RHEL8. Here are my findings:

The oldest version the extension claims to support is GNOME 40 (RHEL9), but in reality it works as expected on older versions, including RHEL8.

By default, gnome-shell does accept extensions that don't explicitly support the GNOME version in use, so the extension should work out of the box.

To make sure that is the case, check that

  $ gsettings get org.gnome.shell disable-extension-version-validation

returns "true".

If it doesn't, the value can be changed with the following command:

  $ gsettings set org.gnome.shell disable-extension-version-validation true

Alternatively, edit the extension's metadata.json file to include "3.32" in the "shell-version" array.


The extension reads its menu definition from a ".entries.json" file in the user's $HOME.

The root object should have an "entries" property that contains an array of objects that describe menu items.

Each menu item has a "type" property that describes the item type:

 - launcher
   A regular, stateless item that runs a command when activated.

   It is defined by the following properties:
   - title - the menu item label
   - command - a shell command line to run if the item is activated

 - toggler
   A menu item with an on/off state (represented by a switch)

   It is defined by the following properties:
   - title - the menu item label
   - command_on - a shell command line to switch the item on
   - command_off - a shell command line to switch the item off
   - detector - a shell command for determining the initial state

   According to the documentation, the "detector" command should return
   0 for "on" and non-0 for "off". However in reality
     - the command isn't run at all (unless manually patching the extension)
     - the state actually depends on whether the command returns any output

 - submenu
   An expandable item that reveals additional menu items when activated

   It is defined by the following properties:
   - title - the menu item label
   - entries - an array of menu items, just like the top-level property

   The format allows for nested submenus, but the implementation does not.

 - separator
   A non-interactive item to visually separate menu sections from each other.


The following is an example configuration that contains at least one item of each type:

```
{
    "entries": [
        {
            "type": "submenu",
            "title": "Clock",
            "entries": [
                {
                    "type": "toggler",
                    "title": "Show Seconds",
                    "command_on": "gsettings set org.gnome.desktop.interface clock-show-seconds true",
                    "command_off": "gsettings set org.gnome.desktop.interface clock-show-seconds false",
                    "detector": "gsettings get org.gnome.desktop.interface clock-show-seconds | grep true"
                },
                {
                    "type": "toggler",
                    "title": "Show Weekday",
                    "command_on": "gsettings set org.gnome.desktop.interface clock-show-weekday true",
                    "command_off": "gsettings set org.gnome.desktop.interface clock-show-weekday false",
                    "detector": "gsettings get org.gnome.desktop.interface clock-show-weekday | grep true"
                }
            ]
        },
        {
            "type": "separator"
        },
        {
            "type": "launcher",
            "title": "Edit menu",
            "command": "gedit $HOME/.entries.json"
        }
    ]
}
```

Comment 22 Florian Müllner 2022-06-27 18:13:00 UTC
I've uploaded a modified version of the extension that
 - runs the 'detector' script to fetch the initial state
 - replaces the background menu instead of adding a custom indicator to the top bar

It is available at https://fedorapeople.org/~fmuellner/custom-menu-panel@AndreaBenini.shell-extension.zip.

Note that the extension only works with gnome-shell's own background menu. That is, it only works in the regular (non-classic) session with the desktop-icons extension disabled.

Comment 36 Anthony Russell 2022-10-06 07:13:43 UTC
Thank you very much.
I have passed it on to the customer.

Comment 44 Michael Boisvert 2023-01-19 18:15:44 UTC
Instructions for testing/docs:

1. In a non-classic session using either Wayland or X11, install and enable gnome-shell-extension-custom-menu-3.32.1-33.el8.noarch.rpm
2. Customize a file called .entries.json at $HOME/ as outlined here: https://github.com/andreabenini/gnome-plugin.custom-menu-panel/blob/main/README.md
3. Restart your session.
4. Right-click on the desktop to see your custom menu.

Comment 53 errata-xmlrpc 2023-05-16 08:37:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gnome-shell-extensions bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2840