LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1788|回复: 12

推荐大家用 wmii (window-manager)

[复制链接]
发表于 2008-10-5 17:55:23 | 显示全部楼层 |阅读模式
开始学linux时用了一段wmaker
后来看 compiz fusion 挺炫,用了几天,可我的PIII实在太烂,这东西对我华而不实
这几天把所有的窗口管理器全装了个遍,最后发现wmii 最好用 ,速度快、易上手,操作方便
我把找到的资料贴上来大家一起研究


高效从wmii开始
In Linux on 28 August 2008 with no comments

wmii
在gnome下使用VIM,就像用短板的木桶,始终达不到应有的高效。而我一向不太追求效率,自看过Randy Pausch教授一场名为时间管理的讲座后颇为震惊,决意从我最亲密的计算机习惯改起。尽管从小我就一直被学校灌输所谓高效率的学习方法,可能心里对这种空虚的玩意儿不以为然,一直置若罔闻,忽视了自身应当到达的效率,而现在,也很难改掉懒散的习惯了。可我一向认为没有什么既定的事实,从拼音到五笔,windows到Linux,notepad到VIM,直到现在metacity(gnome)到wmii,我一直在改变着、挣扎着、快乐着。

wmii是我如今工作和学习时用的wm,日常还是用gnome。wmii不像gnome和kde广为人知,它存在的意义就是寻求高效的开发环境,对于非IT界人也许比较geeky。官方是这样介绍wmii的:wmii is a small,dynamic tiling(平铺) window manager for X11.对于gonme或kde用户,tiling比较陌生,科普一下->wiki

In computing, a tiling window manager(平铺式窗口管理器) is a window manager with an organization of the screen into mutually non-overlapping frames, as opposed to the more popular approach of coordinate-based stacking of overlapping objects (windows) that tries to fully emulate the desktop

从广义的wm概念讲,wm决定了窗口位置、桌面背景、菜单栏、右键菜单、键鼠控制、工作区、状态栏、运行对话框等。配置上,除极少数hacker对 FVWM这种会晕的wm,其它的wm大同小异,包括wmii。除FVWM贯彻到底的自由主义外,其它的wm或多或少有着自己的特点。 metacity(gnome),kwin(kde)一般认为为重量级wm,视觉上截然不同的感官效果,功能上差异明显,运行进程庞大。诸如 xfce,openbox,flukbox之类的wm属于轻量级wm,轻量级wm一般只有习惯上的差异,当然通过配置可达到功能上基本相似,以简洁为荣的轻量级wm,都占用较少的系统资源。而tilling wm较轻量级wm,一般省去了桌面背景、菜单栏、右键菜单,强化了窗口位置(特色的吸附特性)、键鼠控制、工作区、状态栏、运行对话框。twm的结构和特性大大提升了工作时编写代码的效率。

如今,tilling wm渐渐展露其非凡,众多twm的发行版也浮出了水面。据Arcthur所知,tilling wm至少有8种以上,例举下大致上有awesome、dwm、xmonad、ratpoison、ion3、wmii等。国内社区中,由于Linuxer 的局限,各tilling wm在国内社区中露脸的机会相当稀少,论坛上鲜有其讨论(Archlinux社区相对较多)。当然,它们的缺陷也屡见不鲜,如wmii标题栏中文极难配置,需要安装特定的字体,又只能配置一种字体,每个窗口都有一个标题栏,fork的进程太多,比较耗资源等等。其它twm亦不例外的有一些不足,因为我正在学习java和ruby,wmii可以很方便的用ruby来扩展,对于rubyist,ruby-wmii是个很好的起点,它只是一个配置文件,可以在它的基础上做修改,通读一遍代码基本能可以了解wmii的各个方面。

vim+xterm+wmii,完全在键盘上操作的快感也只有在体验过这样的组合后才会知道。最后,贴上wmii的快捷键

Key bindings

These are the default aliases:

MODKEY   Mod1
MODKEY2  Mod4  (often win key)
UP       k
DOWN     j
LEFT     h
RIGHT    l

MODKEY2-space        Switch between raw and normal input modes.
                     The current mode is indicated in the bar. All other key
                     bindings are ignored in raw mode.
MODKEY-Control-y     Run program with given tag (uses wmiimenu twice to get
                     the tag and the program).
MODKEY-a             Ask for action and execute it.
                     Includes internal and external (i.e. dependent on a
                     script in $HOME/.wmii-3) actions. Remembers the last
                     actions executed and presents them at the beginning.
MODKEY-p             Ask for a program and execute it.
                     The list of programs is updated periodically and cached.
                     Remembers the last programs executed and presents them at
                     the beginning.
MODKEY-0..9          Choose either the corresponding numerical view (if it
                     exists) or the (N-last_numerical_view)th non-numeric view
                     e.g. if the views are  1 2 3 4 code irc web
                     and you press MODKEY-6, it'll take you to  irc
MODKEY-Shift-0..9    Either replace the the numeric tag of the current client
                     or retag it as the (N-last_numerical_view)th non-numeric
                     view.
MODKEY-t             Ask for view to move to.
                     Tries to sort the choices intelligently based on
                     previous movement.
MODKEY-LEFT          Select prev column.
MODKEY-RIGHT         Select next column.
MODKEY-UP            Select prev client.
MODKEY-DOWN          Select next client.
MODKEY-space         Toggle managed/floating layer.
MODKEY-d             Set default mode.
MODKEY-s             Set stacked mode.
MODKEY-m             Set max mode.
MODKEY-f             Maximize current floating client.
MODKEY-i             Move bottom of current client down (i.e. enlarge)
MODKEY-Shift-i       Move bottom of current client up (i.e. shrinken).
MODKEY-Return        Launch terminal.
MODKEY-Shift-LEFT    Send to prev column.
MODKEY-Shift-RIGHT   Send to next column.
MODKEY-Shift-DOWN    Swap with lower client.
MODKEY-Shift-UP      Swap with upper client.
MODKEY-Shift-space   Toggle managed/floating layer for client.
MODKEY-Shift-c       Kill current client
MODKEY-r             Go back to previous view (where we came from).
                     Pressing more than once makes you cycle between 2 views.
MODKEY-Control-UP,
MODKEY-comma         Move to (lexicographically) preceding view.
MODKEY-Control-DOWN,
MODKEY-period        Move to (lexicographically) following view.
MODKEY2-Shift-UP,
MODKEY2-comma        Move to (lexicographically) preceding view within
                     current namespace.
MODKEY2-Shift-DOWN,
MODKEY2-period       Move to (lexicographically) following view within
                     current namespace.
MODKEY-Shift-t       Retag current client. Allows +/- modifiers to add/remove
                     tag.
MODKEY-Shift-r       Retag current client and move to corresponding view.
                     Alloes +/- modifiers.
MODKEY2-Shift-t      Retag in the namespace. Given a client tagged as foo+bar:
                       baz   retags it as bar:baz
                       +baz  retags it as foo+bar+bar:baz
                     Given foo+bar:baz, -baz  retags as  foo
MODKEY2-Shift-r      Retag as MODKEY2-Shift-t and moves to new view.
MODKEY2-a..z         Jump to first view whose name starts with the given
                     letter, sorted with intellisort (favors views chosen
                     before)
MODKEY-plus          Move forward in view history
MODKEY-minus         Move backwards in view history.
MODKEY-b             Open bookmark (see README.applets for further
                     information).
MODKEY-Shift-b       Bookmark URL in X11 primary selection buffer. Again, see
                     README.applets.

Internal actions (MODKEY-a)

browser:     if given an argument, open the given URL in a browser, otherwise
              ask for it
google:      same as 'browser', but searches with google
screenshot:  takes a screenshot in $HOME/tmp/NAME-IDX.png, where NAME is
              either the given parameter or 'screenshot', and IDX is
              incremented automatically
rename-view: change the name of the current view, and retag all clients
              accordingly. Takes the new name as a parameter, or asks for it.
wmiirc:      reload the wmiirc configuration
config-help: shows information about how to use and configure wmiirc, as well
              as how to write plugins
 楼主| 发表于 2008-10-5 18:30:04 | 显示全部楼层
http://www.linuxsir.cn/bbs/attac ... =1&d=1223230907
图1



上面的截图中,wmii的右下角,显示了当前mpd正在播放的歌曲,歌词,系统负荷,日期时间等:

这个地方的内容由文件/rbar/status决定,可以用wmiir read /rbar/status查看。
在wmiirc中定义了过程status,就可以使用 status | wmiir write /rbar/status 更新屏幕上的图像:
http://www.linuxsir.cn/bbs/attac ... =1&d=1223233681
这个过程中,调用了程序 echo, mpc, tail, head(我比较笨拙,暂时用了这个愚蠢的方法显示正在播放的歌曲名), date, uptime, sed, mpclyrics,尽管sh自己内建了一些命令,但是mpc, mpclyrics(哈,这个现在在网上找不到,只有我有~)等是外部程序,一定要调用运行的。另外,还要执行wmiir向/rbar/status写东西。

而这个status过程一秒钟会被执行一次,也就是说,为了屏幕右下角的这一行字,系统就要每秒钟不动声色地执行这么多程序。在wmii下,wmiir程序被调用的频率极高,单击鼠标,按下或松开一个键,改变焦点等等都会产生事件,执行wmiir。

用惯了Windows,看看这些,显得很可怕吧~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-5 19:35:22 | 显示全部楼层
这个是 Status Bar (屏幕最下面的状态栏)的编辑,谁给翻译一下
Configuring Wmii's Status Bar
July 27th, 2007
Posted by sam in

I discovered the default status bar script while poking around and added a few lines to make it more useful on my laptop. I post the whole thing here to motivate anyone who has not tried wmii to give it a chance. The status bar script can be run without restarting wmii using MOD-a. I noticed that I sometimes wound up with a few instances running so an occasional kill wouldn’t hurt if you see strange things happening on the status bar.

There’s nothing stopping folks from using ruby, scheme, haskell, python, or compiled C to write these scripts since the interface to wmii is a p9 filesystem. Enough gushing. Here’s a shell script that shows battery info, system load, cpu speed, wireless info, and the time. Most of this code is the default install for wmii but the while loop has been edited. I should also note that it isn’t necessary to edit in /etc/X11/wmii-3/ as scripts in $HOME/.wmii-3/ of the same name are preferred.
$HOME/.wmii3/status or /etc/X11/wmii-3/status (on ubuntu at least)
#########################################################################################################
  1. #!/bin/sh
  2. xwrite() {
  3.     file="$1"; shift
  4.     echo -n "$@" | wmiir write "$file"
  5. }
  6. wmiir remove /bar/status 2>/dev/null && sleep 2
  7. wmiir create /bar/status
  8. xwrite /bar/status/colors $WMII_NORMCOLORS
  9. ## Here is the place to customize
  10. while xwrite /bar/status/data \
  11.     `acpi | sed 's/.*Battery .: //g; s/discharging/-/g; s/charging/+/g; s/charged//g; s/%.*/%/g; s/, //g'` \
  12.     `uptime | sed 's/.*: //; s/,//g; s/\s.*//g'` \
  13.     `cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;'` \
  14.     `iwconfig eth1 | grep ESSID | sed 's/.*ESSID:"//g; s/"\s*$//g'` \
  15.     `iwconfig eth1 | grep 'Link Quality' | sed 's/\s*Link Quality=//; s/\s.*//'` \
  16.     `date +%H:%M:%S`
  17. do
  18.     sleep 1
  19. done
  20. #!/bin/sh
  21. xwrite() {
  22.     file="$1"; shift
  23.     echo -n "$@" | wmiir write "$file"
  24. }
  25. wmiir remove /bar/status 2>/dev/null && sleep 2
  26. wmiir create /bar/status
  27. xwrite /bar/status/colors $WMII_NORMCOLORS
  28. ## Here is the place to customize
  29. while xwrite /bar/status/data \
  30.     `acpi | sed 's/.*Battery .: //g; s/discharging/-/g; s/charging/+/g; s/charged//g; s/%.*/%/g; s/, //g'` \
  31.     `uptime | sed 's/.*: //; s/,//g; s/\s.*//g'` \
  32.     `cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;'` \
  33.     `iwconfig eth1 | grep ESSID | sed 's/.*ESSID:"//g; s/"\s*$//g'` \
  34.     `iwconfig eth1 | grep 'Link Quality' | sed 's/\s*Link Quality=//; s/\s.*//'` \
  35.     `date +%H:%M:%S`
  36. do
  37.     sleep 1
  38. done
复制代码
#########################################################################################################

I still mouseclick the time and wireless info occasionally. Bad habit! The wmii way is MOD-Enter, cal, Ctrl-D. You have to love the way existing windows resize to accommodate the new terminal, then snap back to their previous position as it disappears. If the terminal contains an interesting dialog, just MOD-Shift-’number’ to tag it into a new workspace. I’ll be using vim’s shell execution a lot less.

Closing wmii tip: Set firefox to open new windows in a tab (Edit->references->Tabs) or you’ll go nuts.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-5 19:38:34 | 显示全部楼层
上贴中的 ": %" ( : 和 % 之间没空格 ,)被自动替换成:%M ,郁闷
回复 支持 反对

使用道具 举报

发表于 2008-10-5 19:53:19 | 显示全部楼层
wmii 以前玩過,但覺得其配置太麻煩了,現在改用 jwm,也很爽。

謝謝樓主分享,有空再玩玩 :)
回复 支持 反对

使用道具 举报

发表于 2008-10-5 20:21:06 | 显示全部楼层
代码修改成[code]圈起来不就好了。而且也有不自动转换表情的选项
回复 支持 反对

使用道具 举报

发表于 2008-10-6 08:57:02 | 显示全部楼层
习惯 FVWM 的漂过。
也了解一下大家都还有什么更 geek 的用法,呵呵。这个和 dOOm3d 兄的 wm 有一拼,呵呵。
回复 支持 反对

使用道具 举报

发表于 2008-10-6 11:16:56 | 显示全部楼层
用过一段时间 wmii,觉得还是有点复杂,还是换回了 dwm
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-10-7 12:52:49 | 显示全部楼层
wmii 和dwm思想差不多

适合自己的就是好的
回复 支持 反对

使用道具 举报

发表于 2008-10-7 18:58:37 | 显示全部楼层
这玩意和用fvwm有何区别!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表