browser-ruler/sample-config.hcl

65 lines
2.0 KiB
HCL

default_browser_cmd = ["firefox"]
# The rule label doesn't matter
rule "Flatpak Chromium" {
# Command and args, like with default
browser_cmd = ["flatpak", "run", "org.chromium.Chromium"]
# match evaluates an expr that should result in a MatchFunc where the signature
# is MatchFunc = func(url.URL) bool
# There are several functions provided that contain common rules and help construct this.
# provided are:
# matchHostname(...string) MatchFunc
# matchHostRegexp(...string) MatchFunc
# matchRegexp(...string) MatchFunc
# matchAny(...MatchFunc) MatchFunc
#
# Note that when using regex, any escapes need to be doubled. Once to escape the string
# and a second time to escape the regexp char. So a literal `.` is represented as `\\.`
#
# For writing custom rules using expr, you can use the following two variables:
# hostname: the URL hostname
# fullUrl: the full string of the URL
# url: the Go url.URL struct that is being called
#
# When using those, you can turn them into a MatchFunc using
# MatchFunc(bool) MatchFunc
#
# For example:
# MatchFunc(hostname endsWith "example.com")
# is equivalent to:
# matchHostRegexp(".*\\.example\\.com$")
match = "matchHostname('google.com', 'youtube.com')"
}
rule "Firefox Private" {
browser_cmd = ["firefox", "--private-window"]
# For more complex rules, rules can span multiple lines using EOF syntax
match = <<EOF
matchAny(
matchHostname('facebook.com'),
MatchFunc(hostname == 'instagram.com')
)
EOF
}
# Some additional sample browser commands with a match func that will never match
rule "Firefox New Window" {
browser_cmd = ["firefox", "--new-window"]
match = "MatchFunc(false)"
}
rule "Chromium" {
browser_cmd = ["chromium-browser"]
match = "MatchFunc(false)"
}
rule "Chromium New Window" {
browser_cmd = ["chromium-browser", "--new-window"]
match = "matchNever"
}
rule "Chromium Incognito Window" {
browser_cmd = ["chromium-browser", "--incognito"]
match = "matchNever"
}