Opening CSVs with VisiData in Tmux, from the Firefox Flatpak App
AJ Kerrigan
Posted on February 18, 2023
I use VisiData as my default app for CSVs. There are a couple moving parts, and I had ignored the Firefox/Flatpak piece until recently. While this all feels very specific to my usage patterns, some of these bits were not at all obvious to me at first. So maybe something in here will be a useful reference to someone else or future me.
The Flatpak Wrinkle
I had a mostly-working setup (details) that opened CSVs in VisiData just fine, until I started using the Firefox Flatpak app. I kept thinking "I'll fix this someday..." and then a comment on a GitHub issue reminded me about it.
So the keys to fix my Flatpak setup were...
Create a Flatpak-Specific Desktop Entry
I needed to copy my existing VisiData.desktop
file to ~/.var/app/org.mozilla.firefox/data/applications/VisiData.desktop
and tweak the Exec
line to use flatpak-spawn
:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/usr/bin/bash -c "flatpak-spawn --host i3-focus-or-launch.sh "kitty" "kitty" && flatpak-spawn --host /usr/bin/tmux new-window -n vd ~/.local/bin/vd %U"
MimeType=application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/msexcel;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroEnabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.template.macroEnabled.12;application/vnd.ms-excel.sheet.binary.macroEnabled.12;text/csv;application/x-dbf;text/spreadsheet;application/csv;application/excel;application/tab-separated-values;application/vnd.lotus-1-2-3;application/vnd.oasis.opendocument.chart;application/vnd.oasis.opendocument.chart-template;application/x-dbase;application/x-dos_ms_excel;application/x-excel;application/x-msexcel;application/x-ms-excel;application/x-quattropro;application/x-123;text/comma-separated-values;text/tab-separated-values;text/x-comma-separated-values;text/x-csv;application/vnd.oasis.opendocument.spreadsheet-flat-xml;application/vnd.ms-works;application/clarisworks;application/x-iwork-numbers-sffnumbers;application/x-starcalc;
Name=VisiData
Icon=~/code/visidata.org/static/vd-rtd.png
Let Firefox Talk to the System Bus
flatpak override --user --talk-name org.freedesktop.Flatpak org.mozilla.firefox
Tell Firefox to Use VisiData as a Default App
In ~/.var/app/org.mozilla.firefox/config/mimeapps.list
:
[Default Applications]
...snip...
text/csv=VisiData.desktop
application/csv=VisiData.desktop
application/x-csv=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet-flat-xml=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet-template=VisiData.desktop
application/vnd.sun.xml.calc=VisiData.desktop
application/vnd.sun.xml.calc.template=VisiData.desktop
application/msexcel=VisiData.desktop
application/vnd.ms-excel=VisiData.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet=VisiData.desktop
application/vnd.ms-excel.sheet.macroenabled.12=VisiData.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.template=VisiData.desktop
application/vnd.ms-excel.template.macroenabled.12=VisiData.desktop
application/vnd.ms-excel.sheet.binary.macroenabled.12=VisiData.desktop
application/x-dbf=VisiData.desktop
text/spreadsheet=VisiData.desktop
[Added Associations]
The Setup Outside of Flatpak
I'm running Regolith Desktop 2.1 on Ubuntu 22.04, but this should generalize to Ubuntu+Gnome pairings in the same version neighborhood.
Desktop Entry
I have a file like this at ~/.local/share/applications/VisiData.desktop
:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/usr/bin/sh -c "i3-focus-or-launch.sh kitty kitty && /usr/bin/tmux new-window -n vd ~/.local/bin/vd %U"
MimeType=application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/msexcel;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroEnabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.template.macroEnabled.12;application/vnd.ms-excel.sheet.binary.macroEnabled.12;text/csv;application/x-dbf;text/spreadsheet;application/csv;application/excel;application/tab-separated-values;application/vnd.lotus-1-2-3;application/vnd.oasis.opendocument.chart;application/vnd.oasis.opendocument.chart-template;application/x-dbase;application/x-dos_ms_excel;application/x-excel;application/x-msexcel;application/x-ms-excel;application/x-quattropro;application/x-123;text/comma-separated-values;text/tab-separated-values;text/x-comma-separated-values;text/x-csv;application/vnd.oasis.opendocument.spreadsheet-flat-xml;application/vnd.ms-works;application/clarisworks;application/x-iwork-numbers-sffnumbers;application/x-starcalc;
Name=VisiData
Icon=~/code/visidata.org/static/vd-rtd.png
That Exec
string is pretty specific to my workflow, but it:
- Focuses my terminal
- Creates a new tmux window named
vd
- Opens the file/URL with VisiData in that window
The list of MIME types was copy/pasted from Libre Office Calc, since this started with "anywhere Calc is trying to open, use VisiData instead".
VisiData as a Default Application
I update my ~/.config/mimeapps.list
file so my desktop environment knows to use VisiData for a bunch of stuff:
[Added Associations]
...snip...
text/csv=VisiData.desktop;
application/csv=VisiData.desktop;
text/x-csv=VisiData.desktop;
text/spreadsheet=VisiData.desktop;
[Default Applications]
...snip...
text/csv=VisiData.desktop
application/csv=VisiData.desktop
text/x-csv=VisiData.desktop
text/spreadsheet=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet-flat-xml=VisiData.desktop
application/vnd.oasis.opendocument.spreadsheet-template=VisiData.desktop
application/vnd.sun.xml.calc=VisiData.desktop
application/vnd.sun.xml.calc.template=VisiData.desktop
application/msexcel=VisiData.desktop
application/vnd.ms-excel=VisiData.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet=VisiData.desktop
application/vnd.ms-excel.sheet.macroenabled.12=VisiData.desktop
application/vnd.openxmlformats-officedocument.spreadsheetml.template=VisiData.desktop
application/vnd.ms-excel.template.macroenabled.12=VisiData.desktop
application/vnd.ms-excel.sheet.binary.macroenabled.12=VisiData.desktop
application/x-dbf=VisiData.desktop
text/spreadsheet=VisiData.desktop
Again, this is mostly yoinking Libre Office Calc-related entries out of /usr/share/applications/gnome-mimeapps.list
and overriding them to target VisiData for my user.
Posted on February 18, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.