Xfce Forum

Sub domains
 

You are not logged in.

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

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 163

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

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
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,049

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.

Offline

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

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 163

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

Offline

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

Misko_2083
Member
Registered: 2015-10-13
Posts: 94
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)

Offline

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

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,049

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.

Offline

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

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 163

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

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

Board footer

Powered by FluxBB