Xfce Wiki

Sub domains

This is an old revision of the document!


此页面包含了 Xfce 桌面环境的多种技巧。


你可以用Pango 标记来自定义面板时钟插件的字体。切换到到自定义格式(只在数字式布局时能用)并在格式字符串中使用标记标签。


  • <span font_desc="URW Gothic L Book 18">%R</span>
  • <span font_desc="bold 12">%R</span>


让我们面对它吧:使用 Xfce 的原因之一是性能。它更轻量,​在几乎所所件硬件平台比 Gnome 反应更灵敏,尤其是在较少的内存和处理器能力的机器上。


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.

How to use the alternative GNOME-menu

If you want to use the new menu from GNOME, with quick starters for favorites applications and such, you can use the xfapplet panel plugin with the GNOME main menu applet. The menu should be installed with your package system, look for gnome-main-menu. Xfce screenshot, video.

Add a new xfapplet item inside your panel, and open its properties dialog to add the GNOME menu applet.

If you don't like GNOME main menu, try Ubuntu System Panel, available in several distributions.

See also: How to customize the Xfce 4.5+ menu

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]
Comment=Senseless program ever

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:

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
  • /usr/local/sbin/xfce4-shutdown-as-user.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
  • /usr/local/sbin/xfce4-user-session-shutdown.sh
# xfce4-user-session-shutdown.sh
# Set up the environment so that DISPLAY and
# SESSION_MANAGER are valid, and xfce4-session-logout can run

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
  • In the file /etc/acpi/events/power_button , change the action field to /bin/true :

Use mnemonics to create Thunar Custom Actions

When you create a Thunar Custom Action you can set the name with an underscore “_” before a letter to use it as mnemonic. When you right click in a Thunar view, you can type the letter to access your custom action.

Accessing man pages through xfrun4

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