How To Install A Desktop Environment On Gentoo Linux: XFCE Guide
Desktop Env gentoo Guide Installation Linux WalkthroughHi all, welcome to MusaBase! In today's guide, I'll show you how to install a Desktop environment on Gentoo Linux. This is a follow-up guide to my previous article for Gentoo Linux Installation in which i only showed you, how to install and configure basics of Gentoo. But in this article, I'll continue on installing Xfce with addition to:
- Preparing Gentoo system for a desktop environment
- Installing Xorg, the core component for any Desktop environment
- Configuring make.conf to enable GPU and video card support
- Installing the Xfce and its dependencies
- Configure Gentoo system to launch Xfce
- And finally booting into Xfce on Gentoo
By the end of this you will have a fully functional Xfce running on your Gentoo system with ease. So without further ado, let's get started!
Prerequisites
Before we continue, make sure you have enough storage space available about (30GB) or more, and a minimum of 6GB of RAM is required. Also, in this guide, I won't cover the installation of Gentoo Linux. If you haven't installed Gentoo, then please follow the instructions explained in this Gentoo Linux Installation tutorial. After you have installed Gentoo, comeback to this guide and continue. This guide will be following the Gentoo's Official Xfce Installation Wiki. If you get stuck at any step or command, please dobule-check the commands in my guide with Gentoo's Wiki and for any detailed information.
Step 1: Preapre Gentoo System for Desktop Environment
I have an i5 4th gen processor with 4 cores and 10GB of RAM. This setup completed in almost 9 hours on my PC, so I would highly recommend doing the installation steps overnight. If you have more capable processor than mine, then this setup could take less time, but still, it's going to take time.
1.1: Choose a Desktop Profile
Note: If you installed Gentoo by following my previous Gentoo installation guide, then you don't need to perform this step. If you have installed minimal Gentoo with no desktop profile then follow this step.
- Run:
sudo emerge eselect profile list | less
- It'll print out all the available profiles.
- If your init system is OpenRC, then note the index number of that profile. (e.g., [3] default/linux/amd64/23.0/desktop (stable) ).
- If you are using systemd, then note the index number of desktop/systemd profile. (e.g., [4] default/linux/amd64/23.0/desktop/systemd (stable) ).
- To set or change profile, run:
sudo eselect profile set 3
1.2: Synchronize Local Portage Repository Tree
Portage depends on up-to-date information from repositories to know which packages and ebuilds are available. Synchronizing Portage tree ensures that the Gentoo system has the latest package information and supports multiple repos efficiently.
- We can do this by running:
sudo emaint --auto sync
1.3: Add GPU to make.conf
We also need to add the GPU to /etc/portage/make.conf. The GPU variable will tell the Portage, which grpahics drivers to enable when building packages. This will save time becuase without adding our specific GPU, Portage may build all possible drivers by default which will install drivers for all supported GPUs.
- To add GPU variable, do the following:
sudo nano /etc/portage/make.conf
- In the make.conf add the following line:
VIDEO_CARDS="virtio"
1.4: Updating Gentoo @worldset
Updating full Gentoo system (@worldset) before installing any other package is optional. But, by updating the system, we can safely install Xfce and run the desktop session because all packages would be synchronized, updated and if any missing dependecies are left, it will manage them automatically.
- To update @worldset, run:
sudo emerge --ask --verbose --update --deep --newuse @world
1.4: Cleaning Gentoo System
After updating the Gentoo system, it is always a good idea to clean the system from unused packages plus dependencies. Unused dependencies may lead to unresolved conflicts for future updates. Cleaning them helps keep the system's dependency graph manageable.
- To clean the unused packages & dependencies clutter, run:
sudo emerge --depclean
Step 2: Install Display Server and XFCE Desktop Environment
In this step, We'll add USE flags for our Display server (Xorg) and XFCE and then install them.
2.1: Add USE Flags for Xorg and Install X11
Xorg is a open-source display server. It is the core component for any desktop session to run successfully for Unix-ike operating system, like Linux distro or BSD operating systems. It allows the interaction between graphical applications and our display.
- To add Xorg USE flags, run:
sudo emerge --verbose x11-base/xorg-drivers
- After calculating all the dependencies in the xorg packages for Gentoo, Portage may ask you:
- Would you like to add these changes to your config files? [Yes/No]
- If you face this prompt, then type Yes and press ENTER to continue and follow next steps until you get sudo etc-update step.
- If Portage prompts:
- Would you like to merge these packages? [Yes/No]
- Type Yes and press ENTER to install Xorg.
2.2: Add USE Flags for XFCE
- To add XFCE base and extra pacakge's USE flags, run:
sudo emerge --ask xfce-base/xfce4-meta xfce-extra/xfce4-notifyd
- After calculating the dependencies, the Portage will ask you:
- Would you like to add these changes to your config files? [Yes/No]. As shown below in the second image.
- Type YES and press ENTER and it will add XFCE's USE flags to a temporary file.
2.3: Update Config Files
In previous steps we emerged the xorg and xfce pacakges. But before actually installing those packages we need to add USE flags to package.use file. By performing Step 2.1 & 2.2, we have successfully added USE flags for xorg and xfce. Now we need to update our config.files to actually install these pacakges.
- To update config files, run:
sudo etc-update
- After a few seconds, it will prompt you the options to edit a single or all files with there's corresponding number.
- Type -3 and press ENTER and it will update all config files.
2.4: Install XFCE Desktop
Now that our USE flags has been added and system is up-to-dated, we can install XFCE without any interruption.
- Re-run the emerge command again like this:
sudo emerge --ask xfce-base/xfce4-meta xfce-extra/xfce4-notifyd
- This time, Portage will ask:
- Would you like to merge these packages? [Yes/No]
- Type Yes and press ENTER and installation will begin.
Step 3: Start XFCE Desktop Session
To launch XFCE session, we need to add a xfce execution command in our ~/.xinitrc and then we can start the XFCE session.
3.1: Add XFCE Launch Command in ~/.xinitrc
- Run:
sudo nano ~/.xinitrc
- In the .xinitrc add:
exec startxfce4
- After adding the launch command, press CTRL + O to save the changes then press ENTER to apply the changes, then press CTRL + X to exit the file.
3.2: Launch XFCE Desktop Session
- Now that everything is set, we are ready to launch the XFCE desktop session.
- Simply run:
startxfce4
# OR
sudo startxfce4
- After a few seconds you will be in XFCE's desktop screen:
If Above Method Failed to Start XFCE Session
- If XFCE session is launching after running sudo startxfce4 then we need to change the launch command in ~/.xinitrc.
- Run:
sudo nano ~/.xinitrc
- Then replace the previous exec startxfce4 command with:
exec dbus-launch --exit-with-session xfce4-session
- After replacing the launch command, press CTRL + O to save the changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.
- Next, re-run:
sudo startxfce4
# OR
startxfce4
- And you shoudl be boot into XFCE desktop session.
Afterwards
Now you have a fully functional XFCE Desktop session running on your Gentoo system. I'll be covering more on Gentoo desktop session in my coming articles like KDE Plasma, GNOME, Mate, etc or different Wayland compositors like Hyprland on Gentoo, stay tuned for that.
If you hit any error or face any issue following steps explained in this guide, please let me know in the comments. I'll be more than happy to help.
This is it for now. 1O1 out, I'll see you in the next one!