Melange

Omar Rizwan's TabFS is always humming in my mind — browser tabs as a file system, the state of a tab always reflected in the files inside a folder on your laptop. What does that give you? Omar answers this:

[N]ow you can apply all the existing tools on your computer that already know how to deal with files — terminal commands, scripting languages, point-and-click explorers, etc — and use them to control and communicate with your browser.

Now you don't need to code up a browser extension from scratch every time you want to do anything. You can write a script that talks to your browser in, like, a melange of Python and bash, and you can save it as a single ordinary file that you can run whenever, and it's no different from scripting any other part of your computer.

A script that talks to your browser in a melange. All I can think of is digital bricolage when I read this, and honestly that's what scripting with TabFS is like.

I can relay an example to you from the other day. For a while I wanted to have a website blocker of sorts in order to focus on writing. But here's the thing — I either need to download a browser extension for a SaaS solution like Freedom or stand up a web proxy like Squid on my laptop or a Raspberry Pi. Neither option gels with me. Where's the middle ground? Kludging together some Bash together that sorta does the same thing1 That's at least where I'd have the most fun.

It's fascinating how the TabFS paradigm of files & folders changes how you approach the problem of a website blocker. Instead of focusing on a URL to block a site, you key in on the title of files. Instead of blocking a website, you need to remove the file of that tab. Instead of having a browser extension or server running, you have a script in the background going on an infinite “while” loop.

Below is a first pass on this website “blocker” idea:

#!/bin/bash

# Website "blocker" using TabFS

# TabFS folder — using the by-title subfolder
dir="/Users/cjeller/Documents/TabFS/fs/mnt/tabs/by-title"

# List of websites to block
block_list="Twitter YouTube"

while true
do
  # Grab the tabs
  tabs=$(ls $dir)
  for tab in $tabs 
    do
    # Go through the sites in the block list
    for site in $block_list
      do 
        # If there's a match with the site and the tab, close the tab
        if [[ "$tab" == *"$site"* ]]; then
          rm "$dir/$tab"
        fi
      done
    done
  # Wait 10 seconds before going through the process again & again & again...
  sleep 10
done

It could definitely be refined, but the script works just fine for me in its current state. Hell, I'm using it right now so that I don't get sidetracked while writing this. But that's the beauty of something like TabFS, where embracing the melange on your computer can go a long way.