再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

仅供存放个人的配置文件,不要在本版发问。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#1

帖子 ljj_jjl2008 » 2011-08-01 11:40

再一次折腾:启动后把几个最常用的程序都自动启动起来,然后缩小窗口,布置在屏幕四周,鼠标指到谁谁就自动放大(其他的自动缩小),离开就缩回去。

最差也要把程序平铺,程序之间有可以用鼠标托动的分割线,一托动就调整大小。

其他的尽量简洁,菜单、图标什么的,都尽量省略吧。

这个只是一个想法,还没有任何思路呀。至于能不能实现都不知道呀。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#2

帖子 ljj_jjl2008 » 2011-08-01 11:40

研究了一下午了,感觉这个目标有点太难了:
这牵扯到程序的移动和调整大小,程序移动及调整大小一般都是程序发出请求,WM接受请求并提供功能。
顶多就是WM在程序创建时为程序定制一些特殊要求(什么无边框、最大化、出现位置之类的),然后程序没有请求,WM就不能再随便移动和调整程序窗口了。
即使FVWM可以用快捷键移动窗口调整大小,也是只针对当前“焦点”窗口进行操作,象我这样为每个窗口都记住位置,根据鼠标的位置判断应该把哪个窗口放大哪个缩小,缩小的还要回到自己原先的位置,好像基本办不到了。
FVWM也没有IF判断语句吧?也没有变量吧?很难呀!象EE大神也是只是做到了:快捷键+鼠标手势替代了标题栏+边框,也没有做到智能移动调整窗口呀!

难道要失败?

Ratpoison
awesome
musca
dwm
Subtle
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#3

帖子 ljj_jjl2008 » 2011-08-01 11:40

再一次折腾:启动后把几个最常用的程序都自动启动起来,然后缩小窗口,布置在屏幕四周,鼠标到谁谁就自动放大(其他的自动缩小)(今天实现了“指”到谁谁放大的效果----2011.08.08注)
(请在4楼已经完成的前提下继续下面的操作)
已经实现,效果很好:

1,安装awesome

代码: 全选

sudo apt-get install awesome awesome-extra
说明:awesome是一种“平铺”式桌面管理器,特点是在awesomu下,打开的程序没有边框和标题栏,打开的程序全部按一种特定方式“平铺”在桌面上。其实他有多种桌面布局,即有多种“铺”的方式。因为程序没有边框,所以要用awesome,必须先记住几个关键的按键组合:

以下是必须记住的(Mod4指win键,有时左边的不行,就试试右边的,可以在配置文件中换成别的键)
Mod4 + Shift + c
关掉当前窗口
Mod4 + j
切换到下一个窗口
Mod4 + k
切换到前一个窗口
Mod4 + h
把主区域(master width)的宽度增大5%
Mod4 + l
把主区域(master width)的宽度减少5%
Mod4 + Control + space
切换当前窗口是否为浮动的
Mod4 + F1
运行命令
Mod4 + Return
打开一个终端
Mod4 + m 最大化/还原当前窗口
Mod4 + f 全屏/恢复当前窗口
以下是需要以后慢慢记的。
Mod4 + Left
查看前一个tag
Mod4 + Right
查看后一个tag
Mod4 + 1-9
切换到tag 1-9
Mod4 + Control + j
切换到下一个屏幕
Mod4 + Control + k
切换到前一个屏幕
Mod4 + Shift + j
当前窗口和前一个窗口互换位置
Mod4 + Shift + k
当前窗口和后一个窗口互换位置
Mod4 + Shift + h
增加主区域窗口的数量
Mod4 + Shift + l
减少主区域窗口的数量
Mod4 + Control + h
增加非主区域窗口的数量
Mod4 + Control + l
减少非主区域窗口的数量
Mod4 + space
把当前tag更换为下一种布局
Mod4 + Shift + space
把当前tag更换为前一种布局
Mod4 + Shift + i
显示当前窗口的class和instance。这在写脚本的时候尤其有用
Mod4 + Shift + r
重绘当前窗口
Mod4 + Control + r
重启awesome
Mod4 + Shift + q
退出awesome
2,简单调整配置文件

(1)文件 /minilinux/etc/slim.conf 加上awesome的sessions ,
sessions default,awesome,jwm,openbox,startxfce4,ion3,icewm,wmaker,blackbox
(2)文件 /minilinux/etc/X11/xinit/xinitrc 加上以下内容(重点是awesome对应部分):

代码: 全选

DEFAULT_SESSION=jwm

case $1 in
kde)
   exec startkde
   ;;
xfce4)
   exec startxfce4
   ;;
icewm)
   icewmbg &
   icewmtray &
   exec icewm
   ;;
wmaker)
   exec wmaker
   ;;
blackbox)
   exec blackbox
   ;;
jwm)
    jwm &
#    fcitx & 
    ;;
awesome)
    exec awesome &
    ;;
*)
   exec $DEFAULT_SESSION
   ;;
esac
(3)编辑:/etc/X11/Xsession.d/20slim_locale如下:(重点是. /etc/environment和awesome对应部分)

代码: 全选

#!/bin/sh
. /etc/default/locale
. /etc/environment
for lt_var in $(env -i locale | sed -e 's/=.*$//') LANGUAGE
do
   eval "if test \"\${$lt_var+set}\" = set; then
      export $lt_var
      fi"
done

case $1 in
kde)
   exec startkde
   ;;
xfce4)
   exec startxfce4
   ;;
icewm)
   icewmbg &
   icewmtray &
   exec icewm
   ;;
wmaker)
   exec wmaker
   ;;
blackbox)
   exec blackbox
   ;;
jwm)
    wine c:/ipmsg/ipmsg.exe &
    rox-filer -p default &
    parcellite &
    ;;
openbox)
    exec openbox-session &
    ;;
awesome)
    parcellite &
    geany &
    rox-filer &
    sakura &
    chromium-browser &
   ;;
*)
   exec $DEFAULT_SESSION
   ;;
esac
(4)把/etc/xdg/awesome目录复制到~/.config下
(5)编辑:~/.config/awesome/debian/menu.lua
主要是加上google浏览器的菜单项。
找到:

代码: 全选

Debian_menu["Debian_应用程序_网络"] = {
	{ "通信", Debian_menu["Debian_应用程序_网络_通信"] },
在下面加上一行:

代码: 全选

	{"chromium-browser ","chromium-browser"},
(6)简单编辑~/.config/awesome/rc.lua
找到:

代码: 全选

tags = {}
for s = 1, screen.count() do
    -- Each screen has its own tag table.
    tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
end
修改成:

代码: 全选

tags = {
   names  = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12},
   layout = { layouts[12], layouts[1], layouts[2], layouts[3], layouts[4],
              layouts[5], layouts[6], layouts[7], layouts[8], layouts[9], layouts[10], layouts[11]
 }}
 for s = 1, screen.count() do
     tags[s] = awful.tag(tags.names, s, tags.layout)
 end
(作用:为每一种布局分别创建一个tag,并且把我们要用的布局放在第一位)
文件最后加上一句:(作用是把主窗口加大40%)

代码: 全选

awful.tag.incmwfact( 0.4)
(下面内容是为了实现“指”到谁谁放大的功能的-----2011.08.08添加)
找到以下部分:

代码: 全选


        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
            and awful.client.focus.filter(c) then
            client.focus = c
        end
在他后面添加:(让指到的非浮动的可聚焦的窗口获得焦点,然后暂时把“鼠标进入”事件作废,以便让鼠标光标有时间回到主窗口----2011.08.08添加)
又改进了一点:浮动窗口不能自动排列在四周,所以如果有浮动窗口,又有“指”到谁谁就出现在中心的功能,则浮动窗口永远没有出现在中心或者上层的机会。
所以我设置为:要操作浮动窗口,需要点击顶部状态栏选中他,这时“指到谁谁居中”功能自动停止。当关闭浮动窗口,或者切换到非浮动窗口时,此功能再自动开始。
并且假如浮动窗口被盖住了,指一下四周的其他窗口,浮动窗口就会升到在最上层。浮动窗口一般是程序的对话框,比如打开、保存之类的。----2011.08.08下午。

代码: 全选

        if awful.layout.get(c.screen) == awful.layout.suit.magnifier 
            and awful.client.focus.filter(c) 
            and not awful.client.floating.get(c) 
            and not awful.client.floating.get(client.focus) then
            client.focus = c
            mouse.coords({},"mouse::enter")
        end
        if awful.client.floating.get(client.focus) then
           client.focus:raise()
        end
解决程序调用对话框时,主窗口胡乱变换的BUG
文件 /usr/share/awesome/lib/awful/layout/suit/magnifier.lua
找到这一段:

代码: 全选

    if client.floating.get(focus) then
        focus = cls[1]
        fidx = 1
    end
改成:

代码: 全选

   if client.floating.get(focus) then
        for k, c in ipairs(cls) do
            if c == focus then
                fidx = k
                break
            end
         end
        focus = cls[k]
    end
找到:

代码: 全选

        geometry.x = area.x + (area.width - geometry.width) / 2
改成:

代码: 全选

        geometry.x = area.x + (area.width - geometry.width) + 1
以上语句作用是:把主窗口延伸到了屏幕最右边,因为右边有滚动条,这种“指到就变”的方式下,点滚动条时经常点过了界,变成切换窗口了,所以让窗口一直撑到最右边比较方便。

配置文件在链接的11楼和12楼

完成,注销,slim里面f1选择awesome登陆,然后就会看见上面有一个状态栏,有菜单,有托盘,有时钟。
屏幕中间有一个程序窗口(不是全屏),四周露出来其他程序的一点边。鼠标指到漏出来的其他程序,其他程序就到中间来了。

Mod4 + h
把窗口减少5%

Mod4 + l
把窗口增大5%

Mod4 + Shift + c
关掉当前窗口

Mod4 + j
切换到下一个窗口

Mod4 + k
切换到前一个窗口

窗口操作:有时候我们想移动窗口的位置,或是调整窗口的大小。在浮动布局中,Win + 鼠标左键可以移动窗口的位置,而 Win + 鼠标右键则可以调整窗口的大小。
最后的一些配置:

代码: 全选

sudo update-alternatives --install /usr/bin/www-browser-chromium www-browser /usr/bin/chromium-browser 25
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/geany 25
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/sakura 25
sudo update-alternatives --config x-terminal-emulator
sudo update-alternatives --config editor
sudo update-alternatives --config www-browser
执行后3句时,会让你选择用哪个程序作为默认,分别选择sakrua、geany、chromium-browser。这样修改系统默认的终端、文本编辑器、网页浏览器。
编辑文件 ~/.config/awesome/rc.lua,找到:
editor = os.getenv("EDITOR") or "editor"
editor_cmd = terminal .. " -e " .. editor
修改成:
editor = os.getenv("EDITOR") or "geany"
editor_cmd = editor
(也是把geany设为默认编辑器)
已知缺陷:
(1)程序弹出的对话框(打开、保存文件之类的),现在也是这种风格的,并且有时弹出对话框同时反而切换到其他程序里面,把对话框反而覆盖住了。需要在顶部状态栏点一下,切换回来。
-----此问题已彻底解决----2011.08.09
(2)另外,有时从菜单中新打开的程序自动最大化或者全屏,需要按Mod4 + m(最大化/还原当前窗口)或者Mod4 + f( 全屏/恢复当前窗口)切换一下。
(3)鼠标主题无效,鼠标黑黑的不好看。
(4)默认的这种布局,浮动窗口不能自动浮动到中间大窗口上面,需要在状态栏切换一下。
-----此问题已彻底解决----2011.08.09
(5)点击边缘的窗口,会产生一次“鼠标单击”事件,如果不小心点到文件上,文件会倍打开,点到按钮上,按钮事件也会倍激活。所以尽量用win+j(k)切换窗口。
----此问题已解决,现在是鼠标“指到”谁谁就放大,不存在这个问题了。---2011.08.08注

以下是效果截图(为了看出效果,我把中间窗口缩小了一些。实际应用时可以放大)
2011-08-02-101215_1280x1024_scrot.png
补充说明:这个环境中也没有关机和重启的菜单项目(菜单中的restart和quit只是重启和退出图形界面,不是重启计算机),关机和重启用以下方法:
1,菜单中点击“quit”,退出图形界面,到slim登陆界面
2,用户名处输入“halt”或者“reboot”(不包括引号,分别表示“关机”和“重启”)
3,密码输入root的密码。即完成关机和重启。

代码: 全选

sudo apt-get install kdesudo
(发现一个BUG:使用gksu会在~目录遗留一个 .gksu.lock ,这个文件的存在会引起下次重启时在slim登陆界面输入用户名后直接跳出到字符界面,所以安装了kdesudo代替gksu。为了稳定和安全,请把配置文件~/.config/awesome/debian/menu.lua中的gksu全部替换为kdesudo。----2011.08.06)
头像
cjxgm
帖子: 1952
注册时间: 2010-04-23 20:40
系统: Arch Linux
来自: 浙江·杭州
联系:

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#4

帖子 cjxgm » 2011-08-01 20:25

自己写个 WM 即可解决 :em06
Clanjor Prods. | Develop for Developers. (C++, Lua) | 作曲编曲 | 实时渲染引擎
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#5

帖子 eexpress » 2011-08-01 20:36

dock不就是这样。何必折腾另类的。
fvwm的hover事件,记得是一个补丁。用FvwmButtons?
● 鸣学
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#6

帖子 ljj_jjl2008 » 2011-08-03 16:12

话说:想把这个折腾的更好看一点,结果找到配置文件的说明看了两个多小时,还是没有学会。他的配置文件居然是一种编程语言的语法规则,有判断语句,可以使用变量,还是面向对象的。写配置文件基本上就是一种编程过程。
并且听说他的配置文件的语法规则在不同版本中还不一样,经常费劲写好语句,一升级就不能用了。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#8

帖子 ljj_jjl2008 » 2011-08-08 9:02

(下面内容是为了实现“指”到谁谁放大的功能的-----2011.08.08添加)
找到以下部分:

代码: 全选

        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
            and awful.client.focus.filter(c) then
            client.focus = c
        end
在他后面添加:(让指到的非浮动的可聚焦的窗口获得焦点,然后暂时把“鼠标进入”事件作废,以便让鼠标光标有时间回到主窗口----2011.08.08添加)
又改进了一点:浮动窗口不能自动排列在四周,所以如果有浮动窗口,又有“指”到谁谁就出现在中心的功能,则浮动窗口永远没有出现在中心或者上层的机会。
所以我设置为:要操作浮动窗口,需要点击顶部状态栏选中他,这时“指到谁谁居中”功能自动停止。当关闭浮动窗口,或者切换到非浮动窗口时,此功能再自动开始。
并且假如浮动窗口被盖住了,指一下四周的其他窗口,浮动窗口就会升到在最上层。浮动窗口一般是程序的对话框,比如打开、保存之类的。----2011.08.08下午。

代码: 全选

        if awful.layout.get(c.screen) == awful.layout.suit.magnifier 
            and awful.client.focus.filter(c) 
            and not awful.client.floating.get(c) 
            and not awful.client.floating.get(client.focus) then
            client.focus = c
            mouse.coords({},"mouse::enter")
        end
        if awful.client.floating.get(client.focus) then
           client.focus:raise()
        end
完成,注销,slim里面f1选择awesome登陆,然后就会看见上面有一个状态栏,有菜单,有托盘,有时钟。
屏幕中间有一个程序窗口(不是全屏),四周露出来其他程序的一点边。鼠标指到漏出来的其他程序,其他程序就到中间来了。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#9

帖子 ljj_jjl2008 » 2011-08-08 13:28

现在急需解决的问题还是awesome里面的程序打开对话框时,有时会自动切换主窗开口。
已经分析出了一点原因:
我用的是magnifier布局,这种布局特点是:主窗口占据中央,其他窗口靠边站。
应该是打开对话框的瞬间,主窗口暂时失去了焦点(focus),可是好像awesome里面有个机制:一个tag里面必须有一个程序有焦点,所以系统就把焦点交给了其他程序,然后就触发了将新获得焦点的程序转变为主窗口移动到屏幕中央的指令,结果就是刚打开对话框的程序靠边站了,一个无所谓的程序到中央来了。

苦恼呀,还是没有找到怎么设置配置文件,把这个问题解决掉。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#10

帖子 ljj_jjl2008 » 2011-08-08 17:37

没有从根本上解决以上问题,先变通解决了一下:
写了几句配置语句,把8楼的语句改进了一下,设置成让弹出的对话框当作浮动窗口,并且让浮动优先出现在上层,让对话框不会被盖住,算是解决了一半吧。
可惜主窗口还是被挤到一边去了,把对话框填好点确定后,还要拿鼠标指一下把他叫回来。
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#11

帖子 ljj_jjl2008 » 2011-08-09 6:04

终于彻底解决了:找到了负责布局“magnifier”的文件,把他的规则改动了一下,就好了。
文件 /usr/share/awesome/lib/awful/layout/suit/magnifier.lua

代码: 全选

--------------------------------------------------------------------------
-- @author Julien Danjou <[email protected]>
-- @copyright 2008 Julien Danjou
-- @release v3.4.10
---------------------------------------------------------------------------

-- Grab environment we need
local ipairs = ipairs
local math = math
local tag = require("awful.tag")
local capi =
{
    client = client,
    screen = screen
}
local client = require("awful.client")

--- Magnifier layout module for awful
module("awful.layout.suit.magnifier")

function arrange(p)
    -- Fullscreen?
    local area = p.workarea
    local cls = p.clients
    local focus = capi.client.focus
    local mwfact = tag.getmwfact(tag.selected(p.screen))
    local fidx

    -- Check that the focused window is on the right screen
--    if focus and focus.screen ~= p.screen then focus = nil end
-- 上一句是我注释掉的,这句用处不大,并且会引起屏幕连续闪动。
--    if not focus and #cls > 0 then
--        focus = cls[1]
--        fidx = 1
--    end
--上面语句也要注释掉。
    -- If focused window is not tiled, take the first one which is tiled.
    if client.floating.get(focus) then
        for k, c in ipairs(cls) do
            if c == focus then
                fidx = k
                break
            end
         end
        focus = cls[k]
    end
--上面这一段IF语句是我重写的,作用是发现浮点窗口后,就找到最后一次居中的窗口,把他居中。原来语句如下:(原来语句是找到第一次居中的窗口并居中)
--    if client.floating.get(focus) then
--        focus = cls[1]
--        fidx = 1
--    end

    -- Abort if no clients are present
    if not focus then return end

    local geometry = {}
    if #cls > 1 then
        geometry.width = area.width * math.sqrt(mwfact)
--        geometry.height = area.height * math.sqrt(mwfact)
        geometry.height = area.height
--        geometry.x = area.x + (area.width - geometry.width) / 2
        geometry.x = area.x + (area.width - geometry.width) + 1
--        geometry.y = area.y + (area.height - geometry.height) /2
        geometry.y = 22
--以上语句有改动,把主窗口延伸到了屏幕最右边,因为右边有滚动条,这种“指到就变”的方式下,点滚动条时经常点过了界,变成切换窗口了,所以让窗口一直撑到最右边比较方便。同时我把窗口上下也撑到了边(上面有状态条,所以上面留了22点的宽度)
--以下语句保持原样,没有动。
    else
        geometry.x = area.x
        geometry.y = area.y
        geometry.width = area.width
        geometry.height = area.height
    end
    focus:geometry(geometry)
    focus:raise()

    if #cls > 1 then
        geometry.x = area.x
        geometry.y = area.y
        geometry.height = area.height / (#cls - 1)
        geometry.width = area.width

        -- We don't know what the focus window index. Try to find it.
        if not fidx then
            for k, c in ipairs(cls) do
                if c == focus then
                    fidx = k
                    break
                end
            end
        end

        -- First move clients that are before focused client.
        for k = fidx + 1, #cls do
            cls[k]:geometry(geometry)
            geometry.y = geometry.y + geometry.height
        end

        -- Then move clients that are after focused client.
        -- So the next focused window will be the one at the top of the screen.
        for k = 1, fidx - 1 do
            cls[k]:geometry(geometry)
            geometry.y = geometry.y + geometry.height
        end
    end
end

name = "magnifier"
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#12

帖子 ljj_jjl2008 » 2011-08-09 6:17

也把改动后的rc.lua贴出来:
~/.config/awesome/rc.lua

代码: 全选

-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")

-- Load Debian menu entries
require("debian.menu")

-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/usr/share/awesome/themes/default/theme.lua")

-- This is used later as the default terminal and editor to run.
terminal = "x-terminal-emulator"
editor = os.getenv("EDITOR") or "geany"
editor_cmd = editor

-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"

-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
    awful.layout.suit.floating,
    awful.layout.suit.tile,
    awful.layout.suit.tile.left,
    awful.layout.suit.tile.bottom,
    awful.layout.suit.tile.top,
    awful.layout.suit.fair,
    awful.layout.suit.fair.horizontal,
    awful.layout.suit.spiral,
    awful.layout.suit.spiral.dwindle,
    awful.layout.suit.max,
    awful.layout.suit.max.fullscreen,
    awful.layout.suit.magnifier
}
-- }}}

-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {
   names  = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12},
   layout = { layouts[12], layouts[1], layouts[2], layouts[3], layouts[4],
              layouts[5], layouts[6], layouts[7], layouts[8], layouts[9], layouts[10], layouts[11]
}}
for s = 1, screen.count() do
     tags[s] = awful.tag(tags.names, s, tags.layout)
end
-- }}}
--上面的tag和for语句我改动过,为的是让我常用的magnifier布局放在tag1上面,并分别为每一种布局建立了一个tag
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
   { "manual", terminal .. " -e man awesome" },
   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
   { "restart", awesome.restart },
   { "quit", awesome.quit }
}

mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
                                    { "Debian", debian.menu.Debian_menu.Debian },
                                    { "open terminal", terminal }
                                  }
                        })

mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
                                     menu = mymainmenu })
-- }}}

-- {{{ Wibox
-- Create a textclock widget
mytextclock = awful.widget.textclock({ align = "right" },"%Y-%m-%d %H:%M")

-- Create a systray
mysystray = widget({ type = "systray" })

-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
                    awful.button({ }, 1, awful.tag.viewonly),
                    awful.button({ modkey }, 1, awful.client.movetotag),
                    awful.button({ }, 3, awful.tag.viewtoggle),
                    awful.button({ modkey }, 3, awful.client.toggletag),
                    awful.button({ }, 4, awful.tag.viewnext),
                    awful.button({ }, 5, awful.tag.viewprev)
                    )
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
                     awful.button({ }, 1, function (c)
                                              if c == client.focus then
                                                  c.minimized = true
                                              else
                                                  if not c:isvisible() then
                                                      awful.tag.viewonly(c:tags()[1])
                                                  end
                                                  -- This will also un-minimize
                                                  -- the client, if needed
                                                  client.focus = c
                                                  c:raise()
                                              end
                                          end),
                     awful.button({ }, 3, function ()
                                              if instance then
                                                  instance:hide()
                                                  instance = nil
                                              else
                                                  instance = awful.menu.clients({ width=250 })
                                              end
                                          end),
                     awful.button({ }, 4, function ()
                                              awful.client.focus.byidx(1)
                                              if client.focus then client.focus:raise() end
                                          end),
                     awful.button({ }, 5, function ()
                                              awful.client.focus.byidx(-1)
                                              if client.focus then client.focus:raise() end
                                          end))

for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = awful.widget.layoutbox(s)
    mylayoutbox[s]:buttons(awful.util.table.join(
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)

    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist(function(c)
                                              return awful.widget.tasklist.label.currenttags(c, s)
                                          end, mytasklist.buttons)

    -- Create the wibox
    mywibox[s] = awful.wibox({ position = "top", screen = s })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = {
        {
            mylauncher,
            mytaglist[s],
            mypromptbox[s],
            layout = awful.widget.layout.horizontal.leftright
        },
        mylayoutbox[s],
        mytextclock,
        s == 1 and mysystray or nil,
        mytasklist[s],
        layout = awful.widget.layout.horizontal.rightleft
    }
end
-- }}}

-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
    awful.button({ }, 3, function () mymainmenu:toggle() end),
    awful.button({ }, 4, awful.tag.viewnext),
    awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}

-- {{{ Key bindings
globalkeys = awful.util.table.join(
    awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
    awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
    awful.key({ modkey,           }, "Escape", awful.tag.history.restore),

    awful.key({ modkey,           }, "j",
        function ()
            awful.client.focus.byidx( 1)
            if client.focus then client.focus:raise() end
        end),
    awful.key({ modkey,           }, "k",
        function ()
            awful.client.focus.byidx(-1)
            if client.focus then client.focus:raise() end
        end),
    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),

    -- Layout manipulation
    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
    awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
    awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
    awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
    awful.key({ modkey,           }, "Tab",
        function ()
            awful.client.focus.history.previous()
            if client.focus then
                client.focus:raise()
            end
        end),

    -- Standard program
    awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
    awful.key({ modkey, "Control" }, "r", awesome.restart),
    awful.key({ modkey, "Shift"   }, "q", awesome.quit),

    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
    awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
    awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
    awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
    awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
    awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
    awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
    awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),

    awful.key({ modkey, "Control" }, "n", awful.client.restore),

    -- Prompt
    awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),

    awful.key({ modkey }, "x",
              function ()
                  awful.prompt.run({ prompt = "Run Lua code: " },
                  mypromptbox[mouse.screen].widget,
                  awful.util.eval, nil,
                  awful.util.getdir("cache") .. "/history_eval")
              end)
)

clientkeys = awful.util.table.join(
    awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
    awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
    awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
    awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
    awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
    awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
    awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
    awful.key({ modkey,           }, "n",
        function (c)
            -- The client currently has the input focus, so it cannot be
            -- minimized, since minimized clients can't have the focus.
            c.minimized = true
        end),
    awful.key({ modkey,           }, "m",
        function (c)
            c.maximized_horizontal = not c.maximized_horizontal
            c.maximized_vertical   = not c.maximized_vertical
        end)
)

-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
   keynumber = math.min(9, math.max(#tags[s], keynumber));
end

-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
    globalkeys = awful.util.table.join(globalkeys,
        awful.key({ modkey }, "#" .. i + 9,
                  function ()
                        local screen = mouse.screen
                        if tags[screen][i] then
                            awful.tag.viewonly(tags[screen][i])
                        end
                  end),
        awful.key({ modkey, "Control" }, "#" .. i + 9,
                  function ()
                      local screen = mouse.screen
                      if tags[screen][i] then
                          awful.tag.viewtoggle(tags[screen][i])
                      end
                  end),
        awful.key({ modkey, "Shift" }, "#" .. i + 9,
                  function ()
                      if client.focus and tags[client.focus.screen][i] then
                          awful.client.movetotag(tags[client.focus.screen][i])
                      end
                  end),
        awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
                  function ()
                      if client.focus and tags[client.focus.screen][i] then
                          awful.client.toggletag(tags[client.focus.screen][i])
                      end
                  end))
end

clientbuttons = awful.util.table.join(
    awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
    awful.button({ modkey }, 1, awful.mouse.client.move),
    awful.button({ modkey }, 3, awful.mouse.client.resize))

-- Set keys
root.keys(globalkeys)
-- }}}

-- {{{ Rules
awful.rules.rules = {
    -- All clients will match this rule.
    { rule = { },
      properties = { border_width = beautiful.border_width,
                     border_color = beautiful.border_normal,
                     focus = true,
                     keys = clientkeys,
                     buttons = clientbuttons } },
--    { rule = { },
--      properties = { floating = false } },
    { rule = { class = "MPlayer" },
      properties = { floating = true } },
    { rule = { class = "pinentry" },
      properties = { floating = true } },
    { rule = { class = "gimp" },
      properties = { floating = true } },
    -- Set Firefox to always map on tags number 2 of screen 1.
    -- { rule = { class = "Firefox" },
    --   properties = { tag = tags[1][2] } },
}
-- }}}

-- {{{ Signals
-- Signal function to execute when a new client appears.
client.add_signal("manage", function (c, startup)
    -- Add a titlebar
       if awful.client.floating.get(c) 
           or awful.client.floating.get(client.focus) then
           awful.titlebar.add(c, { modkey = modkey })
           c:raise()
       end
--上面的if语句是我加上的,作用是为新创建的float窗口添加标题栏,并把他提到最上层。
        if awful.layout.get(c.screen) == awful.layout.suit.floating then
           awful.titlebar.add(c, { modkey = modkey })
        end
--这个if语句的作用是:如果tag是floating布局,则里面打开的所有程序都加上标题栏,里面的窗口变得可以自由移动。
    -- awful.titlebar.add(c, { modkey = modkey })
    -- Enable sloppy focus
    c:add_signal("mouse::enter", function(c)
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier 
        and awful.client.focus.filter(c) then
            client.focus = c
        end
        if awful.layout.get(c.screen) == awful.layout.suit.magnifier 
            and awful.client.focus.filter(c) 
            and not awful.client.floating.get(c) 
            and not awful.client.floating.get(client.focus) then
            client.focus = c
            mouse.coords({},"mouse::enter")
        end
--上面的if语句是我加上的,作用是使magnifier 布局下支持鼠标指向来切换主窗口,并且假如有浮动窗口获得焦点时,暂时停止“鼠标指向来切换主窗口”功能(否则浮动窗口会再次被盖住,就没有机会到上层来了)
        if awful.client.floating.get(client.focus) then
           client.focus:raise()
        end
--上面的if语句也是我加上的,作用是进一步提升float窗口,防止其被其他窗口盖住
    end)

    if not startup then
        -- Set the windows at the slave,
        -- i.e. put it at the end of others instead of setting it master.
        awful.client.setslave(c)

        -- Put windows in a smart way, only if they does not set an initial position.
        if not c.size_hints.user_position and not c.size_hints.program_position then
            awful.placement.no_overlap(c)
            awful.placement.no_offscreen(c)
        end
    end
end)
awful.tag.incmwfact( 0.4)
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#14

帖子 ljj_jjl2008 » 2011-08-09 9:51

窗口操作:有时候我们想移动窗口的位置,或是调整窗口的大小。在浮动布局中,Win + 鼠标左键可以移动窗口的位置,而 Win + 鼠标右键则可以调整窗口的大小。
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: 再一次折腾:启动后把所有最常用的程序都自动启动缩成小条起来贴在屏幕四周,鼠标指到谁谁就自动放大,离开就缩回去。

#15

帖子 leeaman » 2011-08-09 9:57

这个还不错的说,fvwm估计也可以
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
回复