I have been playing around with uBlue’s Bluefin-dx recently, and it’s been a pretty cool change of pace. Rebasing between Gnome and Plasma was pretty amazing (though there was some clean up required.)

However, one thing that I had been missing was sending video links to mpv using the tridactyl extention. Tridactyl adds vim-style keybindings to Firefox making moving around using the keyboard possible. Opening sites, adding bookmarks, and all of the regular things one does when on the internet can be done just from the keyboard.

It also has a native messenger that can interact with the host system and call other programs, send information to other programs, and many other things I never dabbled with. My main reason for fooling around with the native messenger was to grab a URL from youtube and open it up with mpv. Besides getting around youtube’s ads, it’s a better viewing experience in my opinion. I can move the window around, resume later, etc.

Since I was using uBlue, though, I was using the Firefox Flatpak. This meant Firefox didn’t have access to the host system by default and neither did the native messenger.

The work around involves making some changes to the Firefox flatpak and changing the mpvsafe alias that comes already set up in tridactyl.

Give the Firefox flatpak additional permissions#

First, Firefox needs access to the DBus session and some directories in the $HOME directory to use the native messenger and interact with the host system.

This can be done easily with Flatseal. In the Socket section, turn on D-Bus session bus access.

and then in the Filesystem > Other files section, add access to

  • ~/.local/share/tridactyl
  • ~/.local/bin/

Once Firefox can communicate with the local DBus session, the mpvsafe alias or bindings in tridactyl needs to be updated to send the url to mpv.

The default mpvsafe command that comes with tridactyl is

alias mpvsafe js -p tri.excmds.shellescape(JS_ARG).then(url => tri.excmds.exclaim_quiet('mpv ' + url))"

I tested this out in two different ways because I was flipping back and forth between using mpv installed via flatpak and and archlinux distrobox version of mpv. In both cases I ended up adding a version specific alias to make it easy to flip back and forth between the two.

MPV Flatpak Method#

If you’re using homebrew with uBlue it’s possible you can just use that and then you’re done. I had some issues with mpv in homebrew though, so I tried both the flatpak install and mpv installed in an archlinux distrobox container. The distrobox version is what I ended up sticking with, but that was mostly just to play around the distrobox.

Instead of editing this alias, I added one called mpvflatsafe for the using flatpak mpv and one call mpvboxsafe for using a distrobox install of mpv.

alias mpvflatsafe js -p tri.excmds.shellescape(JS_ARG).then(url => tri.excmds.exclaim_quiet('flatpak-spawn --host ~/.local/bin/mpvflat ' + url))

and this calls the bash script, mpvflat, below which is very simple

#!/usr/bin/env bsh
flatpak run io.mpv.Mpv "$@" 2>&1 > /dev/null

The Distrobox Method#

I’ve also started playing around with distrobox. Fedora, and to a lesser extent uBlue, recommend distrobox/toolbox as a way to install software that isn’t available as a flatpak. uBlue comes with distrobox already setup, so that’s what I went with. It seems that this is most commonly used for commandline programs, but I’ve been using the arch MPV install as well.

There is, of course, a way to get this method working using a distrobox version of mpv as well

alias mpvboxsafe js -p tri.excmds.shellescape(JS_ARG).then(url => tri.excmds.exclaim_quiet('flatpak-spawn --host distrobox-enter --name arch -- mpv ' + url))

Update the key binding#

Once these were setup I changed the default key binding to open videos, ;v, from

hint -W mpvflatsafe # Use this for flatpak
hint -W mpvboxsafe # Use this for distrobox

Once that is done you’re off the to races. Some may find it a little annoying to open a new window to watch videos. I like it though because I can close my browser and just have that running in the background while I work. This works for more than just videos as well. You could play podcasts, music, or anything else you can grab a URL for.