How to setup FreeBSD with a riced desktop - part 2 - Xfce

Posted on 2020-01-23.
This is the second part of the tutorial. In this part we're going to install Xfce and rice it a bit. You can look further down in the tutorial at the screenshots in order to determine if you like the results.

Table of contents

Introduction

Xfce is a lightweight and very customizable desktop environment. It is currently based on both GTK 2 and GTK 3. It provides a window manager, a file manager, a desktop and panel, and a bunch of other applications. The current version of Xfce is version 4.

Installation

To install Xfce use the meta-package called xfce. In this case I'm also going to install the goodies package as it provides some extra plugins and some useful utilities, and I'm going to install the Xfce mixer package too. Take a look at the different packages that gets pulled in to see if you can do without some of them. In case you want less bloat you can just manually install the packages you want to be a part of your Xfce installation.

$ doas pkg install xfce xfce4-goodies xfce4-mixer

Before we can start using Xfce we need to install Xorg:

$ doas pkg install xorg

Remember to also install the driver for your graphics card. Take a look at the FreeBSD wiki to determine what you need.

I'm using a Broadwell processors so I install the drm-kmod module:

$ doas pkg install drm-kmod

Then in order to enable the module:

# sysrc kld_list="i915kms"

Ensure that all users requiring graphics are members of the "video" group.

# pw groupmod video -M USERNAME

I reboot the machine here.

Then we need to create the .xinitrc file so we can use startx. Insert the following:

exec startxfce4

With this setup we can now login to the machine and simply type x, which is an alias to the startx command that will run the startxfce4 command.

If you prefer, you can install a graphical login manager.

Start Xfce by typing x.

Setup

The first thing I do after Xfce has started up is to change the keyboard layout.

You can do that by going to Applications -> Settings -> Keyboard. Then choose Layout and remove the checkmark at Use system defaults. Then in Keyboard layout, choose Add and then choose your keyboard layout. You can remove the English layout if you don't need to switch between them.

The next thing I do is to disable the lock screen part of the screensaver. I don't want the screensaver to automatically lock the screen if I haven't typed anything for a while. If I want to lock the screen, I do that manually.

We can disable the lock screen by going to Applications -> Settings -> Screensaver. Then go to the Lock Screen pane and disable the feature.

Since we're going to use a riced version of Xfce we're going to change some things further.

Go to the desktop and right click somewhere on the background and choose Desktop settings. Then go to Icons and remove all the checkmark from the Default Icons in the bottom. Close the Desktop settings.

Then right click at the top panel and choose Panel Preferences. Make sure that "Panel 1" is the one in the box, then click on the minus sign. This will remove the top panel. We don't want that.

You can still access all the applications by right clicking somewhere on the desktop and then choose Applications at the bottom of the menu.

Then right click at any of the icons in the bottom panel and choose Panel -> Panel Preferences. Then click on Appearance and change the style to Solid color. Then click on the color and click on the plus sign in order to add a custom color. At the bottom there is a slider, pull that all the way to the left. This makes the panel transparent.

Use the browser to download a suitable wallpaper. You can change the wallpaper by right clicking somewhere on the desktop and then choose Desktop Settings. Then use the Folder to choose the folder where you have stored the wallpaper.

Icon theme

Now we're going to change the icon theme.

You can use any icon theme you like, but I prefer the Moka icon theme.

In my case I create a hidden .icons folder where I place the icons. If you want to make them accessible system wide, you need to place them somewhere else of course. Open a terminal and do the following:

$ mkdir .icons
$ cd .icons
$ git clone https://github.com/snwh/moka-icon-theme

Next, right click the bottom panel and choose Panel Preferences, then click on Items.

In my case I like to have only the most used applications in the panel so I'll remove the Directory Menu, Show Desktop, the separators, and all the launchers except for the Xfce terminal. You remove each item by selecting it and then clicking the minus sign.

The items appear in the order the are placed in the panel. The item in the top is the one all the way to the left in the panel.

Now we're left with only the Xfce terminal launcher. Select the launcher and click the small icon with the wrench on it. It's the Edit option.

A new menu appears with a General tap and a Advanced tap. In the General tap click the small notepad looking icon on the icon list to the right. This will open the Edit Launcher where you can change the icon.

Click the icon. In the Select an icon click Select icon from (at the top) and choose Image Files. Then go to your home folder. If you have selected to put the icons into a hidden folder you need to press "CTRL+h" in order for the hidden files to appear. Select the folder where you have decided to put the Moka icons.

Then go to "Moka" and choose the icon size that suit your needs. In my case I like the "96x96" sized icons.

Once you have selected the folder with the size you want you'll see a list of categories. The nice thing about the icon selection tool is that it has a preview.

For the terminal choose apps, then scroll down to xfce-terminal.png.

You can also type the name of the icon if you have an idea what it's called. If you type "terminal", a list of terminal icons is selected.

When you have selected the "xfce-terminal" click OK and Save.

Now you can add more applications by clicking the plus sign in the Items section of the Panel Preferences. Don't choose any of the build-in applications as you cannot change the icons for those.

For each application you want to appear on the panel choose Launcher.

For this tutorial I choose one for Firefox, Claws-mail, Hexchat, Thunar (the Xfce filemanager), Gimp, FileZilla, and Evince.

Then select each launcher, one at the time, and press the icon with the wrench in order to manually set it up.

When you have selected a launcher you need to click the plus sign in order to add an application. The Add New Item appears and you can now search for the application you want to add.

When you have added an application you need to click the notepad icon in order to change the icon. Repeat the steps you did with the Xfce terminal application and change each launcher icon to match an icon from the Moka theme.

If you have managed to get through all the steps without any hiccups, your desktop should now look something like this:

Xfce with icons

Conky

Normally I would just leave Xfce with the above setup as I really like the minimalistic approach, but in this tutorial I'm going to add Conky to the mix.

Conky is very configurable and it is able to monitor many system variables and resources.

$ doas pkg install conky

You can find multiple Conky scripts on the Conky wiki page.

On the Arch Linux forum there is a thread dating back to 2007 and all the way up to 2019 (as of writing) where many people share their setup. You need to get one of the later postings if you want a script that works with the new Lua configuration in Conky.

In this case I'll use a simple setup.

Add the file .conkyrc in your home folder and insert the following:

conky.config = {
    background = false,
    use_xft = true,
    font = '123:size=8',
    xftalpha = 0.1,
    update_interval = 2.0,
    total_run_times = 0,
    double_buffer = true,
    minimum_width = 250, minimum_height = 5,
    maximum_width = 400,
    draw_shades = false,
    draw_outline = false,
    draw_borders = false,
    draw_graph_borders = false,
    default_color = 'gray',
    default_shade_color = 'red',
    default_outline_color = 'green',
    alignment = 'top_left',
    gap_x = 3840,
    gap_y = 10,
    no_buffers = false,
    uppercase = false,
    cpu_avg_samples = 2,
    net_avg_samples = 1,
    override_utf8_locale = true,
    use_spacer = 'right',
    text_buffer_size = 256,
    own_window = true,
    own_window_argb_value = 192,
    own_window_argb_visual = true,
    own_window_class = 'conky-semi',
    own_window_colour = '#0b0d18',
    own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
    own_window_transparent = false,
    own_window_type = 'normal',
};

conky.text = [[
${font openlogos:size=20}${color Ivory}Free${font Arial:size=20}${color Tan1}BSD${font openlogos:size=20}

${voffset -90}
${color DimGray}
${font}
${font Arial:bold:size=10}${color Tan1}SYSTEM ${color DarkSlateGray} ${hr 2}
$font${color DimGray}$sysname $kernel $alignr $machine
Intel Core i5
Uptime $alignr${uptime}

${font Arial:bold:size=10}${color Tan1}PROCESSORS ${color DarkSlateGray}${hr 2}
$font${color DimGray}CPU1  ${cpu cpu1}% ${cpubar cpu1}
CPU2  ${cpu cpu2}% ${cpubar cpu2}
CPU3  ${cpu cpu3}% ${cpubar cpu3}
CPU4  ${cpu cpu4}% ${cpubar cpu4}

${font Arial:bold:size=10}${color Tan1}MEMORY ${color DarkSlateGray}${hr 2}
$font${color DimGray}MEM $alignc $mem / $memmax $alignr $memperc%
$membar

${font Arial:bold:size=10}${color Tan1}HDD ${color DarkSlateGray}${hr 2}
$font${color DimGray}/ $alignc ${fs_used /root} / ${fs_size /root} $alignr ${fs_free_perc /root}%
${fs_bar /root}

${font Arial:bold:size=10}${color Tan1}SWAP ${color DarkSlateGray}${hr 2}
$font${color DimGray}swap $alignc $swap / $swapmax $alignr $swapperc%
${swapbar}

${font Arial:bold:size=10}${color Tan1}TOP PROCESSES ${color DarkSlateGray}${hr 2}
 NAME: $alignr       PID   CPU   MEM ${font sans:pixelsize=9}
 ${color DimGray}${top name 1} $alignr ${top pid 1}   ${top cpu 1}    ${top mem 1}
 ${top name 2} $alignr ${top pid 2}   ${top cpu 2}    ${top mem 2}
 ${top name 3} $alignr ${top pid 3}   ${top cpu 3}    ${top mem 3}
 ${top name 4} $alignr ${top pid 4}   ${top cpu 4}    ${top mem 4}
 ${top name 5} $alignr ${top pid 5}   ${top cpu 5}    ${top mem 5}

${font Arial:bold:size=10}${color Tan2}NETWORK ${color DarkSlateGray}${hr 2}
$font${color DimGray}IP on em0 $alignr ${addr em0}
$font${color DimGray}IP on VPN $alignr ${addr tun0}

Down $alignr ${downspeed em0} kb/s
Up $alignr ${upspeed em0} kb/s

Downloaded: $alignr  ${totaldown em0}
Uploaded: $alignr  ${totalup em0}

${font Arial:bold:size=10}${color Tan2}TIME ${color DarkSlateGray}${hr 2}

${color Ivory}${font :size=30}$alignc${time %H:%M}
${voffset -30}${color DimGrey}${font :bold:size=10}$alignc${time %a %d %b. %Y}
]];

Then we need to make sure that Conky starts when we start Xfce. Right click somewhere on the desktop and click on Applications -> Settings -> Session and Startup. Then click on the Application Autostart pane and click on the + Add button.

Set Name to "Conky", set Command to "conky", and set Trigger to "on login". Then click on OK and Close.

Right click somewhere on the desktop and click on Applications -> Log out -> Log out. Leave the checkmark in Save session for future logins.

Then start Xfce again.

Your desktop should now look something like this:

Xfce with conky

I'm running this on a virtual machine for the tutorial which is why the size of the harddrive is only 93GB.

In the past Conky could sometimes get messed up, displaying two versions of itself, one a bit further to the right on top of the other, if you experience something like that you need to create a small shell script with a delay and then change the Session and Startup to start the shell script rather than Conky directly.

I used to create a script called .conky_start.sh, which I placed in my home folder, with this:

#!/bin/sh
sleep 5
conky -q

This will delay the start of Conky by five seconds and solve the problem. Depending on how fast your desktop starts up, you can lower or raise the sleep value.

Final comments

With Xfce you have many settings, tools, and themes to choose from and it can be customized further if you like.

Please remember that this is just one way you can "rice" Xfce on FreeBSD. The Internet is filled with examples that you can use for inspiration.

As mentioned I no longer use Xfce, but it served my purpose very well in the past.

This was the Xfce setup. In the next part of the tutorial I'm going to install Xorg and i3 and then "rice" the window manager.

If you have any comments or corrections please feel free to email them to me. Also, if you found this content useful consider supporting me on Patreon