v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
654 stars 58 forks source link

Menu items separator #215

Closed hemanti0503 closed 1 year ago

hemanti0503 commented 1 year ago

Hi, I use YAD to execute often-used commands from my systray. It currently looks like this:

yad --notification --image="applications-all" --text="My Tray Icon" --menu=" Group 1 Command_1 ! group_1_command_1
    | Group 1 Command_2 ! group_1_command_2 \
    |-- \
    | Group 2 Command_1 ! group_2_command_1 \
    | Group 2 Command_2 ! group_2_command_2 \
    | Group 2 Command_3 ! group_2_command_3 \
    | -- \
    | Quit ! quit" \
\
    --command="menu"

As you see, I separate the commands by --. It works, but it seems not very space-efficient. Is there (or could there be) an option to use a thin horizontal separator line instead, that doesn't take away the space of a complete command line?

v1cont commented 1 year ago

use empty name (without any spaces!) instead of '--' to add real menu separator

Sat, 14 Jan 2023 01:14:26 -0800 hemanti0503 @.***> написав:

Hi, I use YAD to execute often-used commands from my systray. It currently looks like this:

yad --notification --image="applications-all" --text="My Tray Icon" --menu=" Group 1 Command_1 ! group_1_command_1 | Group 1 Command_2 ! group_1_command_2 \ |-- \ | Group 2 Command_1 ! group_2_command_1 \ | Group 2 Command_2 ! group_2_command_2 \ | Group 2 Command_3 ! group_2_command_3 \ | -- \ | Quit ! quit" \ \ --command="menu"

As you see, I separate the commands by --. It works, but it seems not very space-efficient. Is there (or could there be) an option to use a thin horizontal separator line instead, that doesn't take away the space of a complete command line?

-- wbr Victor Ananjevsky @.***>

hemanti0503 commented 1 year ago

That's beautiful! Thank you so much! :)

While your solution works nicely, I now have a problem with readability. My code now looks like this:

yad --notification --image="applications-all" --text="My Tray Icon" --menu=" Group 1 Command_1 ! group_1_command_1
    | Group 1 Command_2 ! group_1_command_2 || Group 2 Command_1 ! group_2_command_1 \
    | Group 2 Command_2 ! group_2_command_2 \
    | Group 2 Command_3 ! group_2_command_3 || Quit ! quit" \
\
    --command="menu"

It looked really neat before when every menu entry was on a separate line. Now it gets quite messy, especially since some of my commands are quite long. I think, I might be able to solve this somehow by escaping whitespace, but I can't figure out how.

ibh2322 commented 1 year ago

That's beautiful! Thank you so much! :)

While your solution works nicely, I now have a problem with readability. My code now looks like this:

yad --notification --image="applications-all" --text="My Tray Icon" --menu=" Group 1 Command_1 ! group_1_command_1
    | Group 1 Command_2 ! group_1_command_2 || Group 2 Command_1 ! group_2_command_1 \
    | Group 2 Command_2 ! group_2_command_2 \
    | Group 2 Command_3 ! group_2_command_3 || Quit ! quit" \
\
    --command="menu"

It looked really neat before when every menu entry was on a separate line. Now it gets quite messy, especially since some of my commands are quite long. I think, I might be able to solve this somehow by escaping whitespace, but I can't figure out how.

Hi, This is how i did it and that worked for me.

yad --notification --image="applications-all" --text="My Tray Icon" \
    --menu=" Group 1 Command_1 ! group_1_command_1 \
    | Group 1 Command_2 ! group_1_command_2 \
    || Group 2 Command_1 ! group_2_command_1 \
    | Group 2 Command_2 ! group_2_command_2 \
    | Group 2 Command_3 ! group_2_command_3 \
    || Quit ! quit" \
    \
    --command="menu"
hemanti0503 commented 1 year ago

Such a simple solution! Works great, thank you! :)