Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-04-09 16:08:11

Troglodyte
Member
Registered: 2020-04-09
Posts: 16

[SOLVED] Including a custom menu in applications menu.

I'm switching to FXCE from years of loyal Fluxbox usage.   I have most everything tweaked the way I like it, except one thing.  I'm having a hard time finding good documentation on menu customization.  I've found enough to get started, which got me mostly where I need to go, but here's my problem.

I've created a custom menu for my myriad of SSH connections.  Specifically, i created a file called ssh.menu that has the full structure of how I want my ssh connections laid out.  I added a menu item next to the Whisker menu in my panel and all is good.  The problem is, i want that SSH menu to also appear as a menu item in the main Applications menu when I right-click on the desktop.  I've found a way to modify the categories and add/remove individual items there, but I can not find a way to include a menu. 

Any help, and perhaps a link to the detailed Menu documentation and the XML DTD would be very much appreciated.

I'm running XFCE 4.12 on Ubuntu 18.04

Last edited by Troglodyte (2020-04-13 01:23:03)

Offline

#2 2020-04-09 19:22:26

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,023

Re: [SOLVED] Including a custom menu in applications menu.

Hello and welcome.

Troglodyte wrote:

I added a menu item next to the Whisker menu in my panel and all is good.  The problem is, i want that SSH menu to also
appear as a menu item in the main Applications menu when I right-click on the desktop.

The only way to really achieve this is to add you ssh.menu to the main Applications menu as a submenu. That way it will appear in both the main menu and xfdesktop's Applications menu.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-04-09 20:09:33

Troglodyte
Member
Registered: 2020-04-09
Posts: 16

Re: [SOLVED] Including a custom menu in applications menu.

ToZ wrote:

The only way to really achieve this is to add you ssh.menu to the main Applications menu as a submenu. That way it will appear in both the main menu and xfdesktop's Applications menu.

Right.  This is exactly what I'm trying to do, I just can't figure out how to do that.

Offline

#4 2020-04-09 23:59:56

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,023

Re: [SOLVED] Including a custom menu in applications menu.

Here is a quick and dirty how to. If any folders are missing in the commands below, create the folder.

Step 1: Desktop directory file. Create the file ~/.local/share/desktop-directories/ssh.directory with the following content:

[Desktop Entry]
Version=1.0
Type=Directory
Icon=folder-remote
Name=SSH

...change the Icon and Name fields to suit.

Step 2: Merged entry file. Create the file ~/.config/menus/applications-merged/ssh.menu with the following content:

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
  <Name>Xfce</Name>
  <Menu>
    <Name>Network</Name>
    <Directory>xfce-network.directory</Directory>
  <Menu>
    <Name>SSH</Name>
    <Directory>ssh.directory</Directory>
	<Include>
	<Category>ssh</Category>
	</Include>
  </Menu>
  </Menu>
</Menu>

...note that this uses the default Xfce menu as source. If you've created your own menu from scratch it might need some extra tweaking.

Step 3: Desktop files. You need to create a desktop file for every ssh connection (menu entry) that you need. Create the file ~/.local/share/applications/XXX.desktop (where XXX is a unique name for every connection) that includes the following information:

[Desktop Entry]
Type=Application
Name=SSH Host #1
Comment=Connect to Host #1
Icon=ssh
Exec=xfce4-terminal -T "Host #1" -H -x ssh host1
Categories=ssh;
StartupNotify=true

...and adjust the Name, Comment, Icon, and Exec fields to suit. Again, create one file for every connection.

The menu should auto update to include an SSH submenu under the Internet menu with all ssh connection entries listed there.

In a nutshell, Step 1 creates the directory file to hold the menu items, Step 2 merges in the new SSH menu into the existing menu, and Step 3 creates all of the menu items.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2020-04-10 19:36:43

Troglodyte
Member
Registered: 2020-04-09
Posts: 16

Re: [SOLVED] Including a custom menu in applications menu.

Forgive me if I'm just being dense - but as I mentioned in my original post, without any real documentation I'm piecing what I can out of some examples on line and guessing my way through this. 

I already have a working SSH menu, with layouts and submenus of their own.   All it is is just the SSH connections.  There's a snippet at the end of this comment.    What I'm looking to do is include that menu in the main apps menu.  Something like

<menu>
<Name>SSH Connections</Name>
<Include>menu.ssh</Include>
</menu>

I tried doing what you suggested (thank you for that, by the way) and just replaced ~/.config/menus/applications-merged/ssh.menu that you put in as an example with my ssh.menu.  The results were disastrous.  sad  Anyway.. here's the beginning of my ssh.menu.


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Menu
  PUBLIC '-//freedesktop//DTD Menu 1.0//EN'
  'http://standards.freedesktop.org/menu-spec/menu-1.0.dtd'>
<Menu>
    <Name>SSH</Name>

    <!--This defines where to find .desktop files-->
    <DefaultAppDirs />

    <!--This affects how will the entries appear under "Parent"-->
    <Layout>
	<Menuname>Solaris</Menuname>
	<Separator /> 	

	<Menuname>Web</Menuname>
	<Separator />

	
    </Layout>

    <!--This includes what entries will appear under "Child" -->
    <Menu>
        <Name>Solaris</Name>
        <Include>
		<Filename>memsun10.desktop</Filename>
		<Filename>memsun31.desktop</Filename>
		<Filename>memsun75.desktop</Filename>
..... etc ....

Last edited by Troglodyte (2020-04-10 19:37:30)

Offline

#6 2020-04-10 23:41:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,023

Re: [SOLVED] Including a custom menu in applications menu.

The method I mentioned above worked for me in the past and allows me to create submenus exactly where I want them.

You can also edit the xfce-applications.menu directly and add something like:

        <Menu>
            <Name>SSH</Name>
                <MergeFile>/home/toz/ssh.menu</MergeFile>
        </Menu>

...into the body of the menu with the other menu entries to create a new one that links to your existing menu. I can't seem to find a way to embed this into an existing menu though.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2020-04-12 22:14:23

Troglodyte
Member
Registered: 2020-04-09
Posts: 16

Re: [SOLVED] Including a custom menu in applications menu.

ToZ wrote:

You can also edit the xfce-applications.menu directly and add something like:

        <Menu>
            <Name>SSH</Name>
                <MergeFile>/home/toz/ssh.menu</MergeFile>
        </Menu>

...into the body of the menu with the other menu entries to create a new one that links to your existing menu. I can't seem to find a way to embed this into an existing menu though.

This worked perfectly!  Thank you so much!  The only thing I had to add was an entry in the <Layout> section of the xfce-applications.menu

Last edited by Troglodyte (2020-04-12 22:48:09)

Offline

#8 2020-04-12 23:08:27

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,023

Re: [SOLVED] Including a custom menu in applications menu.

Troglodyte wrote:

The only thing I had to add was an entry in the <Layout> section of the xfce-applications.menu

Did this allow it to be a submenu? Can you post your layout changes?


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#9 2020-04-13 00:45:52

Troglodyte
Member
Registered: 2020-04-09
Posts: 16

Re: [SOLVED] Including a custom menu in applications menu.

In ~/.config/menus/xfce-applications.menu, at the same level as the other menu items I added:

<Menu>
   <Name>SSH</Name>
   <Directory>ssh.directory</Directory>
   <MergeFile>/home/<uid>/.config/menus/ssh.menu</MergeFile>
</Menu>

it did not dereference ~/ so I had to use full path.  To the bottom of the <Layouts> section I added:

<Menuname>SSH</Menuname>

The directory file is ~/.local/share/desktop-directories/ssh.directory and contains:

[Desktop Entry]
Version=1.1
Type=Directory
Name=SSH
Icon=utilities-terminal

End result looks like this:

menu

Last edited by Troglodyte (2020-04-13 00:47:20)

Offline

Board footer

Powered by FluxBB