Wiki2
XFCEOpenBSD

Xfce on OpenBSD

XFCE screenshot

Installation

To install XFCE4 on a base OpenBSD install is quite simple.

First install xfce metapackage xfce and optionally xfce-extras as root.

# pkg_add xfce
# pkg_add xfce-extras

Then start xfce as a user.

$ startxfce4 

Check out pkg-readmes for additional post install info.

less /usr/local/share/doc/pkg-readmes/xfce-4.xxx

I also configure Caps-Lock to work as Escape.

My config files looks as follows.

cd ~

$ cat .Xmodmap
remove Lock = Caps_Lock
keysym Caps_Lock = Escape

$ cat .xsession
xmodmap ~/.Xmodmap
/usr/local/bin/startxfce4 --with-ck-launch

$ cat .xinitrc
xmodmap ~/.Xmodmap
/usr/local/bin/startxfce4 --with-ck-launch

You need to start e.g. xdm and messagebus at boot.

$ cat /etc/rc.conf.local            
apmd_flags="-A"
multicast=YES
xdm_flags=""

pkg_scripts="messagebus"

And you have dependency to a few packages to allow graphical shutdown. Related to the --with-ck-launch option.

$ pkg_info
consolekit2-1.0.2   framework for defining and tracking users, sessions & seats
polkit-0.113p3      framework for granting privileged operations to users

Everything is explained in pkg-readmes.

Multiple keyboard layouts

I use a US keyboard as default. But I regularly need to switch to a Swedish keyboard layout when I write in Swedish.

The following Xfce plugin is really useful to quickly switch between layouts.

pkg_add xfce4-xkb

Add the Keyboard Layouts selector to your top panel to give easy access layout switching.

Conflict with DISPLAY environment variable

I had a problem starting Xfce and spent some hours trying to figure out what was going on.

It turned out that I configured DISPLAY environment variable which was causing trouble for Xfce.

When DISPLAY is specified Xfce failed to start.

# export DISPLAY=":0.0"
# startxfce4
/usr/local/bin/startxfce4: X server already running on display :0.0
No protocol specified
xrdb: Resource temporarily unavailable
xrdb: Can't open display ':0.0'
No protocol specified
No protocol specified
xfce4-session: Cannot open display: .
Type 'xfce4-session --help' for usage.

DISPLAY should not be used.

unset DISPLAY

Create desktop item for app

TortoiseHg was missing an desktop item for Xfce thg.

I was able to find an example from the source repo.

cd /usr/local/share/applications/
wget https://bitbucket.org/tortoisehg/thg/raw/615d9cd72a111ae08cf835fc6e0f9cc9c58897d1/contrib/thg.desktop
chgrp bin thg.desktop 
cd ../icons/hicolor/96x96/apps/
wget https://bytebucket.org/tortoisehg/thg/raw/615d9cd72a111ae08cf835fc6e0f9cc9c58897d1/icons/thg_logo_92x50.png

I had to select the icon from the graphical settings for the launcher.

cd /usr/local/share/applications/
cat thg.desktop  
[Desktop Entry]
Type=Application
Name=TortoiseHg
GenericName=Version Control GUI
Comment=GUI application for using Mercurial
Icon=thg_logo_92x50
Exec=thg --nofork
Categories=Development;RevisionControl;

Mount a NFS share on boot

To mount a samba share on a second machine on boot I have added the following line on /etc/fstab.

solo:/home/share/music /home/peter/Music/share nfs ro,nodev,nosuid,soft,intr 0 0

Colors in ls

The X terminal (xterm) support colors. Make sure you have set the correct TERM environment variable.

export TERM=xterm-256color

If you want to have colors in e.g. ls check out the following.

Add Color to Your Terminal

pkg_add colorls
export LSCOLORS=CaGaxxxxBaxxxxxxxxAaAa
alias ls='colorls -G'

Check manpage for diffrent file types and colors to adapt LSCOLORS customization.

You can see your terminal color range with 256colors2.pl.

.profile not called in Xfce Terminal

Make sure Run command as login shell is checked in Xfce Terminal preferences to make sure .profile is sourced when a new terminal is opened.

Run minecraft

There is a minecraft script in ports that makes it really simple to run minecraft.

pkg_add minecraft
minecraft   # initializes minecraft the first time its run
minecraft   # run minecraft

When I was starting the Minecraft Launcher I got an OutOfMemory error from the java runtime. I fixed this by increasing the size of the java VM heap in the JVM Arguments field in the user profile for the launcher. Also make sure JVM Arguments is checked.

-Xmn256M

Also make sure your user is allowed to use sufficient memory via login.conf

Printing

The target was to be able to print on a HP printer connected to an Apple Time Capsule via USB.

pkg_add cups
less /home/peter/pkg-readmes/cups-2.1.4 
rcctl start cupsd

Start browser on http://localhost:631.

It should be visible from via mdns but that is not directly supported in CUPS it seems.