15

Hyprland: getting started (part 1)

 1 year ago
source link: https://www.lorenzobettini.it/2023/07/hyprland-getting-started-part-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Hyprland: getting started (part 1)

In the past few months, I’ve heard (i.e., read articles and seen videos) many good things about the Wayland compositor Hyprland. I decided to try it, and I’ve been using it for almost one month as my daily driver. I’m still not into “tiling” that much, but in Hyprland, you can also switch to classic “stack” window management. I like Hyprland; it feels fast and reactive (also on a PineBook Pro; I’ll blog about Hyprland on a PineBook Pro in the future).

By the way, if you don’t already know:

Hyprland is a dynamic tiling Wayland compositor based on wlroots that doesn’t sacrifice on its looks. It supports multiple layouts, fancy effects, has a very flexible IPC model allowing for a lot of customization, a powerful plugin system and more.

This post is the first of a few articles showing how to install, configure and use Hyprland and additional tools. You can find many GitHub repositories with installation scripts and configuration files for Hyprland, but you end up with the configurations of those repositories, probably without understanding the basic details of Hyprland. I found starting from scratch (following the Hyprland wiki) much more helpful, taking inspiration from some of the above-mentioned GitHub repositories.

By the way, most Hyprland configurations you find on GitHub are primarily about “ricing” (i.e., heavy aesthetic customizations of the desktop). While I love good-looking desktops, I won’t blog about aesthetic customizations much. I’ll focus mostly on configurations and tools for usability.

This first post is only about getting started and having a usable environment with minimal helpful tools: there will be follow-up posts for installing other tools (like a bar and notification system) and configuring other programs (actually, I have already blogged about Variety in Hyprland).

Moreover, all these posts are about Hyprland in Arch Linux since that’s the only OS where I experimented with Hyprland. In particular, I’m using EndeavourOS.

First, install EndeavourOS without a desktop environment (when you get to the installer’s part, where you have to select a desktop environment).

I will use the AUR helper “yay”, which is already installed in EndeavourOS. On Arch, you’ll have to install it yourself, e.g., with the following commands:

sudo pacman -Sy git
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si

Let’s start from https://wiki.hyprland.org/Getting-Started/Master-Tutorial/ and install Hyprland from the official Arch repositories:

sudo pacman -S hyprland

As suggested, let’s install the terminal “Kitty” (the default Hyprland configuration has a shortcut to run that).

sudo pacman -S kitty

Of course, later, you can also install another terminal.

Now, you can execute “Hyprland” in your tty. (Remember, I haven’t installed any desktop environment or a login manager).

Note for virtual machines: If you test this in a virtual machine, ensure that 3D is enabled. Moreover, it’s crucial to start Hyprland with the following environment variables so that the mouse is usable; please, remember that the experience in a virtual machine will not be optimal anyway:

WLR_NO_HARDWARE_CURSORS=1 WLR_RENDERER_ALLOW_SOFTWARE=1 Hyprland

When Hyprland starts, you see a warning and a few pieces of information:

hyprland-first-run-1.png?resize=625%2C451&ssl=1

To make the warning go away, we edit the generated default configuration file (use either “vi” or “nano” text editors that are already installed in EndeavourOS). To do that, we must start a terminal: by default, the keyboard shortcut is “SUPER + Q” (as shown in the yellow warning):

hyprland-first-run-2.png?resize=625%2C386&ssl=1

Now we can edit the file .config/hypr/hyprland.conf and remove the following line:

autogenerated = 1 # remove this line to remove the warning

Save the file, and the warning will go away. In fact, one of the cool features of Hyprland is that it automatically applies changes to that file.

Let’s change the configuration file further. By default, the configuration uses a US keyboard layout. I had to change it to use the Italian layout: Edit that file and change the following part accordingly (in my case, I have an Italian keyboard):

input {
    kb_layout = it

Save the file, and the new keyboard layout will be immediately set.

You might want to install “neofetch” and run it in a terminal (in this example, I’m running inside a KVM virtual machine):

hyprland-neofetch.png?resize=625%2C549&ssl=1

The default configuration uses the shortcut SUPER + E to start the file manager “Dolphin”, which is not installed by default. You could install it. Here, I’m doing something different: Let’s install the file manager “nemo”:

sudo pacman -S nemo

and change the line

bind = $mainMod, E, exec, dolphin
bind = $mainMod, E, exec, nemo

Let’s save the file, press SUPER + E, and Nemo appears (tiled automatically)

hyprland-nemo.png?resize=625%2C386&ssl=1

Let’s install the application launcher “wofi” (personally, I prefer “rofi”, but I’ll blog about that in the future):

sudo pacman -S wofi

Wofi is already configured with the following keyboard shortcut:

bind = $mainMod, R, exec, wofi --show drun

For example, let’s use SUPER + R and run Firefox (already installed in EndeavourOS) using Wofi: just start typing “fir” until it appears in the list, move the cursor down to select it, and press ENTER (or keep on typing the other letters til “firefox” is the only choice).

hyprland-wofi-firefox-1.png?resize=625%2C386&ssl=1

hyprland-wofi-firefox-2.png?resize=625%2C386&ssl=1

Let’s exploit the blur effects of Hyprland: let’s modify the Kitty configuration file (create it if it doesn’t exist) ~/.config/kitty/kitty.conf by adding this line:

background_opacity 0.5

Save it and start another instance of Kitty and enjoy the blur effect with the default Hyprland background:

hyprland-kitty-blurred.png?resize=625%2C386&ssl=1

If “0.5” is too much transparency, make the value a bit bigger.

Let’s make Nemo transparent as well with an Hyprland window rule. By default, Nemo is not transparent:

hyprland-nemo-transparency-1.png?resize=625%2C382&ssl=1

Let’s modify the Hyprland configuration file by adding this line:

windowrulev2 = opacity 0.8 0.8,class:^(nemo)$

Save and restart Nemo, which is now transparent:

hyprland-nemo-transparency-2.png?resize=625%2C377&ssl=1

The two values in “opacity” set the opacity for the window when it’s focused and not, respectively. By changing the above line as follows:

windowrulev2 = opacity 0.9 0.6,class:^(nemo)$

The Nemo window will be less transparent when active and more transparent when not focused.

Monitor(s) configurations are specified in the Hyprland configuration and are applied on the fly as soon as you save the configuration file. This is the default configuration:

# See https://wiki.hyprland.org/Configuring/Monitors/
monitor=,preferred,auto,auto

The last value is the scale value. Try to change it to “1.5” or “1.75”, save, and see the scaling automatically applied.

Note that, by default, when running on a real computer (not a virtual machine), Hyprland already scales the display for high resolutions (e.g., it sets it to “1.5” by default).

Running from a Display Manager

The default installation already created a file in the appropriate folder to let SDDM start the Hyprland session.

$ cat /usr/share/wayland-sessions/hyprland.desktop  
[Desktop Entry]
Name=Hyprland
Comment=An intelligent dynamic tiling Wayland compositor
Exec=Hyprland
Type=Application

Let’s install the AUR package “sddm-git” (we need the Git version to avoid a bug that has been fixed but not in the current release; when reading this post, the official package might have already been fixed) with yay:

yay -S sddm-git

Then, we enable the service at boot:

sudo systemctl enable sddm

If we want to start it without rebooting, the first time we run:

sudo systemctl start sddm

hyprland-sddm.png?resize=625%2C398&ssl=1

And now you can enter Hyprland from here.

If you’re running inside a virtual machine, you lose the environment variables we saw above: “WLR_NO_HARDWARE_CURSORS=1 WLR_RENDERER_ALLOW_SOFTWARE=1”. To restore them, you must modify the “/usr/share/wayland-sessions/hyprland.desktop” accordingly, in particular, the “Exec” line:

Exec=env WLR_NO_HARDWARE_CURSORS=1 WLR_RENDERER_ALLOW_SOFTWARE=1 Hyprland

Then, restart “sddm” (by switching to a tty):

sudo systemctl restart sddm

Or by rebooting the system.

That’s all for now! Stay tuned for more posts about Hyprland 🙂

Like this:

Loading...

Related


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK