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 · 20 comments
Open

Ignore file for appmenu #303

napcok opened this issue Jan 1, 2025 · 20 comments

Comments

@napcok
Copy link

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

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