Xfce Wiki

Sub domains
 

Tips & Tricks

This page contains various tips for the Xfce desktop environment.

Performance Tips

One of the benefits of Xfce is performance. It is lighter and more responsive than other desktop environments such as GNOME on almost all hardware, especially on machines with less memory and processing power.

Fonts

Fonts play a huge part in GUI performance. With all of the font smoothing, hinting and rendering turned on, you may notice significant latency when menus or dialog boxes appear. When you turn all of these off, menus and dialog boxes will appear much faster (snappy in fact). Scrolling will also improve in web browsers, text editors, and terminal emulators.

The only problem with turning off hinting/antialising is ugly fonts. On a laptop LCD, I recommend the “Kochi Gothic” font from 9 points and larger. “Helvetica” at 9 points and “Luxi Sans” also gives a clean look. Also, using “Verdana” at 9+ points with only anti-aliasing turned on(no hinting or sub-pixel hinting) looks very slick, however it may appear a little bold. Other font recommendations are welcome!

Using the Fixed font (12+) looks nice on a crt monitor works nicely for me. it is easy to read and i don't need to use anti-aliasing. it looks good and runs fast!

Background Color

I regularly connect remotely using vncserver, and I always noticed very slow and sluggish response, especially whenever I closed an application window. For example, when closing Firefox, it would take 30 to 60 seconds for the window to close and the system would be completely unresponsive during that time. By changing my background to solid white, all programs (including Firefox) now close within 1 to 2 seconds.

Right-click on the desktop and choose Settings then Desktop Settings. Make sure Show Image is UNchecked, and set the Color Style to Solid Color, and then set First Color to white (#FFFFFF).

Another option, that may work for some, is to check the options of the program that you are using to connect remotely, and if it has a “Remove Wallpaper” option or a “Do Not Display Wallpaper” option, then enable that option. I use TightVNCviewer and it does not have a Remove Wallpaper option, therefore changing the background color to white is the only solution for me.

Gtkrc files

  • A tutorial about the Gtkrc format can be found here.
  • You can not define a custom background for Thunar icon/ list views due to a bug in Gtk+ itself.
  • You can define a custom panel background with something like this:
# ~/.gtkrc-2.0
style "panel-background" {
  bg_pixmap[NORMAL]        = "foo.bar"
  bg_pixmap[PRELIGHT]      = "foo.bar"
  bg_pixmap[ACTIVE]        = "foo.bar"
  bg_pixmap[SELECTED]      = "foo.bar"
  bg_pixmap[INSENSITIVE]   = "foo.bar"
}
style "panel-color" {
  fg[NORMAL]               = "#222222"
  fg[ACTIVE]               = "#111111"
  bg[NORMAL]               = "#edeff2"
  bg[PRELIGHT]             = "#3d6eab"
  bg[ACTIVE]               = "#3d6eab"
}
widget_class "*Panel*" style "panel-background"
widget "*PanelWidget*" style "panel-color"
widget "*PanelApplet*" style "panel-color"
widget "*Panel*" style "panel-color"
widget_class "*Panel*" style "panel-color"
class "*Panel*" style "panel-color"
class "*Tray*" style "panel-color"
class "*tray*" style "panel-color"

How to add or remove applications in the system menu

Add an application

You have to create a .desktop file (usually in /usr/share/applications for system wide or ~/.local/share/applications for your user) for the application you want to add.

In the following example, we create an entry in the menu with the name “foo” in the submenu “Multimedia”:

[Desktop Entry]
Encoding=UTF-8
Name=foo
GenericName=bar
Comment=Senseless program ever
Exec=foobar
Icon=/usr/share/pixmaps/foobar.xpm
Terminal=false
Type=Application
Categories=Multimedia;

You can read more about .desktop files here.

The libexo provides several utils amongst one to handle desktop entry files in a GUI fashion: exo-desktop-item-edit. With it you can create a new .desktop file, by running the command exo-desktop-item-edit --create-new

Remove an application from the menu

You can do this in two ways:

  • First way, and the easier one is to simply remove the .desktop file in the /usr/share/applications/ folder, but you will lose mime data (file associations).
  • The second way is to add this line to the .desktop file:
NoDisplay=true

How to customize starting Xfce

Like most UNIX terminal sessions, Xfce runs through user-customizable startup file when it starts up. You can edit this init file to run your own scripts, send environment variables to the GUI, etc.

To add your own startup code, edit the xinitrc file like this:

  • Copy the file /etc/xdg/xfce4/xinitrc to ~/.config/xfce4/
  • Add your own code to the file. For example, you could start the rxvt-unicode server:
    • source $HOME/.bashrc
    • # start rxvt-unicode server
    • urxvtd -q -o -f

You can read more about xinitrc at various locations online.

Starting with showing the Root Window

  1. xfdesktop –quit
  2. save your session

Use the desktop margin

To set the desktop margins, use the Settings Manager (Settings Manager > Workspaces & Margins > Margins).

The desktop margins are used to limit the size of maximized windows. This may be useful to avoid switching workspaces by accidentally mousing off the side of the screen.

The margins are also useful if you have only one Xfce panel: the margin area leaves a clear space to pull up application or workspace menus. By default, right click on the desktop (the margin) to show the Xfce menu, or middle (left+right) click to show the workspace menu.

The size of the margins is in pixels, so, with a reasonably modern monitor, at a resolution of, say 1680 x 1050, a setting of '10' will give a margin of about 1/8 of an inch. Note that nothing will change on any open window until you minimize and re-maximize it again. Also note that these margins only apply to maximized windows – you can manually resize any window right to the edge of the screen if you want to.

Handle acpi event for power button, show Xfce logout options

If you would like the xfce logout menu to show up when you press your power button, and your machine has acpi support, then do the following:

Solution 1

  • /etc/acpi/events/powerbtn
# /etc/acpi/events/powerbtn
# This is called when the user presses the power button and calls
# /etc/acpi/powerbtn.sh for further processing.
 
# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.
 
# We need to react on "button power.*" and "button/power.*" because
# of kernel changes.

event=button[ /]power
action=/usr/local/sbin/xfce4-shutdown-as-user.sh
  • /usr/local/sbin/xfce4-shutdown-as-user.sh
#!/bin/sh 
# xfce4-shutdown-as-user.sh
#
# Check how many users are currently logged into X.
# If only one user is logged in, run a script which sets
# up the environment to call xfce4-session-logout.

LOGGED_IN_USER=`ls -trl /tmp/.ICE-unix/ | tail -n -1 | cut -d' ' -f3`
NUM_X_USERS=`echo $LOGGED_IN_USER | wc -l`
  
if [ $NUM_X_USERS -eq 1 ]; then
    sudo -H -u $LOGGED_IN_USER /usr/local/sbin/xfce4-user-session-shutdown.sh
fi
  • /usr/local/sbin/xfce4-user-session-shutdown.sh
#!/bin/sh
# xfce4-user-session-shutdown.sh
#
# Set up the environment so that DISPLAY and
# SESSION_MANAGER are valid, and xfce4-session-logout can run

HOST=`hostname`
SESSION_ID=`ls -t /tmp/.ICE-unix/ | head -n1`
# Note that distros use different syntax for the SESSION_MANAGER variable (this script has Debian's format).
# If this does not work, then try something like SESSION_MANAGER="local/$HOST:@/tmp/.ICE-unix/$SESSION_ID"
# instead. You can always find the correct format for your distribution by looking at the
# value of SESSION_MANAGER in a X session.
DISPLAY=:0 SESSION_MANAGER="local/$HOST:/tmp/.ICE-unix/$SESSION_ID" /usr/bin/xfce4-session-logout
  
  • Make those scripts executable :
chmod +x /usr/local/sbin/xfce4-user-session-shutdown.sh /usr/local/sbin/xfce4-shutdown-as-user.sh

Solution 2

  • Open Settings Manager (or by command : xfce4-settings-manager )
  • Open Power Manager settings
  • In General : set When power button is pressed to Ask
  • Close Power Manager settings
  • If you have ACPI scripts installed, deactivate or update the power-button script from /etc/acpi/events/, and change the action field to /bin/true:
# EXAMPLE
event=button/power.*
#action=/usr/lib/acpid/power_button
action=/bin/true

Accessing man pages through xfrun4

Use '#' as a shortcut to open man pages using xfrun4. e.g. #man

Do maths with xfrun4/appfinder

  • What you get: input simple mathematical expression, like 5+5 or (5+5)/3 or .5*10, in xfrun4/appfinder, and get the result as notification.
  • Requirement: notify-send
  • Save this script as bcme.sh, in your home directory:
#!/bin/sh

precision=2        # number of digit for floating value
notify_time=20000  # number of milisecond the notification show

res=`echo "scale=$precision;$@" | bc`  
notify-send -t $notify_time "$res" "=$@"
  • Add custom action to Application finder :
    • Type : Regular Expression
    • Pattern : ^([0-9]|\(|\.).*
    • Command : /bin/sh ~/bcme.sh \0
    • (check) Save match in command history

Xfconf

Toggle panel autohide

Short Bash script to toggle the autohide property of a panel, so you can bind for example a keyboard shortcut to quickly show and hide a panel.

#!/bin/sh
 
test -z "$1" && echo missing panel id  && exit 1
test ! -z "`echo $1 | sed s/[0-9]*//g`" && echo bad panel id  && exit 1
 
CHANNEL=xfce4-panel
PANELID=$1
PROP=/panels/panel-$PANELID/autohide
 
if `xfconf-query -c $CHANNEL -p $PROP >/dev/null 2>&1`; then
    xfconf-query -c $CHANNEL -T -p $PROP
else
    xfconf-query -c $CHANNEL -n -p $PROP -t bool -s false
fi

Control per-window transparency

Xfce lets you control the transparency of any window by horizontal scrolling on the titlebar. Starting with 4.12 though, it has been disabled by default. To enable this, open Settings Editor > xfwm4 and change horiz_scroll_opacity to true by clicking the checkbox.