How to Create a Custom Web Browser with Nyxt

Spread the love

Nyxt is a lightweight modern web browser that focuses on functionality, usability and extensibility. It borrows concepts from both Emacs and Vim to provide a way to navigate the web with only your keyboard.

This article aims to guide you through the process of installing the Nyxt browser on Ubuntu. Further, this article also aims to show you how you can configure Nyxt to fit to your own personal workflow.

Content

Why Use the Nyxt Web Browser?

One of the main selling points of Nyxt is that it is easy to extend and modify. Unlike other modal browsers such as Qutebrowser, it is possible to configure every aspect and setting in Nyxt.

This is because the browser works as a live Lisp environment that you can actively tweak on the fly. For example, it is possible to configure the browser not to download any images from websites.

This makes Nyxt an incredibly versatile tool for power users that want to create a fully custom environment for web browsing.

Installing the Nyxt Web Browser

  1. The first step in installing Nyxt is to obtain a copy of its latest binaries from the developer’s website. You can do it from the terminal as well using wget:
wget https://github.com/atlas-engineer/nyxt/releases/download/2.2.4/nyxt-2.2.4.tar.xz

  1. Create a new directory and extract the binary archive inside it. You can do both of those actions by running the following commands:
mkdir nyxt && mv nyxt-2.2.4.tar.xz ./nyxt
cd nyxt && tar xvf ./nyxt-2.2.4.tar.xz

  1. Create a symbolic link from your “nyxt” directory to “/usr/local/bin.” This adds Nyxt to your system’s PATH variable and enables you to open the browser from anywhere in your computer:
sudo ln -s /home/$USER/nyxt/usr/local/bin/nyxt /usr/local/bin/nyxt

  1. You can now run Nyxt by typing nyxt, then pressing Enter.

Using the Nyxt Web Browser

With Nyxt up and running, you can now browse the internet with it. To open a webpage, you need to press Ctrl + L. This will bring up a small prompt where you can type the URL that you want to visit.

For example, pressing Ctrl + L, then typing “https://maketecheasier.com” will open the MakeTechEasier website.

From here, the browser should properly display the website and you will be able to interact with it as a regular webpage.

Similar to a regular web browser, you can also use the same interface to make basic search queries. For example, pressing Ctrl + L, then typing “maketecheasier linux tutorials” will open a DuckDuckGo results page.

Navigating the Nyxt Buffer

By default, Nyxt does not support any form of browser tabs. Instead, it heavily relies on independent frames and buffers to maintain each webpage that it loads. This allows you to customize the behavior of Nyxt on a per-website basis.

You can access a list of all the available buffer in your current session by pressing Alt + Down.

Aside from loading buffers from a list, you can also quickly switch in-between them by pressing Ctrl + Tab. This command will automatically cycle the browser to every buffer in the current session.

On the other hand, you can press Ctrl + [ to go back to the previous buffer and Ctrl + ] to go to the next one.

Lastly, the Nyxt browser also allows you to directly open webpages in separate buffers. Similar to opening in a background tab, you can do this by pressing Alt + L.

Navigating the Nyxt History

Another unique feature of Nyxt is its ability to display a tree-style history. This can be useful for users that want to trace back the sites that they have visited on their current session. To activate Nyxt’s tree-style history for the current buffer, press Ctrl + Space, then type “buffer-history-tree.”

Nyxt also supports a traditional list-style system. Press Ctrl + Shift, then H to bring up a small dialog menu where you can search for the history item that you want to load.

Lastly, you can also go through your session’s history similar to navigating your buffer list. For example, you can press Alt + [ to open the last page you have visited and Alt + ] to go back to your current webpage.

Changing Browser Modes in Nyxt

Nyxt ships with roughly 20 modes by default. These either control how the browser displays web content or change how you access a website. For example, the “noscript-mode” disables all JavaScript for the current buffer.

In order to change a mode, you need to press Ctrl + Space. This will bring up a small dialog box where you can provide the name of the mode that you want to activate. In my case, I type “emacs-mode” to enable Emacs-like keybindings while browsing the web.

Lastly, it is also possible to stack multiple modes in a single session. This can be helpful for users that want to create their own unique session while using Nyxt. To do this, you need to press Ctrl + Space, then type “toggle-modes.”

Configuring and Extending Nyxt

One of the biggest features of Nyxt is that it is possible to configure and extend almost every aspect of the program. However, it also means that it is possible to break the program with a wrong setting. With that in mind, you can create your own Nyxt configuration file by running the following command:

mkdir /home/$USER/.config/nyxt/ && touch /home/$USER/.config/nyxt/init.lisp

With a configuration file up and running, you can now write your own custom settings. For example, the following line of code will rebind the address buffer from Ctrl + L to Ctrl + Alt, then K:

(defvar *custom-keymap* (make-keymap "custom-map")
    "Keymap for `custom-mode'.")
 
(define-key *custom-keymap* "C-M-k" 'set-url)
 
(define-mode custom-mode ()
    "Mode for the custom key bindings in `*custom-keymap*'."
       ((keymap-scheme (keymap:make-scheme
                     scheme:cua *custom-keymap*
                     scheme:emacs *custom-keymap*
                     scheme:vi-normal *custom-keymap*))))
  • The defvar function tells Nyxt to create a custom keymap for the browser and name it as “custom-map.”
  • On the other hand, the define-key function creates a new keyboard combination inside that keymap and assigns it to the 'set-url function. In this case, the value C-M-k corresponds to Ctrl + Alt, then K.
  • Lastly, the define-mode function tells Nyxt to contain all the settings for the custom keymap inside a special “custom-mode.” This allows you to isolate any changes that you have made away from the default configuration.

With that done, you can now apply your new settings by saving your config file and reloading the Nyxt browser.

Frequently Asked Questions

Is it possible to run Nyxt without a terminal open?

Yes. It is possible to run the Nyxt browser without relying on the terminal. To do this, you can create a custom .desktop file for your Nyxt application.

I am getting a STRING INVALID error whenever I do any action in Nyxt.

This problem happens whenever you run Nyxt on a Wayland session. This is because the program heavily relies on Xorg to render and process its functions. You can fix this by logging out of your current session and selecting “Ubuntu on Xorg” on your machine’s login menu.

I can’t launch the web browser due to a GTK/Xorg error.

This error mostly occurs whenever your system is out of date. You can fix this issue by running sudo apt update then sudo apt upgrade to bring all of your programs and libraries to their latest version.

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Ramces Red
Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Comments are closed