Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
zh-cn:tips [2012/04/28 16:36] – [Use the desktop margin] haobugzh-cn:tips [2015/03/10 04:50] – [Do maths with xfrun4/appfinder] yjwork
Line 135: Line 135:
  
 空白边的大小以像素为单位,所以在比较新近的显示器上,以分辨率1680 x 1050为例, ‘10’ 会留出大约 1/8 英寸(0.3175厘米)的空白。注意,已经打开的窗口在最小化再还原后才会生效。另外还要注意,这只应用于最大化的窗口 —— 你可以手工地改变窗口的大小到屏幕边缘。 空白边的大小以像素为单位,所以在比较新近的显示器上,以分辨率1680 x 1050为例, ‘10’ 会留出大约 1/8 英寸(0.3175厘米)的空白。注意,已经打开的窗口在最小化再还原后才会生效。另外还要注意,这只应用于最大化的窗口 —— 你可以手工地改变窗口的大小到屏幕边缘。
-===== Handle acpi event for power button, show Xfce logout options =====+===== 处理 ACPI 电源按钮事件,显示 Xfce 注销选项 =====
  
-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:+如果你想在你按下电源按钮时显示注销菜单,并且你的机器支持 ACPI,那就按下面的步骤做吧:
  
-==== Solution 1 ====+==== 解决方案 1 ====
    * ''/etc/acpi/events/powerbtn''    * ''/etc/acpi/events/powerbtn''
-<file>+<file bash>
 # /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.+# /etc/acpi/powerbtn.sh 作进一步处理。
    
-Optionally you can specify the placeholder %e. It will pass +你也可以用 %e 这个占位符来把整个内核事件消息传给你指定的程序。 
-# through the whole kernel event message to the program you've + 
-specified. +我们需要对 "button power.*" 和 "button/power.*" 都作出反应, 
-  +因为内核做了改动。
-# We need to react on "button power.*" and "button/power.*" because +
-of kernel changes.+
  
 event=button[ /]power event=button[ /]power
Line 158: Line 156:
  
   * ''/usr/local/sbin/xfce4-shutdown-as-user.sh''   * ''/usr/local/sbin/xfce4-shutdown-as-user.sh''
-<file>+<file bash>
 #!/bin/sh  #!/bin/sh 
 # xfce4-shutdown-as-user.sh # xfce4-shutdown-as-user.sh
 # #
-Check how many users are currently logged into X. +检查当前有多少用户登录了 X。如果只有一个用户登录, 
-If only one user is logged in, run a script which sets +就执行脚本设置环境来调用 xfce4-session-logout
-# up the environment to call xfce4-session-logout.+
  
 LOGGED_IN_USER=`ls -trl /tmp/.ICE-unix/ | tail -n -1 | cut -d' ' -f3` LOGGED_IN_USER=`ls -trl /tmp/.ICE-unix/ | tail -n -1 | cut -d' ' -f3`
Line 175: Line 172:
  
   * ''/usr/local/sbin/xfce4-user-session-shutdown.sh''   * ''/usr/local/sbin/xfce4-user-session-shutdown.sh''
-  <file>+  <file bash>
 #!/bin/sh #!/bin/sh
 # xfce4-user-session-shutdown.sh # xfce4-user-session-shutdown.sh
 # #
-Set up the environment so that DISPLAY and +设置环境变量,使 DISPLAY 和 SESSION_MANAGER 为有效的, 
-SESSION_MANAGER are valid, and xfce4-session-logout can run+并且可以执行 xfce4-session-logout 
  
 HOST=`hostname` HOST=`hostname`
 SESSION_ID=`ls -t /tmp/.ICE-unix/ | head -n1` 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). +注意,发行版们的 SESSION_MANAGER 变量使用不同的语法(这时用的是 Debian 格式) 
-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 +# SESSION_MANAGER="local/$HOST:@/tmp/.ICE-unix/$SESSION_ID" 这样的。 
-# value of SESSION_MANAGER in a X session.+通过在 X 会话中查看 SESSION_MANAGER 的值,你总可以找到你的发行版的正确的格式 
 DISPLAY=:0 SESSION_MANAGER="local/$HOST:/tmp/.ICE-unix/$SESSION_ID" /usr/bin/xfce4-session-logout DISPLAY=:0 SESSION_MANAGER="local/$HOST:/tmp/.ICE-unix/$SESSION_ID" /usr/bin/xfce4-session-logout
   </file>   </file>
  
-   Make those scripts executable +   让这些脚本可执行 
-<code>+<code bash>
 chmod +x /usr/local/sbin/xfce4-user-session-shutdown.sh /usr/local/sbin/xfce4-shutdown-as-user.sh chmod +x /usr/local/sbin/xfce4-user-session-shutdown.sh /usr/local/sbin/xfce4-shutdown-as-user.sh
 </code> </code>
-==== Solution 2 ==== +==== 解决方案 2 ==== 
-   Open Settings Manager (or by command : xfce4-settings-manager ) +   打开“设置管理器”(或者用命令: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// :+   如果您安装有 ACPI 脚本,从 **/etc/acpi/events/** 停用或更新电源按钮脚本修改  //action// 字段的值为 ///bin/true//:
 <file> <file>
 event=button/power.* event=button/power.*
Line 212: Line 210:
  
 使用 '#' 作为在 xfrun4 中打开一个用户手册页的快捷方式。例如,#man 使用 '#' 作为在 xfrun4 中打开一个用户手册页的快捷方式。例如,#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.
 +  * 要求: notify-send
 +  * 在您的家目录,保存此脚本为 bcme.sh :
 +
 +  #!/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" "=$@"
 +
 +  *在应用程序查找器添加自定义动作 :
 +    * 类型 : 正则表达式
 +    * 类型 : ^([0-9]|\(|\.).*
 +    * 命令 : /bin/sh ~/bcme.sh \0
 +    *  (勾选) 在命令历史中保存匹配的
 +
 +
 +====== 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.
 +
 +<code bash>
 +#!/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
 +</code>