marvinkreis / rofi-file-browser-extended

Use rofi to quickly open files
MIT License
242 stars 15 forks source link

How to use mineinfo.cache for associated commands? #50

Open erwin opened 1 year ago

erwin commented 1 year ago

Most desktop environments maintain ~/.local/share/applications/mimeinfo.cache and /usr/share/applications/mimeinfo.cache to track which applications are valid for each file type.

For example, when I right click ~/windows-10.conf, image

It's the same as if I run:

grep -h $(xdg-mime query filetype ~/windows-10.conf) \
  ~/.local/share/applications/mimeinfo.cache \
  /usr/share/applications/mimeinfo.cache \
  | sed -e 's/=\|\;/\n/g'

I get:

text/plain
nvim.desktop
okularApplication_txt.desktop
org.kde.kate.desktop
org.kde.kwrite.desktop
org.kde.mobile.okular_txt.desktop
vim.desktop

Let's say we picked to execute it with nvim.desktop, we could use:

gio launch \
  $(find ~/.local/share/applications /usr/share/applications \
  | grep nvim.desktop) ~/windows-10.conf

How would you recommend working with mimeinfo.cache to add this list of associated commands to oc-cmd once a file has been selected? Or if that's not possible, is there a way you recommend using this list?

Or do you think it's better to just add the most useful commands to ~/.config/rofi/file-browser with oc-cmd?

Kind of a related question, how do you recommend handling file rename and file move with oc-cmd? Ideally I could have the file-browser-extended UI stay up, and hitting Esc would just back out step by step... And the actual file name could be entered into the rofi UI.

This browser is awesome! I've been looking for something like this for years. So glad I found it (and more importantly that you built it!)