sfwbar icon indicating copy to clipboard operation
sfwbar copied to clipboard

Ignore file for appmenu

Open napcok opened this issue 1 year ago • 46 comments

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.

napcok avatar Jan 01 '25 12:01 napcok

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

sfs-pra avatar Jan 01 '25 12:01 sfs-pra

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)

napcok avatar Jan 01 '25 13:01 napcok

OnlyShowIn= NotShowIn=

sfs-pra avatar Jan 01 '25 14:01 sfs-pra

OnlyShowIn= NotShowIn=

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

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

napcok avatar Jan 01 '25 14:01 napcok

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.

LBCrion avatar Jan 01 '25 16:01 LBCrion

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.

napcok avatar Jan 01 '25 16:01 napcok

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.

LBCrion avatar Jan 02 '25 18:01 LBCrion

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?

napcok avatar Jan 02 '25 19:01 napcok

You can add them to the unit function in your config. I.e. copy sfwbar.config from /usr/share/sfwbar to $HOME/.config/sfwbar

Then edit it and add to Function("SfwBarInit") { AppMenuItemTop "MyItem", "firefox" }

On Thu, 2 Jan 2025, 19:30 Daniel Napora, @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2568269100, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFA4MCC6BZJ43ZNWUJL2IWHVPAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRYGI3DSMJQGA . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Jan 02 '25 19:01 LBCrion

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

napcok avatar Jan 02 '25 21:01 napcok

I updated the functionality for the manually added items to be sorted by the order in which they were added.

For the filtering functionality, can you try the latest git please and if it still doesn't work, run "sfwbar -d -g appmenu" please and post it's output?

On Thu, Jan 2, 2025 at 9:45 PM Daniel Napora @.***> wrote:

It works, partially. sfwbarmenu2.png (view on web) https://github.com/user-attachments/assets/ca5114ec-07af-461b-8c18-0cbeaf6e0765 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" }

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2568419356, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFFR3UX2ECPTX5CWXVL2IWXQPAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRYGQYTSMZVGY . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Jan 03 '25 07:01 LBCrion

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

sfs-pra avatar Jan 03 '25 08:01 sfs-pra

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

sfwbarmenu3

napcok avatar Jan 03 '25 08:01 napcok

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

LBCrion avatar Jan 03 '25 21:01 LBCrion

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)

napcok avatar Jan 04 '25 00:01 napcok

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"

sfs-pra avatar Jan 04 '25 06:01 sfs-pra

I think we need to think about better way of configuring the menu items. Originally these were envisioned as simple constructs. You declare a menu, stick some items into it with titles and actions attached. Then I added icons using the fvwm % notation. Then I added I's so items could be deleted.

I don't think sticking more optional parameters into an Item() keyword makes sense. We'll end up with an uncertain grammar (i.e. if you have 3 parameters, if the last one an id or a tooltip?). It may also be worthwhile to be able to build an item from a .desktop entry and override some parameters (i.e. take an icon, translated name, but add some parameters

On Sat, Jan 4, 2025 at 6:49 AM sfs-pra @.***> wrote:

I confirm, it works as it should

sfwbar-git r1753.701626d - yes!

Will work on this later

ok

Now “tooltip” is not in AppMenuItemBottom

AppMenuItemTop GT("File manager", "sfwbar-ext") + "%spacefm%tooltip", "spacefm" ?

Besides it would be good to have a separator

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

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2570355924, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFCHDNBNXJXXW7VSH7L2I576FAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZQGM2TKOJSGQ . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Jan 04 '25 19:01 LBCrion

Eek. my e-mail has gone beserk and sent the message before I finished writing it. Thinking a user may want to add some parameters to a command line leaving the rest of the parameters inherited from the desktop entry.

On Sat, Jan 4, 2025 at 7:33 PM Lev Babiev @.***> wrote:

I think we need to think about better way of configuring the menu items. Originally these were envisioned as simple constructs. You declare a menu, stick some items into it with titles and actions attached. Then I added icons using the fvwm % notation. Then I added I's so items could be deleted.

I don't think sticking more optional parameters into an Item() keyword makes sense. We'll end up with an uncertain grammar (i.e. if you have 3 parameters, if the last one an id or a tooltip?). It may also be worthwhile to be able to build an item from a .desktop entry and override some parameters (i.e. take an icon, translated name, but add some parameters

On Sat, Jan 4, 2025 at 6:49 AM sfs-pra @.***> wrote:

I confirm, it works as it should

sfwbar-git r1753.701626d - yes!

Will work on this later

ok

Now “tooltip” is not in AppMenuItemBottom

AppMenuItemTop GT("File manager", "sfwbar-ext") + "%spacefm%tooltip", "spacefm" ?

Besides it would be good to have a separator

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

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2570355924, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFCHDNBNXJXXW7VSH7L2I576FAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZQGM2TKOJSGQ . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Jan 04 '25 19:01 LBCrion

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

ffs-akl avatar Jan 06 '25 03:01 ffs-akl

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

in startmenu.widget

sfs-pra avatar Jan 06 '25 05:01 sfs-pra

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.

LBCrion avatar Jan 15 '25 08:01 LBCrion

Is this expected? swappy-20250115-210211

ffs-akl avatar Jan 15 '25 14:01 ffs-akl

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

LBCrion avatar Jan 16 '25 18:01 LBCrion

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 avatar Jan 25 '25 18:01 sfs-pra

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

sfs-pra avatar Jan 26 '25 09:01 sfs-pra

I added support for HIdden= to the latest git version, but NoDisplay should have been supported already. Can you check if either/both of these still don't work.

On Sun, Jan 26, 2025 at 9:11 AM sfs-pra @.***> wrote:

sfwbar-git-r1794.1ed698b They don't work Hidden= NoDisplay= https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2614287433, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFE325ZPHESXA2H2NXL2MSRDFAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMJUGI4DONBTGM . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Jan 27 '25 07:01 LBCrion

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 https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2591909842 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.

LBCrion avatar Jan 27 '25 08:01 LBCrion

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 avatar Jan 27 '25 09:01 sfs-pra

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

sfs-pra avatar Jan 29 '25 10:01 sfs-pra

Looks like gio is being pedantic and doesn't handle trailing semicolons for these keys. I added a workaround in the latest git version. Can you check if these work as expected now?

On Wed, Jan 29, 2025 at 10:39 AM sfs-pra @.***> wrote:

sfwbar-git-r1795.ff14406 Hidden= NoDisplay= https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html 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

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/303#issuecomment-2621268055, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFH4ONINORVMLQST6TD2NCVUPAVCNFSM6AAAAABUOSFJUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMRRGI3DQMBVGU . You are receiving this because you commented.Message ID: @.***>

LBCrion avatar Feb 01 '25 15:02 LBCrion