Skip to content
Dhruv9449Public

About

A tiny macOS default browser that opens every link in the right Chrome profile

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dvar

Dvar πŸšͺ

A tiny macOS default browser that opens every link in the right Chrome profile.

CI built with Swift macOS 13+ MIT License


Click a GitHub link in Slack and it opens in your Work profile. Click a YouTube link in Mail and it opens in Personal. Dvar sits between macOS and Chrome as your default browser, checks a short list of rules, and hands the link to the right profile.


Table of Contents



Key Features

  • πŸ”€ Route links by domain, path, or regex
  • πŸ’¬ Route links by the app they were clicked in (Slack, Mail, VS Code, ...)
  • πŸ–₯️ Native settings window to add, reorder and test rules
  • ⌨️ Full CLI for scripting and quick edits
  • πŸ§ͺ Live tester to see which profile a URL will open in before saving
  • πŸͺΆ Lightweight, a ~600 KB native binary with no dependencies, no Dock icon
  • 🌐 Works with Chrome, Chrome Beta/Dev/Canary, Chromium, Brave and Edge


Tech Stack and Dependencies



Setting-up and Installation

Requirements

  • macOS 13 or later
  • Xcode command line tools
xcode-select --install

Cloning repository

git clone git@github.com:Dhruv9449/Dvar.git

or

git clone https://github.com/Dhruv9449/Dvar.git

Installing

cd Dvar
make install

This installs ~/Applications/Dvar.app and links the dvar CLI into ~/.local/bin. If that folder isn't on your PATH, add it or run make install BIN_DIR=/usr/local/bin.

Dvar icon Dvar shows up in Spotlight and Finder with this icon. Opening it brings up the settings window; closing the window leaves it running quietly in the background.



Making Dvar the default browser

Click Make default in the settings window, or run:

dvar set-default-browser

macOS asks you to confirm the change.


Granting access to Chrome's profiles

Chrome keeps its profile list inside its own data folder, which macOS protects from other apps. Give Dvar access once:

  1. Open System Settings β†’ Privacy & Security β†’ Full Disk Access (the settings window has a button for this).
  2. Add Dvar from ~/Applications and turn it on.
  3. Click Retry in the settings window.

Dvar caches the profile list in ~/.config/dvar/, so it only needs to read it once. The build pins the app's signature to its bundle id, so the grant survives rebuilds.

Prefer not to grant access? Name profiles by their directory in rules instead (Profile 1). Open chrome://version in a profile and look at the end of Profile Path.



Usage

Settings window

Open Dvar from Spotlight, or run dvar ui. From there you can:

  • pick the browser and the profile for links that no rule matches
  • add, edit, delete and drag-reorder rules, choosing profiles from your real Chrome profiles and apps from the ones currently running
  • try a URL and see which profile it would open in, before saving
  • make Dvar the default browser

Invalid rules (an empty pattern or a broken regex) are flagged inline and block saving.


CLI

Use the following command for help -

dvar --help
dvar profiles
# DIRECTORY  NAME / EMAIL
# Default    Personal  <me@gmail.com>
# Profile 1  Work      <me@mycompany.com>

dvar default Personal
dvar add '*.mycompany.com' Work
dvar add github.com/mycompany @mycompany.com
dvar add Work --from Slack
dvar add '^https://docs\.google\.com/.*/d/1AbC' Work --regex

dvar rules
#   1. match *.mycompany.com  β†’  Work [Profile 1, me@mycompany.com]
#   2. match github.com/mycompany  β†’  Work [Profile 1, me@mycompany.com]
#   ...
#   default  β†’  Personal [Default, me@gmail.com]

dvar test https://github.com/mycompany/api/pull/42
# Work [Profile 1, me@mycompany.com]  via rule #2: match github.com/mycompany
Command What it does
dvar ui Open the settings window
dvar profiles List the browser's profiles
dvar rules List rules in match order
dvar add <pattern> <profile> [--regex] [--from <app>] [--at <n>] Add a rule
dvar remove <n> / dvar move <n> <m> Delete or reorder a rule
dvar default <profile>|--clear Profile for links no rule matches
dvar browser <name> Switch browser (chrome, chrome-beta, chrome-dev, chrome-canary, chromium, brave, edge)
dvar test <url> [--from <app>] Show which profile a URL would open in
dvar open <url> Route and open a URL now
dvar edit Open the config in $EDITOR
dvar status Paths, browser, and whether Dvar is the default browser
dvar set-default-browser Make Dvar the system default browser
dvar version Print the version

Writing rules

Rules are checked top to bottom and the first match wins. Every condition set on a rule must match.

Field Meaning
match Glob on the URL without its scheme. Without a / it matches the host only: *.mycompany.com covers mycompany.com and every subdomain, while notion.so covers only notion.so. With a / the host and path are matched separately, and github.com/mycompany also covers everything under it (but not github.com/mycompany-fork). Case-insensitive.
regex Case-insensitive regular expression searched in the full URL.
from The app the link was clicked in, by name (Slack) or bundle id (com.tinyspeck.slackmacgap).
profile A display name (Work), an email, @domain (any profile whose email is on that domain), or a directory (Profile 1).

If a profile can't be found, the link opens without one rather than making Chrome create a new empty profile.


Config file

Rules live in ~/.config/dvar/config.json and apply to the next click; nothing needs restarting. See config.example.json.

{
  "browser": "chrome",
  "default": "Personal",
  "rules": [
    { "match": "*.mycompany.com", "profile": "Work" },
    { "match": "github.com/mycompany", "profile": "@mycompany.com" },
    { "from": "Slack", "profile": "Work" }
  ]
}


How it works

Dvar.app is a background app (no Dock icon) registered for http and https. When macOS hands it a link, it reloads the config, picks a profile and starts the browser with --profile-directory=<dir> <url>. If the browser is already running, that hands the URL to the open window and exits. The app the link came from is read from the sender of the open-URL Apple Event.

Every routed link is logged to ~/Library/Logs/dvar.log, which is the first place to look if a link opens in the wrong profile.



Development

make build   # build/dvar
make test    # CLI tests against a fake config and Chrome profile list
make app     # build/Dvar.app

Dvar builds with swiftc in Swift 6 language mode; there is no Xcode project. The CLI tests run against a throwaway config and a fake Chrome profile list (DVAR_CONFIG and DVAR_LOCAL_STATE), so they never touch your real setup.


Project structure

Sources/
β”œβ”€β”€ Entry.swift                    Starts the app or the CLI
β”œβ”€β”€ Core/
β”‚   β”œβ”€β”€ Config.swift               Config file and rules
β”‚   β”œβ”€β”€ Matcher.swift              Picks the rule for a URL
β”‚   β”œβ”€β”€ Browser.swift              Supported browsers, profiles, launching
β”‚   β”œβ”€β”€ Router.swift               Decides, opens and logs each link
β”‚   β”œβ”€β”€ DefaultBrowser.swift       Reads and sets the system default browser
β”‚   β”œβ”€β”€ Log.swift                  ~/Library/Logs/dvar.log
β”‚   └── Dvar.swift                 Version, bundle id, file paths, errors
β”œβ”€β”€ App/
β”‚   β”œβ”€β”€ AppDelegate.swift          Receives links from macOS
β”‚   β”œβ”€β”€ SettingsModel.swift        State behind the settings window
β”‚   β”œβ”€β”€ SettingsView.swift         SwiftUI settings window
β”‚   └── SettingsWindowController.swift
└── CLI/
    β”œβ”€β”€ CLI.swift                  dvar commands
    └── Arguments.swift            Argument parsing


Uninstalling

make uninstall

Then pick another default browser in System Settings β†’ Desktop & Dock.



License

Copyright Β© 2026 Dhruv9449
MIT License



Developer

Dhruv Shah

Dhruv Shah

GitHub LinkedIn Email

Made with ❀️ by Dhruv Shah

About

A tiny macOS default browser that opens every link in the right Chrome profile

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages