Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-01-03 16:53:17

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

is there a plugin to make a drop-down menu?

is there a plugin to make a drop-down menu and configure a label and command action for each one?  i see a few different plugins with "menu" in the title, but they all seem to be limited in how their menus can be configured.

Offline

#2 2019-01-03 19:04:28

CwF
Member
Registered: 2018-01-28
Posts: 287

Re: is there a plugin to make a drop-down menu?

You can use Launcher for this. Multiple items added to the same launcher yields the carrot next to the primary launcher entry, that then expands to be a menu.

Offline

#3 2019-01-03 19:19:20

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: is there a plugin to make a drop-down menu?

Another option would be to use yad. You'd be surprised what yad can do. A small menu example (will create an icon on the systray that you can right-click to get options or middle-click to quit):

#!/bin/bash

PIPE="$HOME/.pipe.tmp"
rm          $PIPE
mkfifo      $PIPE
exec 3<>    $PIPE

yad --notification --listen <&3 &
echo "menu:\
Terminal Emulator	! xfce4-terminal |\
File Manager		! thunar |\
Web Browser		! exo-open --launch WebBrowser |\
Mousepad		! mousepad | " >&3
echo "icon:$HOME/.icons/menu.png" >&3
echo "tooltip: Right-click for menu" >&3


exit 0

One of our members, Misko_2083 is really good with yad. Hopefully he'll drop by.


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

#4 2019-01-03 20:06:02

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

ultimately, i want to be able to code my own apps in Python3 and anchor them on the panel or anywhere else.  i also would like to have them launched by some special keyboard combinations such as Ctrl+Alt+letter or Ctrl+Shift+letter and so on, where letter can really be just about any key.

Offline

#5 2019-01-04 00:29:45

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: is there a plugin to make a drop-down menu?

ToZ
Here's  a little script for the launcher.
The tricky part was detecting when the app is launched.
Luckily there is strace to track the signal SIGCHLD.
Data for the columns is in arrays.

#!/bin/bash
#######################################################
# Description:                                        #
#   bash script to run dropdown list                  #
#   via yad list UI                                   #
#######################################################

ERR(){ echo "ERROR: $1" 1>&2; }

declare -i DEPCOUNT=0
for DEP in /usr/bin/{xdotool,yad,xargs,printf,strace} /bin/echo; {
    [ -x "$DEP" ] || {
        ERR "$LINENO Dependency '$DEP' not met."
        DEPCOUNT+=1
        }
}
[ $DEPCOUNT -eq 0 ] || exit 1

VERSION=`yad --version | awk '{ print $1 }'`
verlte() {
    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}

verlt() {
    [ "$1" = "$2" ] && return 1 || verlte $1 $2
}

if verlt $VERSION 0.38.2; then
   yad --text=" The version of yad installed is too old for to run this program, \n Please upgrade yad to a version higher than 0.38.2   " \
       --button="gtk-close"
   exit
fi

# Ensures only one instance of this scipt can start
# Also, if there is another yad window closes it
if [[ $(pgrep -c $(basename $0)) -ne 1 ]]; then
   pids="$(xdotool search --class "yad_launcer")"
   wpid="$(xdotool getwindowfocus)"

   for pid in $pids; do
        # Compares window class pid with the pid of a window in focus
        if [[ "$pid" == "$wpid" ]]; then
           xdotool windowunmap $pid
           exit 1
        fi
   done
fi

#######################################################
# Here you define columns:                            #
#   icon, command, application name, description      #
#                                                     #
#######################################################

# --- You can change this part

# For the icons you can also write full path
# [key]="icon"
declare -A ICON=(
		   [0]="aqualung"
		   [1]="gtk-ok"
		   [2]="gcolor2"
		   [3]="gweled"
		   [4]="minitube"
		   [5]="gtk-ok"
		   [6]="qmmp"
		   [7]="shutter"
                )

# [key]="command"
declare -A APPS=(
		   [0]="/usr/bin/aqualung"
		   [1]="/usr/bin/frozen-bubble"
		   [2]="/usr/bin/gcolor2"
		   [3]="/usr/games/gweled"
		   [4]="/usr/bin/minitube"
		   [5]="/usr/bin/neverball"
		   [6]="/usr/bin/qmmp"
		   [7]="/usr/bin/shutter"
                )

# Application name for the column
# [key]="app name"
declare -A APP_NAME=(
		   [0]="Aqualung"
		   [1]="Frozen Bubble"
		   [2]="Gcolor2"
		   [3]="Gweled"
		   [4]="Mini Tube"
		   [5]="Neverball"
		   [6]="Qmmp"
		   [7]="Shutter"
                )

# [key]="description"
declare -A APP_DESC=(
		   [0]="Music player"
		   [1]="Game"
		   [2]="Color selector"
		   [3]="Puzzle game"
		   [4]="Youtube"
		   [5]="Game"
		   [6]="Music player"
		   [7]="For screenshots"
                )

APP_TITLE="Launcher"

# Activation method can be select or dclick
#   select - run application on selection
#   dclick - run application on double-click
ACTION=select

# --- Don't change anything bellow'

_list()
{
for k in "${!APPS[@]}"; do
        printf "%s\n%s\n%s\n%s\n" "${ICON[$k]}" "${APPS[$k]}" "${APP_NAME[$k]}" "${APP_DESC[$k]}" 
done
}


_list | yad --list \
              --title="$APP_TITLE" \
              --column="icon":IMG \
              --column="Command" \
              --column="Application" \
              --column="Description" \
              --width="500" \
              --height="450" \
              --hide-column="2" \
              --$ACTION-action="sh -c \"echo %s | cut -d ' ' -f 2 2>&1 | xargs sh -c >/dev/null 2>&1\"" \
              --no-buttons  \
              --search-column=3 \
              --window-icon="xfce4-desktop" \
              --undecorated \
              --close-on-unfocus \
              --on-top \
              --skip-taskbar \
              --mouse \
              --sticky \
              --class="yad_launcer" & ICONS_PID=$!

# Command is executed when SIGCHLD signal is emited
# Monitor for SIGCHLD signal and exit 252
# Exit if SIGCHLD is emited
strace -p $ICONS_PID -e trace=signal -s 32 2>&1 \
| while read -r line; do
        if [[ $line =~ "--- SIGCHLD" ]];then
           # Close on launch
           exit 0
         elif [[ $line == "+++ exited with 252 +++" ]]; then
           # Yad is closed on unfocus or Escape keypress
           exit 252
         fi
done

Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#6 2019-01-04 00:48:36

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: is there a plugin to make a drop-down menu?

Aparently the icons dialog can be used in the same way. Even as a fullscreen launcher.

#!/bin/bash
#######################################################
# Description:                                        #
#   bash script to run fullscren launcher             #
#   via yad list UI                                   #
#######################################################

ERR(){ echo "ERROR: $1" 1>&2; }

declare -i DEPCOUNT=0
for DEP in /usr/bin/{xdotool,yad,strace} /bin/echo; {
    [ -x "$DEP" ] || {
        ERR "$LINENO Dependency '$DEP' not met."
        DEPCOUNT+=1
        }
}
[ $DEPCOUNT -eq 0 ] || exit 1

VERSION=`yad --version | awk '{ print $1 }'`
verlte() {
    [  "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}

verlt() {
    [ "$1" = "$2" ] && return 1 || verlte $1 $2
}

if verlt $VERSION 0.38.2; then
   yad --text=" The version of yad installed is too old for to run this program, \n Please upgrade yad to a version higher than 0.38.2   " \
       --button="gtk-close"
   exit
fi

# Ensures only one instance of this scipt can start
# Also, if there is another yad window closes it
if [[ $(pgrep -c $(basename $0)) -ne 1 ]]; then
   pids="$(xdotool search --class "yad_fullscreen_launcer")"
   wpid="$(xdotool getwindowfocus)"

   for pid in $pids; do
        # Compares window class pid with the pid of a window in focus
        if [[ "$pid" == "$wpid" ]]; then
           xdotool windowunmap $pid
           exit 1
        fi
   done
fi

yad --icons \
    --read-dir=/usr/share/applications \
    --fullscreen \
    --sort-by-name \
    --undecorated \
    --single-click \
    --skip-taskbar \
    --close-on-unfocus \
    --class="yad_fullscreen_launcer" \
    --no-buttons & ICONS_PID=$!

# Command is executed when SIGCHLD signal is emited
# Monitor for SIGCHLD signal and exit 252
# Exit if SIGCHLD is emited
strace -p $ICONS_PID -e trace=signal -s 32 2>&1 \
| while read -r line; do
        if [[ $line =~ "--- SIGCHLD" ]];then
           # Close on launch
           exit 0
         elif [[ $line == "+++ exited with 252 +++" ]]; then
           # Yad is closed on unfocus or Escape keypress
           exit 252
         fi
done

Last edited by Misko_2083 (2019-01-04 00:50:06)


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#7 2019-01-04 00:55:35

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: is there a plugin to make a drop-down menu?

Nice. The second one is a little too overwhelming for me, but the first one looks good.


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

#8 2019-01-04 02:52:11

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

CwF wrote:

You can use Launcher for this. Multiple items added to the same launcher yields the carrot next to the primary launcher entry, that then expands to be a menu.

what is "carrot" in this context?  i'm a systems/networking person, not a gui person.

Offline

#9 2019-01-04 03:13:46

CwF
Member
Registered: 2018-01-28
Posts: 287

Re: is there a plugin to make a drop-down menu?

Skaperen wrote:

what is "carrot" in this context?

A name I picked up somewhere? That's the little arrow to the side of the launcher button created with more than one entry. Click on it separately and you get the other entries.

Offline

#10 2019-11-08 06:12:28

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: is there a plugin to make a drop-down menu?

Hey all, we made a small xfce panel plugin which places a button in the panel.
https://github.com/johanmalm/jgmenu/blo … u-applet.c
That button launches Jgmenu which is a simple yet powerful X11 menu.
https://jgmenu.github.io/index.html
The plugin also sets some variables so that the menu "knows" where to position itself.
For the time being button has no label and there is no way to set several menus.
But it will run jgmenu next to the button with the plugin event:

xfce4-panel --plugin-event=jgmenu-applet:popup:bool:false

Jgmenu has the capability to create menus from the pipe, so when I have the will and the time,
I'll play with this more.

printf "Terminal,xterm\nWeb Browser,firefox\n" | jgmenu --vsimple

Last edited by Misko_2083 (2019-11-08 06:22:28)


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#11 2019-11-08 14:51:28

Jerry3904
Member
Registered: 2013-11-09
Posts: 850

Re: is there a plugin to make a drop-down menu?

CwF wrote:
Skaperen wrote:

what is "carrot" in this context?

A name I picked up somewhere? That's the little arrow to the side of the launcher button created with more than one entry. Click on it separately and you get the other entries.

FWIW, the word is caret (Latin: "is lacking"): https://en.wikipedia.org/wiki/Caret


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#12 2019-11-17 02:27:31

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

CwF wrote:

You can use Launcher for this. Multiple items added to the same launcher yields the carrot next to the primary launcher entry, that then expands to be a menu.

how do i make that work?  in its properties window under the General tab is a big empty space and some greyed out buttons to the right.  i have no idea what to type there and it doesn't let me type anything, anyway.

one button is green instead of grey,  it is a plus. when i click it, it brings up a list of things to add, but there is no visible way to type in my own.

Offline

#13 2019-11-19 18:53:16

CwF
Member
Registered: 2018-01-28
Posts: 287

Re: is there a plugin to make a drop-down menu?

In the Launcher properties under the general tab, under the + icon is the sheet of paper icon, it is the 'add a new empty item'. Add a few of those and the launcher icon remains one item, with the drop down/up menu from clicking the arrow.

Offline

#14 2019-11-24 09:09:00

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

how do i put in the command (of my own script) that i want that menu line to run?  if it needs a .desktop file, i can probably do that.  i also need to give that menu line a name or title.

Offline

#15 2019-11-24 18:48:48

ctac
Member
Registered: 2017-05-08
Posts: 57

Re: is there a plugin to make a drop-down menu?

I have a launcher like that.

Name: Menu ssh
Command:

/usr/bin/xfce4-panel --plugin-event=launcher-7:popup

Perhaps 7 is not the same for you.

With two launchers.

first:

Name: XTerm NetBSD
Command:

xterm -title 'NetBSD' -aw -bc -bg white -fg DarkGreen -xrm xterm*iconHint:'./.local/share/icons/NetBSD' -fa 'Monospace Regular' -fs 15 -e 'ssh -X LeNetBSD'
second:

Name: XTerm OpenBSD
Command:

xterm -title 'OpenBSD' -aw -bc -bg white -fg blue -xrm xterm*iconHint:'./.local/share/icons/OpenBSD' -fa 'Monospace Regular' -fs 15 -e 'ssh -X LeOpenBSD'

Offline

#16 2019-11-24 19:51:50

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

are you trying to show me what commands to put in the launcher?  i already have different commands i want to have executed.  those commands will run my own scripts.  not all of the commands will open a window.  what i need to know is how to get the commands into a launcher or how to create my own plugin that i can add to the panel that will do the things i program.

Offline

#17 2019-11-24 20:20:03

ctac
Member
Registered: 2017-05-08
Posts: 57

Re: is there a plugin to make a drop-down menu?

Sorry, but i give you what i have.
I can't help you more because i don't understand what you look for.

Offline

#18 2019-11-25 05:37:50

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

i will try to explain one more time more verbosely in more detail.

i have a few scripts that when run with various argument, will perform tasks i want to have performed.  i have created desktop icons for some of them.  i have also set up keyboards shortcuts for a few.  both of these methods work.  it is undesired to have all the desired tasks use these methods.  using desktop icons would mean filling up the desktop space.  finding good icon images would be hard.  and there would be too many.  using keyboard shortcuts would require using so many key combinations and would be hard to remember which key a task uses.  what would work decently is a menu that can be custom configured with a short description of the task.  the setup might be done in a file or by the application.  this would be a configurable menu.

i also want to have the menu anchored on the panel so it does not get covered up (a problem for desktop icons, too).  that probably means some kind of plug-in.  i wish the panel could also support non-plug-in apps.

each menu item is best to be text.  some items would be submenus.  requiring this all to be a file tree with subdirectories might actually make this easier.

the issue i find with existing launchers is that they are limited to the apps they know about.  unlike keyboard shortcuts, there is no support for running any command you can type in.  there are people who have said there is a way, but i can't find it and they don't say anything beyond that (so i am unsure if it is even real).

Offline

#19 2019-11-25 07:09:31

John Jason Jordan
Member
Registered: 2019-11-22
Posts: 76

Re: is there a plugin to make a drop-down menu?

In Settings Menu > Desktop you can set your application menu to appear anywhere on the desktop with a right mouse click. The application menu is controlled by a .menu file in home/<username>/.config/menus labeled xfce-applications.menu. There is a wiki link here with information about how to customize this file to include the categories you want. You could create a category for all your scripts and then a .desktop file for each one with a Categories= line naming your category. To launch a script right click on the desktop, then on your category, then on the script. The above-mentioned wiki also contains a quick description of what is required for a .desktop file, including the Name= line which is what it will appear as in the menu. You can thus name each .desktop file to describe the function of your script.

Offline

#20 2019-11-25 18:49:25

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

i don't have "Settings Menu" though i do have "Settings..." of other varieties.    i want to have the place where i first click (to start bringing up the menu) to be on the panel because the desktop (the space below the panel) is often entirely covered.  maybe an alternative is to have a keyboard shortcut to bring it up.  there are issues with keyboard shortcuts, so i have to be careful with that and choose which key combination wisely.  i did not see the wiki link anywhere when i was looking around at various places, so i may not have the right stuff in place.  and i want to make sub-categories, too.

if i were designing a graphical system, i would make it work directly from simple directory and file structures, supporting files in TEXT (flat or structured), INI, JSON, PYON, XML and YAML formats. and allow them to be changed externally in real time (for any OS that has change notification).  anything can refer to any tree point to establish its configuration or layout.  it appears that what Xfce has right now is more like chaos.

Offline

#21 2019-11-25 21:46:05

John Jason Jordan
Member
Registered: 2019-11-22
Posts: 76

Re: is there a plugin to make a drop-down menu?

Skaperen wrote:

i don't have "Settings Menu" though i do have "Settings..." of other varieties.    i want to have the place where i first click (to start bringing up the menu) to be on the panel because the desktop (the space below the panel) is often entirely covered.  maybe an alternative is to have a keyboard shortcut to bring it up.

If you add category (-ies) to your menu they will also appear in the Applications menu in your panel. If you don't already have an Applications menu in your panel you can add one - there are several to choose from. I use two, the big one is cleverly named Applications Menu, and I use another one called Launcher, that I use with just a dozen programs so it has no categories or sub-menus. The Applications Menu has categories, and each category can have sub-menus, although I've never created sub-menus under a category.

Here is the wiki I was referring to earlier:
https://wiki.xfce.org/howto/customize-menu

I should add that the wiki above also has information for creating a .desktop file. A .desktop file is just a plain text file with the extension .desktop that contains at least the following:

[Desktop Entry]
Type=Script
Exec=<how to launch the script, e.g., name of the script if the file is executable>
Icon=<optional icon file>
Name=<name of the script that will appear in the menu>
Comment=<optional for the purpose of the script when you hover on the name>

The .desktop files must be kept in either /usr/share/applications, or in ~/.local/share/applications. Were I you I would keep them in the latter folder so you don't have to be root to create/move/delete/edit them.

Last edited by John Jason Jordan (2019-11-25 22:06:19)

Offline

#22 2019-11-26 01:29:34

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: is there a plugin to make a drop-down menu?

my menu already has categories.  this menu is not something Xfce will understand.  it's just an application that draws what looks like a menu an reacts to clicks usually calling os.execvp() with the configured command.  nothing in Xfce can ever understand what it is drawing.  X will understand enough to draw it.  categories are just sub-menus.  but if you show me how to make a menu that you are jumping to conclusion that i did make maybe i can remake mine into that form.  can you create an example and put it where i can download it?

i see the wiki link.  i will try to follow those steps and see what i get.  i have created .desktop files in ~/Desktop to make desktop icons.  is that the same format?  it looks similar to INI format which can be modified to make JSON or PYON format by just quoting the value strings.  yeah, i would use ~/.local/share/applications for per-user customizing.

Offline

#23 2022-11-25 15:52:55

paul.neocube
Member
From: United States
Registered: 2022-11-25
Posts: 3
Website

Re: is there a plugin to make a drop-down menu?

ToZ wrote:

Another option would be to use yad. You'd be surprised what yad can do. A small menu example (will create an icon on the systray that you can right-click to get options or middle-click to quit):

#!/bin/bash

PIPE="$HOME/.pipe.tmp"
rm          $PIPE
mkfifo      $PIPE
exec 3<>    $PIPE

yad --notification --listen <&3 &
echo "menu:\
Terminal Emulator	! xfce4-terminal |\
File Manager		! thunar |\
Web Browser		! exo-open --launch WebBrowser |\
Mousepad		! mousepad | " >&3
echo "icon:$HOME/.icons/menu.png" >&3
echo "tooltip: Right-click for menu" >&3


exit 0

One of our members, Misko_2083 is really good with yad. Hopefully he'll drop by.

This is perfect actually. Since I am not an expert in coding, this seems easy enough to manage without much coding experience. Well, so I thought anyways. I attempted to edit the first item to launch a WebCatalog app via a .desktop file but with different variations, was unsuccessful. I see the option in the menu but it does not successfully launch the application. Here is the line of code I edited:

Amazon Apps    ! "/home/neocube/.webcatalog/Amazon Apps/Amazon Apps" |\

Any idea why this would not work correctly and launch the app? In Terminal "/home/neocube/.webcatalog/Amazon Apps/Amazon Apps" (with the quotes) launches it without any issue. Many thanks for taking the time to read my post.

Offline

#24 2022-11-25 16:28:23

paul.neocube
Member
From: United States
Registered: 2022-11-25
Posts: 3
Website

Re: is there a plugin to make a drop-down menu?

CwF wrote:

You can use Launcher for this. Multiple items added to the same launcher yields the carrot next to the primary launcher entry, that then expands to be a menu.

This is what led me to this post. I did it once and do not remember how I did it. Selecting multiple desktop files and right-clicking "Create launcher on the panel" opens multiple dialog boxes to add those items to the panel separately but not together as a drop-down menu. I cannot reproduce it lol

Offline

#25 2022-11-25 18:51:13

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: is there a plugin to make a drop-down menu?

paul.neocube wrote:

Amazon Apps    ! "/home/neocube/.webcatalog/Amazon Apps/Amazon Apps" |\

The quotes might be throwing it off (because its already enclosed in quotes). See if one of these versions will work:

Amazon Apps    ! '/home/neocube/.webcatalog/Amazon Apps/Amazon Apps' |\

...or:

Amazon Apps    ! /home/neocube/.webcatalog/Amazon\ Apps/Amazon\ Apps |\

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

Board footer

Powered by FluxBB