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 反应更灵敏,尤其是在较少的内存和处理器能力的机器上。

字体

字体对 GUI 性能有极大影响。全部打开字体平滑,微调和渲染,你会注意菜单对话框出现时有明显的延迟。当你把这些全部关闭,出现要快(实际上是敏捷)很多

关掉这这些微调/抗锯齿唯一的问题就是,字体会显示得很丑。在 LCD 的笔记本电脑上,我建议使用 “Kochi Gothic” 字体的9号或者更大号。“Helvetica” 9号或者 “Luxi Sans” 也看起来很清晰。“Verdana” 9号以上,及只打开抗锯齿(不打开微调,亚像素渲染) 看起来非常光滑,只是可能看起了有点粗。也欢迎推荐其他字体。

我在 CRT 显示器上使用 Fixed 字体(12号+),感觉效果很好。很容易看清不用开抗锯齿。看起为不错并且跑得快。

背景颜色

我经常使用 vncserver 远程连接,我总是感觉很慢,反应迟钝,特别是关闭程序窗口的时候。比如,关闭 Firefox 的时候,需要30到60 秒钟才能完成,在这期间,系统完全没有反应。 我修改了我的背景为纯白色,现在的所有程序(包括 Firefox )1到2秒内就可以关闭了。

右击桌面,选择”设置“,然后”桌面设置“。请确保”显示图像“是未选中的。并设置”颜色风格“为”纯色”,然后设置第一个颜色为白色(#FFFFFF)。

另外一个选择,对一些软件可能有用,那就是查看你用来远程连接的程序的设置选项,如果有”去掉墙纸“或者”不显示墙纸“的选项,那就打开这个选项。我用的是 TightVNCviewer,它没有”去掉墙纸“的选项,所以修改背景颜色是我的唯一的解决办法。

如何使用 GNOME 菜单

如果你想使用 GNOME 的新菜单, 比如用快速启动的喜欢的应用之类的话,你可以使用的 xfapplet 面板插件 添加 GNOME 主菜单小程序。这个菜单您可以用你的包管理系统安装,查找 gnome-main-menuXfce的截图视频

在您的面板上添加一个新 xfapplet 项,并打开其属性对话框添加GNOME 菜单的小程序。

如果你不喜欢GNOME主菜单,可以试一下Ubuntu系统面板,在几种发行上找得到。

另见:如何自定义 Xfce 4.5 +菜单

gtkrc 文件

  • 这里有一个 gtkrc 文件格式的教程。
  • 你不能定义 Thunar 图标/列表视图模式下的自定义背景,这是因为 GTK+ 本身的缺陷。
  • 你可以像这样定义自定义的面板背景:
# ~/.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"

如何删除和添加系统菜单中应用程序

添加应用程序

你必须为你想要添加的应用程序创建一个 .desktop 文件(通常创建在下列位置中, /usr/share/applications 对整个系统有效, ~/.local/share/applications 对你自己有效)。

在下面的例子中,我们在 “多媒体” 菜单中创建了一个名为 “foo” 的子菜单:

[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;

你可以在 这里阅读更多的关于 .desktop 文件的内容。

libexo 提供了好几个实用工具,其中有一个可以以图形方式处理 desktop 文件: exo-desktop-item-edit。 你可以用它创建一个新的 .desktop 文件,用命令 exo-desktop-item-edit --create-new ;-)

删除应用程序

你有两种方法:

  • 第一种,并且也是更简单的一种就是直接删除 /usr/share/applications/ 文件夹中的.desktop 文件,但这样你们丢失 mime 数据(文件关联)。
  • 第二种,添加这一行到 .desktop 文件中:
NoDisplay=true

怎样自定义 Xfce 启动

像大多数 UNIX 终端会话一样,Xfce 在启动时会执行用户自定义的启动文件。你可以通过修改这个初始化文件来执行你自己的脚本,给 GUI 发送界面环境变量等。

请像这样编辑 xinitrc 文件,添加你自己的启动代码:

  • 复制 /etc/xdg/xfce4/xinitrc 到 ~/.config/xfce4/
  • 添加你自己的代码到这个文件。例如,你可以启动 rxvt-unicode 服务器:
    • source $HOME/.bashrc
    • # start rxvt-unicode server
    • urxvtd -q -o -f

你可以从这了解更多关于 xinitrc 的内容 很多不同的网站

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
  • In the file /etc/acpi/events/power_button , change the action field to /bin/true :
event=button/power.*
#action=/usr/lib/acpid/power_button
action=/bin/true

使用助记符创建 Thunar 自定义动作

当你创建一个 自定义动作 时,你可以设置一个字母前面带 “_”(下划线)的名字,这个字母作为助记符。当你在 Thunar 中点击右键时你可以按这个字母来访问你的自定义动作。

Accessing man pages through xfrun4

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