LBCrion / sfwbar

S* Floating Window Bar
GNU General Public License v3.0
278 stars 17 forks source link

Include flatpak apps in startmenu.widget #109

Closed Flrian closed 1 year ago

Flrian commented 1 year ago

If its not too complicated, would it be possible to include apps installed via flatpak in the startmenu widget?

LBCrion commented 1 year ago

I think this is a matter of checking the flatpack desktop entry directory. I don't use flatpack myself, so will need some help. Can you please check: 1) the value of $XDG_DATA_DIRS variable on your system. 2) the contents of /var/lib/flatpak/exports/share/applications directory?

On Fri, 25 Aug 2023, 12:35 Flrian, @.***> wrote:

If its not too complicated, would it be possible to include apps installed via flatpak in the startmenu widget?

— Reply to this email directly, view it on GitHub https://github.com/LBCrion/sfwbar/issues/109, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASHPFFBH77NKYTLR2M47COTXXBWWZANCNFSM6AAAAAA36H3IK4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Flrian commented 1 year ago
❯ printenv XDG_DATA_DIRS
/home/florian/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
I install my flatpaks as user instead of system wide, so here is that instead ``` ❯ ls -lah ~/.local/share/flatpak/exports/share/applications total 108K drwxr-xr-x 1 florian florian 1.6K Aug 25 11:54 . drwxr-xr-x 1 florian florian 92 Mar 21 17:05 .. lrwxrwxrwx 1 florian florian 107 Aug 20 13:59 com.discordapp.Discord.desktop -> ../../../app/com.discordapp.Discord/current/active/export/share/applications/com.discordapp.Discord.desktop lrwxrwxrwx 1 florian florian 125 Apr 22 22:53 com.github.johnfactotum.Foliate.desktop -> ../../../app/com.github.johnfactotum.Foliate/current/active/export/share/applications/com.github.johnfactotum.Foliate.desktop lrwxrwxrwx 1 florian florian 115 Jul 8 01:14 com.github.tchx84.Flatseal.desktop -> ../../../app/com.github.tchx84.Flatseal/current/active/export/share/applications/com.github.tchx84.Flatseal.desktop lrwxrwxrwx 1 florian florian 117 Aug 15 18:03 com.github.wwmm.easyeffects.desktop -> ../../../app/com.github.wwmm.easyeffects/current/active/export/share/applications/com.github.wwmm.easyeffects.desktop lrwxrwxrwx 1 florian florian 105 Jun 20 21:34 com.obsproject.Studio.desktop -> ../../../app/com.obsproject.Studio/current/active/export/share/applications/com.obsproject.Studio.desktop lrwxrwxrwx 1 florian florian 99 May 20 14:58 com.spotify.Client.desktop -> ../../../app/com.spotify.Client/current/active/export/share/applications/com.spotify.Client.desktop lrwxrwxrwx 1 florian florian 107 Aug 22 14:18 com.usebottles.bottles.desktop -> ../../../app/com.usebottles.bottles/current/active/export/share/applications/com.usebottles.bottles.desktop lrwxrwxrwx 1 florian florian 135 Apr 11 18:45 io.github.celluloid_player.Celluloid.desktop -> ../../../app/io.github.celluloid_player.Celluloid/current/active/export/share/applications/io.github.celluloid_player.Celluloid.desktop lrwxrwxrwx 1 florian florian 109 May 2 18:06 io.github.seadve.Mousai.desktop -> ../../../app/io.github.seadve.Mousai/current/active/export/share/applications/io.github.seadve.Mousai.desktop lrwxrwxrwx 1 florian florian 123 Aug 8 12:55 io.gitlab.news_flash.NewsFlash.desktop -> ../../../app/io.gitlab.news_flash.NewsFlash/current/active/export/share/applications/io.gitlab.news_flash.NewsFlash.desktop -rw-r--r-- 1 florian florian 19K Aug 25 11:54 mimeinfo.cache lrwxrwxrwx 1 florian florian 105 May 2 18:06 org.gnome.Connections.desktop -> ../../../app/org.gnome.Connections/current/active/export/share/applications/org.gnome.Connections.desktop lrwxrwxrwx 1 florian florian 109 Aug 16 14:59 org.keepassxc.KeePassXC.desktop -> ../../../app/org.keepassxc.KeePassXC/current/active/export/share/applications/org.keepassxc.KeePassXC.desktop lrwxrwxrwx 1 florian florian 122 Aug 25 11:54 org.libreoffice.LibreOffice.base.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.base.desktop lrwxrwxrwx 1 florian florian 122 Aug 25 11:54 org.libreoffice.LibreOffice.calc.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.calc.desktop lrwxrwxrwx 1 florian florian 117 Aug 25 11:54 org.libreoffice.LibreOffice.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.desktop lrwxrwxrwx 1 florian florian 122 Aug 25 11:54 org.libreoffice.LibreOffice.draw.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.draw.desktop lrwxrwxrwx 1 florian florian 125 Aug 25 11:54 org.libreoffice.LibreOffice.impress.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.impress.desktop lrwxrwxrwx 1 florian florian 122 Aug 25 11:54 org.libreoffice.LibreOffice.math.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.math.desktop lrwxrwxrwx 1 florian florian 124 Aug 25 11:54 org.libreoffice.LibreOffice.writer.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.writer.desktop lrwxrwxrwx 1 florian florian 128 Aug 25 11:54 org.libreoffice.LibreOffice.xsltfilter.desktop -> ../../../app/org.libreoffice.LibreOffice/current/active/export/share/applications/org.libreoffice.LibreOffice.xsltfilter.desktop lrwxrwxrwx 1 florian florian 101 Aug 18 12:23 org.mozilla.firefox.desktop -> ../../../app/org.mozilla.firefox/current/active/export/share/applications/org.mozilla.firefox.desktop lrwxrwxrwx 1 florian florian 101 Aug 20 21:28 org.pipewire.Helvum.desktop -> ../../../app/org.pipewire.Helvum/current/active/export/share/applications/org.pipewire.Helvum.desktop ```

Let me know if you need anything else!

LBCrion commented 1 year ago

Hi @Flrian, I updated the startmenu.widget to respect the XDG_DATA_DIRS variable. Can you try the latest git version to see if it correctly handles the flatpak applications for you now?

Flrian commented 1 year ago

It does not. I assume its because they are symlinks and get linked there from the application specific folder (e.g. ~/.local/share/flatpak/app/com.github.wwmm.easyeffects/current/active/export/share/applications/com.github.wwmm.easyeffects.desktop)?

Flrian commented 1 year ago

Also it would probably be a good idea to add XDG_DATA_HOME and ~/.local/share/ if that is not set, I have a bunch of .desktop files there that don't get shown either atm.

LBCrion commented 1 year ago

Symlinks shouldn't prevent this from working. Can you please check if sfwbar is picking up the updated widget from git? You can by running sfwbar -d -g startmenu.widget and then check if the widget file it loads contains XDG_DATA_DIRS. It should be easy enough to get XDG_DATA_HOME working as well once we get this one sorted.

Flrian commented 1 year ago

Should be using the updated one.

LBCrion commented 1 year ago

That's odd. Can you try running the python script on it's own to see if there are any issues in it?

test.txt

Flrian commented 1 year ago
❯  python test.txt
MenuClear('Menugen_Applications')
MenuClear('Menugen_System')
MenuClear('Menugen_Graphics')
MenuClear('Menugen_Accessories')
MenuClear('Menugen_Office')
MenuClear('Menugen_Internet')
MenuClear('Menugen_Other')
Menu('Menugen_Accessories') { Item('Files%org.gnome.Nautilus',Exec 'nautilus') }
Menu('Menugen_Accessories') { Item('VSCode%vscode',Exec '/usr/bin/vscode') }
Menu('Menugen_Applications') { SubMenu('Accessories%applications-accessories','Menugen_Accessories') }
Menu('Menugen_Applications') { SubMenu('Graphics%applications-graphics','Menugen_Graphics') }
Menu('Menugen_Applications') { SubMenu('Internet%applications-internet','Menugen_Internet') }
Menu('Menugen_Applications') { SubMenu('Office%applications-office','Menugen_Office') }
Menu('Menugen_Applications') { SubMenu('Other%applications-other','Menugen_Other') }
Menu('Menugen_Applications') { SubMenu('System%applications-system','Menugen_System') }
Menu('Menugen_Graphics') { Item('FontForge%org.fontforge.FontForge',Exec 'fontforge') }
Menu('Menugen_Graphics') { Item('MuPDF%new-mupdf-icon',Exec 'mupdf') }
Menu('Menugen_Internet') { Item('Steam%steam',Exec 'steam') }
Menu('Menugen_Office') { Item('Zathura%org.pwmt.zathura',Exec 'zathura') }
Menu('Menugen_Other') { Item('Browse C: Drive%folder-wine',Exec 'xdg-open') }
Menu('Menugen_Other') { Item('Configure Wine%wine-winecfg',Exec 'winecfg') }
Menu('Menugen_Other') { Item('Notepad%wine-notepad',Exec 'notepad') }
Menu('Menugen_Other') { Item('Uninstall Wine Software%wine-uninstaller',Exec 'wine') }
Menu('Menugen_System') { Item('Avahi Zeroconf Browser%network-wired',Exec '/usr/bin/avahi-discover') }
Menu('Menugen_System') { Item('Foot Client%foot',Exec 'footclient') }
Menu('Menugen_System') { Item('Foot Server%foot',Exec 'foot') }
Menu('Menugen_System') { Item('Foot%foot',Exec 'foot') }
Menu('Menugen_System') { Item('Htop%htop',Exec 'htop') }
Menu('Menugen_System') { Item('Manage Printing%cups',Exec '/usr/bin/xdg-open') }
Menu('Menugen_System') { Item('nvtop%nvtop',Exec 'nvtop') }

Just in case its something to do with the flatpak desktop files themselves, here is for example the Discord one:

[Desktop Entry]
Name=Discord
StartupWMClass=discord
Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone.
GenericName=Internet Messenger
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=discord com.discordapp.Discord
Icon=com.discordapp.Discord
Type=Application
Categories=Network;InstantMessaging;
Path=/usr/bin
X-Flatpak-Tags=proprietary;
X-Flatpak=com.discordapp.Discord
LBCrion commented 1 year ago

Ok, I see the issue. flatpack uses '=' in the Exec parameters and this has been messing with tag parsing. It should now be fixed in git. Would you mind giving it another try?

Flrian commented 1 year ago

I do see them now! But clicking on a flatpak entry doesn't open the application.

sfwbar -d with startmenu.widget

12:09:12.75 image: com.discordapp.Discord @ 14 x 16
12:09:12.75 image: com.discordapp.Discord @ 14 x 16
12:09:13.20 expr: ""/usr/bin/flatpak"" = "/usr/bin/flatpak" (vstate: 0)
12:09:13.20 action: Exec '(null)', '/usr/bin/flatpak', widget=(nil), win=14 from '(null)', '"/usr/bin/flatpak"'
12:09:13.20 module: checking action `exec`
12:09:13.20 module: calling action `exec`

vs custom menu with the exec line from the desktop file as entry

12:16:13.59 expr: ""/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=discord com.discordapp.Discord"" = "/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=discord com.discordapp.Discord" (vstate: 0)
12:16:13.59 action: Exec '(null)', '/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=discord com.discordapp.Discord', widget=0x5635905a1a00, win=14 from '(null)', '"/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=discord com.discordapp.Discord"'
12:16:13.59 module: checking action `exec`
12:16:13.59 module: calling action `exec`
12:16:14.32 app_id: 'discord', title ''
LBCrion commented 1 year ago

This should now be fixed with proper Exec command line parsing. I also added handling of XDG_CONFIG_HOME to tidy things up. Hopefully the current git should work.

Flrian commented 1 year ago

It does work great, thank you so much for taking the time and implementing this!