免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1282 | 回复: 0
打印 上一主题 下一主题

Linux小技巧-关闭屏幕 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-30 17:12 |只看该作者 |倒序浏览



在命令模式下输入sleep 1&&xset dpms force off,即可关闭屏幕。
sleep 1是让电脑暂停1秒,然后再执行xset dpms force off,这样可以防止输入关闭屏幕命令后释放键盘不及时。
在图形环境下可以创建一个快捷方式。
以下为转贴:http://blog.sina.com.cn/s/blog_4dca847601009qhd.html
  最近老大让看xorg.conf, xset,所以这两天就看了一下它们的man file,不懂的地方就在网上搜了搜,发现介绍得都是某一个点,要把所有的参数都介绍全的还没有,所以就想发一篇希望以后会对别人有所帮助。

   Xset是上层应用程序,主要用于在XWindow启动之后,对XWindow进行一些设置,在Linux中比较好的一点就是当你不知一个命令的用法时可以使用man
man xset
XSET(1)
XSET(1)

NAME
       xset - user preference utility for X

SYNOPSIS
       xset [-display display]
       [-b] [b {on|off}] [b [volume [pitch [duration]]]]
       [-bc] [bc]
       [-c] [c {on|off}] [c [volume]]
       [+dpms] [-dpms]
            [dpms standby [ suspend [ off]]]      [dpms force {standby|suspend|off|on}]
       [fp=pathlist] [-fp=pathlist] [+fp=pathlist] [fp-pathlist] [fp+pathlist]
       [fp default] [fp rehash]
       [-led [integer]] [+led [integer]]
       [led {on|off}]
       [mouse [accel_mult[/accel_div] [threshold]]] [mouse default]
       [p pixel color]
       [-r [keycode]]  [r [keycode]] [r {on|off}] [r rate delay [rate]]
       [s [length [period]]] [s {blank|noblank}] [s {expose|noexpose}] [s {on|off}] [s default] [s activate] [s reset]
       [q]

DESCRIPTION
       This program is used to set various user preference options of the display.

OPTIONS
       -display display
               This option specifies the server to use; see X(7).

b The b option controls bell volume, pitch and duration. This option
accepts up to three numerical parameters, a preceding dash(-), or a
“on/off” flag. If no parameters are given, or the “on” flag is used,
the system defaults will be used. If the dash or “off” are given, the
bell will be turned off. If only one numerical parameter is given, the
bell volume will be set to that value, as a percentage of its maximum.
Likewise, the second numerical parameter specifies the bell pitch, in
hertz, and the third numerical parameter specifies the duration in
milliseconds. Note that not all hardware can vary the bell characteris
tics. The X server will set the characteristics of the bell as closely
as it can to the user’s specifications.
bc The bc option
controls bug compatibility mode in the server, if possible; a preceding
dash(-) disables the mode, otherwise the mode is enabled. Various
pre-R4 clients pass illegal values in some protocol requests, and
pre-R4 servers did not correctly generate errors in these cases. Such
clients, when run against an R4 server, will terminate abnormally or
otherwise fail to operate correctly. Bug compatibility mode explicitly
reintroduces certain bugs into the X server, so that many such clients
can still be run. This mode should be used with care; new application
development should be done with this mode disabled.
The server must support the MIT-SUNDRY-NONSTANDARD protocol extension in order for this option to work.

c The c option controls key click. This option can take an optional
value, a preceding dash(-), or an “off” flag. If no parameter or the
“on” flag is given, the system defaults will be used. If the dash or
“off”flag is used, keyclick will be disabled. If a value from 0 to 100
is given, it is used to indicate volume, as a percentage of the
maximum. The X server will set the volume to the nearest value that the
hardware can support.

       -dpms   The -dpms option disables DPMS (Energy Star) features.

       +dpms   The +dpms option enables DPMS (Energy Star) features.

       dpms flags...
The dpms option allows the DPMS (Energy Star) parameters to be set. The
option can take up to three numerical values, or the “force”flag
followed by a DPMS state. The “force” flags forces the server to
immediately switch to the DPMS state specified. The DPMS state can be
one of ‘standby’ or ‘suspend’ , ‘off’, ‘on’ When numerical values are
given, they set the inactivity period (in units of seconds) before the
three modes are activated. The first value given is for the
“standby”mode, the second is for the “suspend”mode, and the third is
for the “off”mode. Setting these values implicitly enables the DPMS
features. A value of zero disables a particular mode.

fp= path,...
The fp= sets the font path to the entries given in the path argument.
The entries are interpreted by the server, not by the client. Typically
they are directory names or font server names, but the interpretation
is server-dependent.
       fp default
               The default argument causes the font path to be reset to the server’s default.
       fp rehash
The rehash argument resets the font path to its current value, causing
the server to reread the font databases in the current font path. This
is generally only used when adding new fonts to a font directory (after
running mkfontdir to recreate the font database).
       -fp or fp-
The -fp and fp- options remove elements from the current font path.
They must be followed by a comma-separated list of entries.

       +fp or fp+
This +fp and fp+ options prepend and append elements to the current
font path, respectively. They must be followed by a comma-separated
list of entries.

led The led option controls the
keyboard LEDs. This controls the turning on or off of one or all of the
LEDs. It accepts an optional integer, a preceding dash(-) or an
“off”flag. If no parameter or the “on”flag is given, all LEDs are
turned on. If a preceding dash or the flag “off”is given, all LEDs are
turned off. If a value between 1 and 32 is given, that LED will be
turned on or off depending on the existence of a preceding dash. A
common LED which can be controlled is the “Caps Lock” LED. “xset led 3”
would turn led #3 on. “xset -led 3” would turn it off. The particular
LED values may refer to dif ferent LEDs on different hardware.

mouse The m option controls the mouse parameters; it may be abbreviated
to ‘m’.The parameters for the mouse are ‘acceleration’and ‘threshold’
The acceleration can be specified as an integer, or as a simple
fraction. The mouse, or whatever pointer the machine is connected to,
will go ‘acceleration’ times as fast when it travels more than
‘threshold’ pixels in a short time. This way, the mouse can be used for
precise alignment when it is moved slowly, yet it can be set to travel
across the screen in a flick of the wrist when desired. One or both
parameters for the m option can be omitted, but if only one is given,
it will be interpreted as the acceleration. If no parameters or the
flag ‘default’is used, the system defaults will be set.

p The p option controls pixel color values. The parameters are the
color map entry number in decimal, and a color specification. The root
background colors may be changed on some servers by altering the
entries for BlackPixel and WhitePixel. Although these are often 0 and
1, they need not be. Also, a server may choose to allocate those colors
privately, in which case an error will be generated. The map entry must
not be a read-only color, or an error will result.

r
The r option controls the autorepeat. Invoking with "-r", or "r off",
will disable autorepeat, whereas "r", or "r on" will enable autorepeat.
Following the "-r" or "r" option with an integer keycode between 0 and
255 will disable or enable autorepeat on that key respectively, but
only if it makes sense for the particular keycode. Keycodes below 8 are
not typically valid for this command. Example: "xset -r 10" will
disable autorepeat for the "1" key on the top row
of an IBM PC keyboard.
If
the server supports the XFree86-Misc extension, or the XKB extension,
then a parameter of ‘rate’ is accepted and should be followed by zero,
one or two numeric values. The first specifies the delay before
autorepeat starts and the second specifies the repeat rate. In the case
that the server supports the XKBextension, the delay is the number of
milliseconds before autorepeat starts, and the rate is the number of
repeats per second. If the rate or delay is not given, it will be set
to the default value.

s The s option lets you set the
screen saver parameters. This option accepts up to two numerical
parameters, a ‘blank/noblank’flag, an ‘expose/noexpose’flag, an
‘on/off’ flag, an ‘activate/reset’ flag, or the ‘default’ flag. If no
parameters or the ‘default’ flag is used, the system will be set to its
default screen saver characteristics. The ‘on/off’ flags simply turn
the screen saver functions on or off. The ‘activate’ flag forces
activation of screen saver even if the screen saver had been turned
off. The ‘reset’ flag forces deactivation of screen saver if it is
active. The ‘blank’ flag sets the preference to blank the video (if the
hardware can do so) rather than display a background pattern, while
‘noblank’ sets the preference to display a pattern rather than blank
the video. The ‘expose’ flag sets the preference to allow window
exposures (the server can freely discard window contents), while
‘noexpose’ sets the preference to disable screen saver unless the
server can regenerate the screens without causing exposure events. The
length and period parameters for the screen saver function determines
how long the server must be inactive for screen saving to activate, and
the period to change the background pattern to avoid burn in. The
arguments are specified in seconds. If only one numerical parameter is
given, it will be used for the length.
       q   The q option gives you information on the current settings.

   有人肯定看到这一大堆的英文已经晕头转向了,还是希望有人把它汉化一下的,下面我来做一下汉化的工作,有一些解释都是我自己的理解有可能会不正确,希望哪天如果有人参考的话,发现明显的错误给予指出。

首先
-display 根据英文字面的意思是指出是哪个display在跑这个Xserver,不过我试了好多次想用这个选项,还是没有成功,所以具体怎么用还是不知道。
-b 打开和关闭电脑的嘟嘟的提示音,比如我们打开文件的是否,出错的时候发出的声音。但是听音乐还是可以照常听的
xset b on
xset b off
如果xset后面跟的是一个数值,哪默认提示音是打开的,并且它的音量就是此数值/100*最大音量。

-bc 关闭调试版本兼容机制
bc 打开调试版本兼容机制
xset –bc
xset bc

c 控制键盘的按键声
关闭/打开
xset c on
xset c off

dpms
xset –dpms 关闭电源之星
xset +dpms 打开电源之星,主要用来省电的
xset dpms 后面可以有三个参数的时间分别为(standby,suspend, off)
例如可以这样写
xset dpms 0 0 30 这样写就会在30s后关闭显示屏,进入省电模式。
同时这个选项还可以这样写
xset dpms force[standby|suspend|on|off]
可以强制进入以上四个模式
fp  虽然Xorg缺省已经支持了相当丰富的字体,但是还是有可能需要安装新的字体,例如某种中文字体。X Window的字体应该在配置文件中设置其搜寻路径,但在启动X Window之后,也可以使用xset命令来重新设置字体的搜寻路径。
xset fp+ :增加一个字体搜寻目录。
xset fp- :删除一个字体搜寻目录。
xset fp= :重新设置字体搜寻目录。
xset fp rehash:更改某个字体目录中的内容后,强迫系统刷新字体搜寻路径。
可以使用‘xset’使用工具来修改当前会话的字体路径。用命令 xset fp 来设置字体路径;把新元素添加到前面使用 xset +fp,而添加到后面使用 xset fp+。例如,
$ xset +fp /usr/local/fonts/Type1
$ xset fp+ /usr/local/fonts/bitmap
反过来,从字体的路径的前面删除一个元素使用‘xset -fp’,而从后面删除使用‘xset fp-’。

Lcd 可以用来控制键盘上的Led灯主要有
xset -lcd
xset +lcd
在我的键盘上只有第三个灯在亮Scroll Lock,其它两个都不能通过这个来控制,但是根据它上面说描述的好像键盘上所有的灯都可以控制的,但是我在实际的操作过程中,发现好像就只有第三个可以控制

Mouse这一选项是用来鼠标加速的,就跟windows有一个配置鼠标移动速度的很像
xset m 100/1 4
等同于xset m 100 4
不过这个要慎重设,虽然没有什么后果,但是100后鼠标移动速度超快根本看不到鼠标。

P 它说这一项是用来控制像素值的,但是我设置了后没有什么效果不知道为什么
xset p 0
界面颜色无任何效果


r用来设置键盘上重复按键的,可以这么解释,我们平常按住一个键的话比如长按1,在输入处会出现很多的1,但是如果使用
xset  r off则此时无论你长按什么键,它都只会出来一次,比如长按1,它只会出来一个1
还可以针对某一特定的值
xset –r 10就是将键盘上长按1的效果去掉了,其它的都还有长按的效果的。
xset –r 11就是将键盘上长按2的效果去掉了,其它的都还有长按的效果的。以此类推
它还有一些功能设置,比如按多就可以算是一个重复按键,你可以设置1s,2s(不过这种情况要在加载了Xserver的扩展module XKB extension后才会有的功能)


s这个选项和screen saver有关,根据我的理解screen save的意思是屏保的意思,与前面的dpms有点相像,同样具有省电的功能,总共有几个选项exposure 可以屏保,noexposure不能屏保,屏保的时间可以使用
xset s 10 这样的形式来确定,单位是s,如果没有对其进行操作10s后进入屏保
xset s expose
xset s noexpose
bank和nobank是用来确定屏保的画面
xset s blank (屏保后画面为黑色的)
xset s noblank(屏保后画面是一个图案,我的是一个X)

q这个选项没有什么其它的参数
xset –q 用来显示我们上面配置的参数如下:
Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000002
  auto repeat delay:  500    repeat rate:  30
  auto repeating keys:  00ffffffdffffbbf
                        fadfffdfffdfe5ef
                        ffffffffffffffff
                        ffffffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  10    cycle:  600
Colors:
  default colormap:  0x20    BlackPixel:  0    WhitePixel:  65535
Font
Path:
/root/.gnome2/share/cursor-fonts,/usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType,/root/.gnome2/share/fonts
Bug Mode: compatibility mode is disabled
DPMS (Energy Star):
  Standby: 0    Suspend: 0    Off: 0
  DPMS is Enabled
  Monitor is On
File paths:
  Config file:  /etc/X11/xorg.conf
  Modules path: /usr/lib/xorg/modules
  Log file:     /var/log/Xorg.0.log
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/16288/showart_1949718.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP