How to dualboot Hyprland with Gnome Desktops on Linux
Tags: linux
Published: 2024-01-24 07:30:43

> Linux desktops are like a box of chocolates - you never know what you’re going to get. One day, you’re working on a sleek and stylish desktop, and the next day, you’re staring at a screen that looks like it was designed in the 90s. But that’s the beauty of Linux - it’s unpredictable, quirky, and always keeps you on your toes.

Personally, I find Gnome the most usable desktop. Things just works - it stays out of my way, and apps work together with harmony, without causing any issues. Want to login to Vscode with Github? Just click yes, and gnome will open your preffered default browser automatically, login to Github, close the tab, and switch back to vscode app and log you in successfully.

However, sometimes I prefer Hyprland over Gnome. Maybe its because it looks cool, maybe you can customize it a lot, maybe it just has quality of life animations and customizable keybinds. But for me, its because Hyprland doesn't hook any keybind by default. And that includes the Win/Super key. It's just perfect for VM Guis and passing my inputs like the win key to open the windows start menu pretty easily, whereas Gnome would open its own overview panel when clicking the win key.

So, without further ado - Start by having GNOME preconfigured/already installed and ready to use.
I suggest using Fedora Workstation, it comes with Gnome desktop by default, unless you choose some other flavour.

> BTW, many suggest to use other login display managers like SDDM, but I didn't find any problems using the default GDM login manager that comes with GNOME desktop by default.

For illustration purposes, I will be running Fedora Default/Gnome flavour ISO inside a VM (but dont worry, I still use Fedora on the real setup too lol)

So anyways, after setting up Gnome desktop properly, you should start by installing Hyprland package.
On Fedora, its as easy as installing `sudo dnf install hyprland` .

![Installing Hyprland on Fedora](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbj9zrubjraqhd31e17d.png)


If everything goes perfect, you can log out to the login screen of GDM. Select your account if not already, and you will see a small "cog" icon at the bottom right. Clicking it will show available Desktops that you can use.


![Select Hyprland](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk9yfnl2d5jcgjnc0t69.png)

We now need to setup gnome polkit integration. Hyprland docs suggested kde integration, but since we want Gnome one, start by pressing `win+Q` to open up kitty terminal. Type in `sudo dnf install polkit-gnome` to do so. For other linux distros out there, consider finding a similar package by search online.

> If you are setting Hyprland for the first time, you will get a yellow warning popup at the top of the screen. To remove it, you need to install a code editor like `vim`, edit the config file at `~/.config/hypr/hyprland.conf` and remove the `autogenerated=1` line.

---

Now the hard part - We need to setup passwords to be synced with Gnome desktop too.

If you had previously googled it, ArchWiki would say the binary was installed at `/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1`, however that's not the case here in Fedora.

![ArchWiki Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qsitppmfxdrbzqxtxkzr.png)

I found out that Fedora installs the binary at `/usr/libexec/polkit-gnome-authentication-agent-1` (Thank me later). So you can run that command, and then open another terminal to try whether Gnome will ask password now back - `win+Q` to open another kitty terminal & type in `pkexec whoami`

![Gnome Polkit Asking Password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mq168d3c9y1ee1wvlbzy.png)

If you provide the correct password, it will run the command as root user, and so it will return `root` to the terminal ;p


![pkexec command ran successfully](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbvsvmb9482a25e0rzsm.png)

So, now that we know that this polkit for gnome works successfully, we should write it to the hyprland config file to run this command everytime on logging into hyprland. To do so, open `~/.config/hypr/hyprland.conf`.

![gnome polkit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d38ws3vsthxegwdnnq4z.png)

Now, save it and press `win+M` to crash/stop Hyprland, which will take you back to GDM login screen. Login back to Hyprland, and open up the terminal and run back `pkexec whoami` to find out that the Gnome UI like popup will ask the password back again - which confirms that Hyprland already ran that command which we asked it to.

But, its not over...
If you were already using your favorite browser on Gnome desktop before, I bet you logged into some of the sites. But if you try to open the same browser on Hyprland, you lose all your logged in passwords and such. Wonder why? It's because all those browsers and third party apps dont know what Hyprland environment is, and since they aren't inside gnome environment, they can use gnome password manager to login your online accounts. Wondering what's the solution? I did too. I searched all across the internet, and couldn't find any solution. However, I got a feeling that I should mess with the environment variables to check whether I can fake like as if I was in a Gnome environment - and to my suprise, I had succeeded!
After looking into Hyprland docs back again, I found a small spoiler alert that Hyprland sets up some envs which says to every app that they're in Hyprland environment.

![oh well...](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vsp19jmz1hyf946y8x6.png)

"however it is not a bad idea to set them explicitly" - oh wow... who knew the answer was put up like this?
Since we are using Wayland on both the desktops, we don't need to change the 2nd option. However, we need to set the other two envs to fake the whole environment that we are in Gnome.

Type in this to the `~/.config/hypr/hyprland.conf` file, just on top/before any `exec-once` statements, so any command ran will have these envs setup already:
```conf
env = XDG_CURRENT_DESKTOP,GNOME
env = XDG_SESSION_DESKTOP,gnome
```

Wondering where did I find these two variables? I just opened the terminal in Gnome desktop and echo'ed it back to me ;)

![gnome envs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1g6w98qqsnknj7x61k2.png)

You can run any applications now, and they will be synced & logged in on both the desktops! Congrats, you have your (soon to be) dream setup! Happy ricing your Hyprland!


![Never gonna...](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/woydudiilc1j6qm8w6nf.png)