Chromium-based Browsers: Setting Custom Quick Searches with Kotlin URLs
Chromium-based browsers, such as Google Chrome and Microsoft Edge, allow users to customize their search experience by setting up quick searches. These quick searches enable users to search specific websites directly from the browser's address bar, using a custom search URL syntax.
Custom Search URL Syntax
The custom search URL syntax for Chromium-based browsers is as follows:
http://domain.tld/search?term=%In this syntax, "%" is a placeholder for the search term that the user wants to look up on the specified website. For example, if a user wants to search for "Chromium" on the www.example.com website, they would enter the following URL in their browser's address bar:
http://www.example.com/search?term=ChromiumSetting Up Custom Quick Searches with Kotlin
Kotlin is a statically-typed programming language that runs on the Java virtual machine and can be used to automate various tasks, including setting up custom quick searches in Chromium-based browsers. To set up a custom quick search using Kotlin, you can use the following code:
fun setCustomQuickSearch(searchUrl: String, keyword: String) {
val cmd = "open -na \"Google Chrome\" --args --enable-features=CustomSearchURLs$searchUrl|$keyword "
Runtime.getRuntime().exec(cmd)
}In this code, the setCustomQuickSearch() function takes two arguments: the custom search URL (searchUrl) and the keyword (keyword) that will trigger the quick search. The function then uses the open command to launch Google Chrome with the --enable-features=CustomSearchURLs flag, which enables custom search URLs, and the --args flag, which allows you to pass additional arguments to the command. The custom search URL and keyword are then passed as arguments to the command, using the following syntax:
CustomSearchURL>$searchUrl|$keywordFor example, to set up a quick search for the www.example.com website using the keyword "ex," you would call the setCustomQuickSearch() function as follows:
setCustomQuickSearch("http://www.example.com/search?term=%", "ex")Using Surfingkeys with Custom Quick Searches
Surfingkeys is a powerful keyboard shortcut manager for Chromium-based browsers that allows you to customize your browsing experience even further. With Surfingkeys, you can assign keyboard shortcuts to custom quick searches, making it even easier to search your favorite websites.
To assign a keyboard shortcut to a custom quick search using Surfingkeys, you can use the following code:
surfingkeys.bind_key("ex", function() {
setCustomQuickSearch("http://www.example.com/search?term=%", "ex")
});In this code, the bind_key() function binds the "ex" keyboard shortcut to the setCustomQuickSearch() function, which sets up the custom quick search for the www.example.com website. Now, whenever you press the "ex" keyboard shortcut in your browser, the custom quick search will be triggered, allowing you to search the www.example.com website directly from the address bar.
- Chromium-based browsers allow users to customize their search experience by setting up quick searches using a custom search URL syntax.
- Kotlin can be used to automate the process of setting up custom quick searches in Chromium-based browsers.
- Surfingkeys is a keyboard shortcut manager for Chromium-based browsers that allows you to assign keyboard shortcuts to custom quick searches.