Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore file for appmenu #303

Open
napcok opened this issue Jan 1, 2025 · 43 comments
Open

Ignore file for appmenu #303

napcok opened this issue Jan 1, 2025 · 43 comments

Comments

@napcok
Copy link
Contributor

napcok commented Jan 1, 2025

It is possible to implement a file listing .desktop files to exclude from the output menu?

Maybe also a good idea... user-defined HEADER and FOOTER file for the menu?

I'm new in wayland world.... and sfwbar is amazing. :)
Thank you.

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 1, 2025

@napcok
Copy link
Contributor Author

napcok commented Jan 1, 2025

https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html echo "Hidden=true;" >> no_need.desktop

Not a solution. Not flexible. I don't need to hide programs system-wide. I need to hide them in sfwbar menu - like i'm able to hide them in Labwc menu.
I use many WMs, some X11 based and Labwc (wayland)

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 1, 2025

OnlyShowIn=
NotShowIn=

@napcok
Copy link
Contributor Author

napcok commented Jan 1, 2025

OnlyShowIn= NotShowIn=

This is theory, in practice it doesn't work.

Either way, I think my proposal is worth considering by developers.

@LBCrion
Copy link
Owner

LBCrion commented Jan 1, 2025

Header/footer - do you mean manually added items at the top/bottom of the menu or just static text? This looks like a part of #302 coincidentally also opened today. It should also be reasonably easy to implement.

Filtering out specific entries. I think there are a few reasons to implement this:

  1. we already do something similar with window filtering and appid mapping.
  2. I'm not a fan of forcing users to maintain changes to desktop entry files. Distributions often overwrite these during upgrades, so it ends up a repetitive fix process. Also, changing desktop entries affects all users. Filtering in a panel allows for per user filters.

@napcok
Copy link
Contributor Author

napcok commented Jan 1, 2025

Yes, I mean manually added commands.

Just an idea taken from how Jgmenu does this...
Syntax is:
LABEL,COMMAND,ICON

Something like:
~/.config/sfwbar/menu_top.csv

Firefox,firefox,firefox
File Manager,thunar,system-file-manager
System update,foot yay,system-file-manager

~/.config/sfwbar/menu_bottom.csv

Screenshot,sh -c 'grim -t jpeg ~/screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg',image
Logout,labwc --exit,system-log-out
Reboot,systemctl reboot,system-reboot
Shutdown,systemctl poweroff,system-shutdown

Very easy for users to customize.

@LBCrion
Copy link
Owner

LBCrion commented Jan 2, 2025

New actions added to the appmenu module:

AppMenuFilter - filter a .desktop file from the menu. Takes one string parameter that is the name of the file INCLUDING the .desktop extension.

AppMenuItemTop "Title", "Command" - add an item to the top of the menu. Title can have %icon in it. Command will be executed up the item selection. For now this is the only action supported.

AppMenuItemBottom, same as AppMenuItemTop except item is added at the bottom of the menu.

@napcok
Copy link
Contributor Author

napcok commented Jan 2, 2025

Thank you.
Installed sfwbar-git, now I'm trying to figure out how to use this (apply those actions to appmenu module).
Can somebody please point me to the right direction?

@LBCrion
Copy link
Owner

LBCrion commented Jan 2, 2025 via email

@napcok
Copy link
Contributor Author

napcok commented Jan 2, 2025

It works, partially.
sfwbarmenu2
Two things:

  1. Items added to top and bottom are sorted alphabetically (not in the order they added).
  2. AppMenuFilter action does not work.

My SfwbarInit:

function("SfwbarInit") {
  sway_bar_id "bar-0"
  layer "top"
  
  AppMenuFilter "panelxpose.desktop"
  AppMenuFilter "arandr.desktop"
  AppMenuFilter "gxkb.desktop"
  AppMenuFilter "lxrandr.desktop"
  AppMenuFilter "lxinput.desktop"
  AppMenuFilter "espanso.desktop"
    
  AppMenuItemTop "File Manager%pcmanfm", "pcmanfm"
  AppMenuItemTop "Web Browser%firefox", "firefox"
  AppMenuItemTop "Add/remove Software%pamac-manager", "pamac-manager"
  
  AppMenuItemBottom "Take screenshot%image", "/home/napcok/bin/grimshot --cursor --wait 10 save area sfwbarmenu2.png"
  AppMenuItemBottom "Logout%system-log-out", "labwc --exit"
  AppMenuItemBottom "Reboot%system-reboot", "systemctl reboot"
  AppMenuItemBottom "PowerOff%system-shutdown", "systemctl poweroff"
}

@LBCrion
Copy link
Owner

LBCrion commented Jan 3, 2025 via email

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 3, 2025

Wouldn't it be better to make
Item(“terminal.desktop”, “top|bottom”)
It would solve the localization and “tooltip” problem.
Now “tooltip” is not in AppMenuItemBottom, and localization will have to be done through GT, i.e. double work :(

Besides it would be good to have a separator between main and Top\Bottom menus like “separator”.

Is it possible to add submenu(“sub”, “mysubmenu”)
Tried : action = { Menu “app_menu_system” menu “menu_name1” }
I get 2 menus at the same time

@napcok
Copy link
Contributor Author

napcok commented Jan 3, 2025

  1. AppMenuFilter action works.
  2. Added items sorted as they added in config, but all of them added to top

sfwbarmenu3

@LBCrion
Copy link
Owner

LBCrion commented Jan 3, 2025

Top/bottom ordering should work now.

@sfs-pra, I think I'll need to support both desktop entry based binned items as well as custom items. Looking at how @napcok example, he's adding custom commands to the menu. It is theoretically possible to add these via custom desktop files, but I'd rather not force users to create those. That said, adding entries based on desktop files should also be an option. Will work on this later (and will look at adding support for custom submenus as well).

@napcok
Copy link
Contributor Author

napcok commented Jan 4, 2025

I confirm, it works as it should
Thank you very much :)

One more question/request:
It is possible to allow PipeRead in this place? (function SfwbarInit)

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 4, 2025

I confirm, it works as it should

sfwbar-git r1753.701626d - yes!

Will work on this later

ok

Now “tooltip” is not in AppMenuItemBottom

AppMenuItemBottom GT("Find") + "%gtk-find%tooltip", "vala-panel-runner" ?

Besides it would be good to have a separator

AppMenuItemTop "╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼", "true"

@LBCrion
Copy link
Owner

LBCrion commented Jan 4, 2025 via email

@LBCrion
Copy link
Owner

LBCrion commented Jan 4, 2025 via email

@knm100
Copy link
Contributor

knm100 commented Jan 6, 2025

Tried : action = { Menu “app_menu_system” menu “menu_name1” }
I get 2 menus at the same time

where should i add action = { Menu “app_menu_system” menu “menu_name1” } ?
I tried to add it to startmenu.widget and function("SfwbarInit") , but the both way didn't work

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 6, 2025

where should i add action = { Menu “app_menu_system” menu “menu_name1” } ?

in startmenu.widget

@LBCrion
Copy link
Owner

LBCrion commented Jan 15, 2025

I added functionality to allow configuring properties of menu items similar to widgets (including sort order), but haven't exposed this in the config yet. The question now is how to make this user accessible. As always with more flexibility, we get more config complexity. If we follow widget config model, we'll end up with something like this:

menu("mymenu") {
   item "item1" {
     title = "Menu Item 1"
     action = CallMyFunction1()
     tooltip = "This the first menu item"
     index = 1
   }
   item "item2" {
      title = "Menu Item 2"
      action = Exec "firefox"
      tooltip  = "Menu item 2"
     index = 2
   }
   item "item 3" {
      desktop_id = "firefox"
      index = 2  # since both item2 and item3 have the same index, they will be sorted alphabetically by their title
  }
}

If we use this mode, we can set system menu index to something like 500 by default, so user defined items can be added before or after it as needed. The downside is that the user will need to specify sort index explicitly in the menu.

@knm100
Copy link
Contributor

knm100 commented Jan 15, 2025

Is this expected?
swappy-20250115-210211

@LBCrion
Copy link
Owner

LBCrion commented Jan 16, 2025

No, this shouldn't be happening. Should be fixed in the latest git.

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 25, 2025

sfwbar-git-r1794.1ed698b
Alphabetical sorting is now available in AppMenuItemBottom
Can it be returned as it was - without sorting, in the order of enumeration?

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 26, 2025

sfwbar-git-r1794.1ed698b
They don't work Hidden= NoDisplay=

@LBCrion
Copy link
Owner

LBCrion commented Jan 27, 2025 via email

@LBCrion
Copy link
Owner

LBCrion commented Jan 27, 2025

sfwbar-git-r1794.1ed698b Alphabetical sorting is now available in AppMenuItemBottom Can it be returned as it was - without sorting, in the order of enumeration?

This is what the comment #303 (comment) is for. We really need to figure out a better way to specify menu items, both for the custom menus and for the application menu.

Using actions to add menu items limits us to only a few parameters (and only one optional parameter realistically). It also only allows binding Exec actions to menu items.

I would very much like some feedback on a more full featured menu item config, which should ideally allow specifying multiple optional properties (including sort order). I don't like the way the sort order works in my comment above. It is more or less required unless you want all items in the menu to be sorted alphabetically.

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 27, 2025

sfwbar-git-r1795.ff14406
Hidden= NoDisplay=
without improvement
killall -1 sfwbar - does not solve the problem

Can it be returned as it was - without sorting, in the order of enumeration?
without improvement

In my opinion it is optimal to sort alphabetically in the application menu, in AppMenuItem - without sorting, i.e. as written.
I.e. as it was
index = in menu optionally would not hurt either
How to solve the problem with AppMenuItem sorting now ?

@sfs-pra
Copy link
Contributor

sfs-pra commented Jan 29, 2025

sfwbar-git-r1795.ff14406
Hidden= NoDisplay=
without improvement

Works. The problem was a duplicate in ~/local/share/applications
The problem remains - it doesn't work:
NoDisplay=true;
Hidden=true;
; - sometimes used

@LBCrion
Copy link
Owner

LBCrion commented Feb 1, 2025 via email

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 1, 2025

NoDisplay=true;
Hidden=true;

sfwbar-git-r1806.c74fd8d
problem solved

How to solve the problem with AppMenuItem sorting now ?

without improvement

@LBCrion
Copy link
Owner

LBCrion commented Feb 1, 2025 via email

@LBCrion
Copy link
Owner

LBCrion commented Feb 3, 2025

Ok, the new menu declaration system should be ready to test. It' still subject to change, so I'm not documenting it yet. Here's an example:

Menu("MyMenu") {
  Sort = True
  Item {
    Label = "Item1"
    Action = "firefox"
    Tooltip = "Some text here"
    Index = 1
  }
  Item {
    Label = "Submenu"
    Tooltip = "Example Submenu"
    Index = 2
    Submenu {
      Item { Label = "submenu item 1" }
      Item { Label = "submenu item 2" }
     }
  }
}

@LBCrion
Copy link
Owner

LBCrion commented Feb 3, 2025

This should replace AppMenuItemTop/AppMenuItemBottom. Instead of these, you can just add items to the application menu with explicit index specified.

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 4, 2025

example:

Where to add this code instead of AppMenuItemTop/AppMenuItemBottom ?
How to add icons?
How to use "DesktopId" ?

@LBCrion
Copy link
Owner

LBCrion commented Feb 5, 2025 via email

@LBCrion
Copy link
Owner

LBCrion commented Feb 5, 2025 via email

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 5, 2025

How do you now get an apps menu with the addition of what used to be called AppMenuItemTop/AppMenuItemBottom ?

desktopid = "Alacritty"

Is this addition to the Alacritty.desktop menu ?
Nothing is clear at all so far :(

@LBCrion
Copy link
Owner

LBCrion commented Feb 5, 2025 via email

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 5, 2025

module("appmenu")

menu("app_menu_system") {
  Item {
    Label = "gtkhash%gtkhash"
    Action = "gtkhash"
    Tooltip = "Some text here"
    Index = 1
  }
 item {
  label = "aaa"
  index = 1000
 }
 item {
  desktopid = "gtkhash"
  label = "my label"
 }
}

layout {
  button {
    value = "open-menu"
    style = "startmenu"
    action = Menu "app_menu_system" 
    tooltip = GT("Application menu")
  }
}

It works like this. But it's still not clear about the desktopid.

@LBCrion
Copy link
Owner

LBCrion commented Feb 6, 2025 via email

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 7, 2025

desktop id allows you to add a menu item based on a .desktop

work!

@sfs-pra
Copy link
Contributor

sfs-pra commented Feb 7, 2025

Item {
    Label = GT("Application menu") + "%gtkhash"
    Action = "gtkhash"
    Tooltip = GT("Application menu")
    Index = 1
  }

Tooltip = GT("Application menu") - dont work : "missing "string" in tooltip"
Tooltip = "Application menu" - work

label "╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼╼" - Is there no other way to draw the line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants