Zren / plasma-hud

Provides a way to run menubar commands in KDE Plasma through rofi, much like the Unity 7 Heads-Up Display (HUD).
GNU General Public License v2.0
235 stars 9 forks source link

Hide DBusMenuFile Text in Entries #34

Closed ihsanauliaa closed 2 years ago

ihsanauliaa commented 4 years ago

Hello,

I just recently started using plasma-hud when I realized that when using any JetBrains' IDE, plasma-hud shows "DBusMenuFile" for each menu entry like in the picture below: alt text

Is there a way to hide those "DBusMenuFile" text? I think it happens because JetBrains' IDE are based on Java so that it doesn't really play nicely with dbusmenu etc.

Thanks in advance.

Zren commented 4 years ago

Add result = result.replace('DBusMenuFile' + PATHSEPERATOR, '') to the format_path function. Restart plasma-hud. Does it work?

https://github.com/Zren/plasma-hud/blob/master/usr/lib/plasma-hud/plasma-hud#L99

ihsanauliaa commented 4 years ago

It does work! Thank you! But I realized that I need to replace "DBusMenuFile" with "File", "DBusMenuEdit" with "Edit" etc, rather than to hide them. I made a quick and dirty fix for this problem.

def format_path(path):
    #logging.debug('Path:%s', path)
    result = path.replace(PATHSEPERATOR, '', 1)
    result = result.replace('Root' + PATHSEPERATOR, '')
    result = result.replace('Label Empty' + PATHSEPERATOR, '')
    result = result.replace('_', '')
    result = result.replace('DBusMenuFile', 'File')
    result = result.replace('DBusMenuEdit', 'Edit')
    result = result.replace('DBusMenuView',  'View')
    result = result.replace('DBusMenuNavigate', 'Navigate')
    result = result.replace('DBusMenuCode', 'Code')
    result = result.replace('DBusMenuRefactor', 'Refactor')
    result = result.replace('DBusMenuRun', 'Run')
    result = result.replace('DBusMenuTools', 'Tools')
    result = result.replace('DBusMenuVCS', 'VCS')
    result = result.replace('DBusMenuWindow', 'Window')
    result = result.replace('DBusMenuHelp', 'Help')
    # return result.replace(PATHARROW, u'\u0020\u0020\u00BB\u0020\u0020')
    return result

I don't really know how to fix it elegantly. It will be greatly appreciated if you find another way to fix this problem properly.

Zren commented 4 years ago

How did you even export the menu to the OS? Is there a specific package I need to install?

2020-10-08___14-49-03

ihsanauliaa commented 4 years ago

I am sorry but what do you mean by "export the menu to the OS"?

Zren commented 4 years ago

Can you still reproduce the bug? If you removed/comment out the .replace() calls you added in format_path() then restart plasma-hud, does it still show DBusMenuFile which you trigger plasma-hud?

How did you install GoLand? I downloaded a GoLand-2020.2.3.tar.gz and ran sh ./bin/goland.sh.

Zren commented 4 years ago

What I meant by export the menu is that as you can see in the screenshot, GoLand displays the menu in the application's window. Where as Konsole has the app menu button in the titlebar. When testing, the GoLand menu was not "exported" to the DBus, so the Operating System could not display the menu in the titlebar.

ihsanauliaa commented 4 years ago

I can't reproduce the bug at the moment because of a bug/regression in all Jetbrain's IDE that resulted in the global menu not working so that plasma-hud can't also be activated image

All Jetbrain's IDE(s) from version 2020.2.1 upwards have this regression IIRC so unfortunately until they resolve this problem, we really can't test a fix

Zren commented 4 years ago

Ah that makes sense. Ping me when the bug is fixed upstream so I can test my regex code.

ihsanauliaa commented 4 years ago

Will do!

louix commented 2 years ago

The Jetbrains IDEs show the global menu for me today (well, Webstorm at least!), so I'm assuming the upstream bug is fixed. Can I help test anything?

image

About exporting the menu to the OS, on Arch these packages may be required:

libdbusmenu-gtk3
libdbusmenu-glib
appmenu-gtk-module
Zren commented 2 years ago

Try applying this patch: https://github.com/Zren/plasma-hud/commit/981b1fde410d0ee8a47478633d0958b8d6f9562f

louix commented 2 years ago

Looks like it solves it! image