--- aliases: [/en/sys/openbsd/xfce/] categories: ['OpenBSD','System','X11'] date: 2021-07-20T21:05:54+02:00 description: "How-to install, set and use Xfce4 on OpenBSD!" draft: false tags: ['OpenBSD','Xfce','Xfce4'] title: "OpenBSD: Xfce4" translationKey: "openbsd-xfce4" --- ## Description **Xfce4** is a Desktop Environnement, available on OpenBSD. ⇒ Environnement: * OpenBSD: 6.6 → 7.4 * Xfce4: 4.14 → 4.18 --- In this tutorial, I assume that OpenBSD has just been freshly installed, and that everything has to be done. ## Installation Usual: `# pkg_add xfce xfce-extras` Some dependancies are installed, like **dbus**. ### Additionnal packages By default, some packages are not installed. - **xfce4-icon-theme**: additional icons pack - **xfce4-power-manager**: power management for laptop - **xfce4-pulseaudio**: plugin for the pulseaudio sound system - *but, it's not necessary… OSS works great!* - **xfce4-xkb** : switch between layers keyboard languages - *but, is-it really useful, when using the command `setxkbmap`, or even just `kbd`, followed with the language code… is enough‽* ## Configuration Since Xfce4 4.14, available on OpenBSD 6.6, it's a bit easier to configure simply your personal environment system. In a first step, I talk about a basic functional configuration; and, I'll add information to improve your comfort. ### .xsession The first file to create is: `~/.xsession`. Add: ```cfg exec xfce4-session ``` ### user profile You've to add your user to both system groups: - allows to use the shutdown and restart features: - OpenBSD ≤ 7.3: **operator** - OpenBSD ≥ 7.4: **_shutdown** - **wheel** which authorizes to use the sleep and hibernate features, if they're available on your system. With rights admins: ```sh # usermod -G _shutdown,wheel user ``` *(change 'user' by your id user, of course…)* ### Performances #### apmd To use the sleep and hibernate functions, **apmd** need to be set. We set on automatic performance adjustement mode. ```sh # rcctl enable apmd # rcctl set apmd flags -A # rcctl start apmd ``` #### obsdfreqd If you have a laptop or would like the system to manage performance fine-tune performance, you may prefer to use the use of **obsdfreqd**. **obsdfreqd** is a CPU frequency manager, created by Solène Rapenne, packaged since OpenBSD 7.1. It replace the native **apmd** daemon. ```sh # rcctl enable obsdfreqd # rcctl stop apmd # rcctl set apmd flags -L # rcctl start apmd obsdfreqd ``` **Explanations**: - it's necessary to start **apmd** in the manual mode, for obsdfreqd can handle it. - obsdfreqd's defaults settings are enough. --- Voila! It's enough to run correctly Xfce4. Think to restart your session or the machine. --- Now, let's go a little further in the configuration, like setting the French language, *or yours*, and others useful tips. ### .profile Start setting your personal file: `~/.profile` to add the following mentions: ```cfg EDITOR=vi # or nano, emacs, vim ENV=$HOME/.kshrc LC_MESSAGES=fr # or fr_FR.UTF8; it's egual! export EDITOR ENV LC_MESSAGES ``` ⇒ Explains: - I love **nano** as editor; into the base, **vi** is installed. The others need to be installed. - We declare a personal ENVironment; here, the **pdksh**. - Finally, define the language, as french. And we export the three variables. Of course, it's possible to configure any environment variable, like `PS1`: `export PS1="[\t] \e[0;35m:\u@\h: \e[0;32m\w \e[0;36m\$ \e[m"` --- Here an complete instance: ```cfg $HOME/.profile # $OpenBSD: dot.profile,v 1.7 2020/01/24 02:09:51 okan Exp $ # # sh/ksh initialization PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games export PATH HOME TERM EDITOR=nano ENV=$HOME/.kshrc LC_MESSAGES=fr export EDITOR ENV LC_MESSAGES ``` Concerning the **ENV** variable, we've declared a personal file `~/.kshrc`. By default, it doesnot exist; you have to create it with your favorite editor. --- You need to change your personal file `~/.xsession` to add your environment profile: ```cfg $HOME/.xsession . $HOME/.profile exec xfce4-session ``` Thus your graphic session will take account differents settings of your profile, such as language. ### .kshrc The content of this personal file is not complicated. Here is what to add to be functional: ```cfg $HOME/.kshrc . /etc/ksh.kshrc . $HOME/.profile HISTCONTROL=ignoredumps HISTFILE=$HOME/.mksh_hist HISTSIZE=10000 PAGER=less export PAGER ``` ⇒ Useful explains: - We source the global initialization for ksh to obtain a correct environment shell. - We source your personal profil file. - **HIST** variables are usefull to historize the orders commands: - `HISTFILE`: to define the backup file history - `HISTSIZE`: the number of commands to remember; do not confuse with the number of lines into file, defined with `HISTFILESIZE` - *not here*. - it's not necessary to export them. ### dbus **dbus** is installed as dependancy. The changes below are not essential, although useful. They're reported on the relative pkg-readme file. Add into your personal file `~/.xsession`: ```cfg if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then eval `dbus-launch --sh-syntax --exit-with-x11` fi ``` The file will look like this: ```cfg $HOME/.xsession . $HOME/.profile if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then eval `dbus-launch --sh-syntax --exit-with-x11` fi exec xfce4-session ``` --- Egual, pkg-readme **upower** informs us that it's useful to run the **apmd** and **messagebus** services, so the power management system works; let's go to enable the latter: ```sh # rcctl enable messagebus # rcctl start messagebus ``` ⇒ if your machine is a laptop, think to install **xfce4-powermanager** package, which is not provided by default. ### Printing To print, install Cups: ```sh # pkg_add cups cups-filters cups-libs foomatic-db gutenprint ``` Start both services **cupsd**, and **cups_browsed** — *this second is useful to detect printers on network using Bonjour broadcast messages*. ```sh # rcctl enable cupsd cups_browsed # rcctl start cups cups_browsed ``` You can administrate by the webui of Cups, available on http://localhost:631, or by tools as **cupsctl**, **lpadmin**. --- Since OpenBSD 6.2, binaries **lpq**, **lpr**, and **lprm** need to be symbolics links to run smoothly. Edit again your personal file `~/.kshrc` to add: ```cfg for i in lpq lpr lprm; do alias $i=/usr/local/bin/$i; done ``` ### Avahi **Avahi** is, on OpenBSD, the DNS multicast discovery service. Just install the **avahi** package, and after active and start the services: ```sh # rcctl enable multicast avahi_daemon # rcctl order messagebus avahi_daemon # rcctl start avahi_daemon ``` Normally, messagebus is already started! ## Tips ### PF I've not discuted about firewall rules, but here is an example: ⇒ Cups : ```cfg pass in on egress proto tcp from egress:network to egress port 631 flags S/SA modulate state ``` ⇒ Avahi : ```cfg pass proto udp from any to 224.0.0.251 port mdns allow-opts pass inet6 proto udp from any to ff02::fb port mdns allow-opts pass proto udp from any to 239.255.255.250 port ssdp allow-opts pass inet6 proto udp from any to { ff02::c, ff05::c, ff08::c } port ssdp allow-opts ``` Of course, it's up to you! ### Voila Think to restart your session, after modifying yours personals files. After, you can install others packages… --- Voila! ## Documentations * the differents pkg-readme files: - /usr/local/share/doc/pkg-readmes/xfce - /usr/local/share/doc/pkg-readmes/dbus - /usr/local/share/doc/pkg-readmes/upower --- * Official FAQ: https://wiki.xfce.org/faq * Official tips: https://wiki.xfce.org/tips ---