2010年11月14日日曜日

awesome WM の導入と設定

ウィンドウマネージャ(WM)なんて,Gnomeで何も問題を感じていなかったのですが,「タイル型WM」なる全く異なるコンセプトのWMがあると聞き,導入してみました.

今回導入したのは,awesome WM です.

awesome WMの特徴(主観)
  • タイル型WMのジャンルで,Xmonad というWMと双璧をなす人気らしい
  • 設定がLuaという,比較的簡単なプログラミング言語で,柔軟に設定可能
  • タイル型なだけあり,ウィンドウが重ならない.
  • キーボードショートカットを覚えると,本格的にマウス不要になる.
  • Gnomeでいうワークスペース的な機能を「tag」という形で自然に取り込んでいて,画面を論理的に切り替えられる



こんな感じにできます(スクリーンショット)


導入


パッケージをダウンロード
-
sudo apt-get install awesome




/etc/X11/Xsession.d/40x11-common_xsessionrc を以下のように編集
(このあたりはだいぶ環境依存のはずです.)
-
# This file is sourced by Xsession(5), not executed.

#Source user defined xsessionrc (locales and other environment variables)
# if [ -r "$USERXSESSIONRC" ]; then
#   . "$USERXSESSIONRC"
# fi

source /home/sho/.xinitrc



~/.xinitrcを,以下のように作成・編集
-
#!/bin/sh

exec awesome




設定ファイルの作成
-
mkdir .config/awesome
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/




この時点で一旦ログアウトして,「セッション」をawesomeに指定し,ログインする.
以下,自分好みの設定



CPUやメモリの状態を表示させる
- Visiousをダウンロード,解凍し,~/.config/awesome/visious という名前のディレクトリに移す
- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
--
-- Load Debian menu entries
require("debian.menu")
-- For dynamic widgets
require("vicious")
--
-- Create a systray
mysystray = widget({ type = "systray" })

refreshdelay = 1
-- memwidget
-- text
memtext = widget({ type = "textbox" })
memtext.text = ' mem '
-- bar
membar = awful.widget.graph()
membar:set_width(50)
membar:set_height(17)
membar:set_background_color("#494B4F")
membar:set_border_color(nil)
membar:set_color("#004080")
membar:set_gradient_colors({ "#004080", "#006699", "#CCCCFF" })
vicious.register(membar, vicious.widgets.mem, "$1", refreshdelay)
-- // memwidget

-- cpuwidget
-- text
cputext = widget({ type = "textbox" })
cputext.text = ' cpu '
-- graph
cpugraph = awful.widget.graph()
cpugraph:set_width(50)
cpugraph:set_height(17)
cpugraph:set_background_color("#494B4F")
cpugraph:set_color("#004080")
cpugraph:set_gradient_colors({ "#004080", "#006699", "#CCCCFF" })
vicious.register(cpugraph, vicious.widgets.cpu, "$1", refreshdelay)
-- // cpuwidget


-- Create a wibox for each screen and add it
--
      mylayoutbox[s],
      mytextclock,
      s == 1 and mysystray or nil,
      -- I added the followings.
      membar.widget,
      memtext,
      cpugraph.widget,
      cputext,

      mytasklist[s],

[参考] http://samemiso.blogspot.com/2009/12/awesome-34cpumem.html



テーマ(beautiful)の設定
- http://awesome.naquadah.org/wiki/Beautiful_themes から,zhuravlik を拝借
--
sudo mkdir /usr/share/awesome/themes/zhuravlik
-- /usr/share/awesome/themes/zhuravlik/theme.lua を以下のように作成・編集
---
---------------------------
-- Default awesome theme --
---------------------------

theme = {}

theme.font          = "sans 8"

theme.bg_normal     = "#f7f7f7ee"
theme.bg_focus      = "#535d6cee"
theme.bg_urgent     = "#ff0000ee"
theme.bg_minimize   = "#444444ee"

theme.fg_normal     = "#535d6c"
theme.fg_focus      = "#ffffff"
theme.fg_urgent     = "#ffffff"
theme.fg_minimize  = "#ffffff"

theme.border_width  = "1"
theme.border_normal = "#000000"
theme.border_focus  = "#535d6c"

-- There are other variable sets
-- overriding the default one when
-- defined, the sets are:
-- [taglist|tasklist]_[bg|fg]_[focus|urgent]
-- titlebar_[bg|fg]_[normal|focus]
-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color]
-- mouse_finder_[color|timeout|animate_timeout|radius|factor]
-- Example:
--theme.taglist_bg_focus = "#ff0000"

-- Display the taglist squares
theme.taglist_squares_sel   = "/usr/share/awesome/themes/default/taglist/squarefw.png"
theme.taglist_squares_unsel = "/usr/share/awesome/themes/default/taglist/squarew.png"

theme.tasklist_floating_icon = "/usr/share/awesome/themes/default/tasklist/floatingw.png"

-- Variables set for theming the menu:
-- menu_[bg|fg]_[normal|focus]
-- menu_[border_color|border_width]
theme.menu_submenu_icon = "/usr/share/awesome/themes/default/submenu.png"
theme.menu_height = "15"
theme.menu_width  = "100"

-- You can add as many variables as
-- you wish and access them by using
-- beautiful.variable in your rc.lua
--theme.bg_widget = "#cc0000"

-- Define the image to load
theme.titlebar_close_button_normal = "/usr/share/awesome/themes/default/titlebar/close_normal.png"
theme.titlebar_close_button_focus  = "/usr/share/awesome/themes/default/titlebar/close_focus.png"

theme.titlebar_ontop_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/ontop_normal_inactive.png"
theme.titlebar_ontop_button_focus_inactive  = "/usr/share/awesome/themes/default/titlebar/ontop_focus_inactive.png"
theme.titlebar_ontop_button_normal_active = "/usr/share/awesome/themes/default/titlebar/ontop_normal_active.png"
theme.titlebar_ontop_button_focus_active  = "/usr/share/awesome/themes/default/titlebar/ontop_focus_active.png"

theme.titlebar_sticky_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/sticky_normal_inactive.png"
theme.titlebar_sticky_button_focus_inactive  = "/usr/share/awesome/themes/default/titlebar/sticky_focus_inactive.png"
theme.titlebar_sticky_button_normal_active = "/usr/share/awesome/themes/default/titlebar/sticky_normal_active.png"
theme.titlebar_sticky_button_focus_active  = "/usr/share/awesome/themes/default/titlebar/sticky_focus_active.png"

theme.titlebar_floating_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive  = "/usr/share/awesome/themes/default/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = "/usr/share/awesome/themes/default/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active  = "/usr/share/awesome/themes/default/titlebar/floating_focus_active.png"

theme.titlebar_maximized_button_normal_inactive = "/usr/share/awesome/themes/default/titlebar/maximized_normal_inactive.png"
theme.titlebar_maximized_button_focus_inactive  = "/usr/share/awesome/themes/default/titlebar/maximized_focus_inactive.png"
theme.titlebar_maximized_button_normal_active = "/usr/share/awesome/themes/default/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active  = "/usr/share/awesome/themes/default/titlebar/maximized_focus_active.png"

-- You can use your own command to set your wallpaper
theme.wallpaper_cmd = { "feh --bg-scale /home/sho/document/wallpaper/Atmo.jpg" }

-- You can use your own layout icons like this:
theme.layout_fairh = "/usr/share/awesome/themes/default/layouts/fairhw.png"
theme.layout_fairv = "/usr/share/awesome/themes/default/layouts/fairvw.png"
theme.layout_floating  = "/usr/share/awesome/themes/default/layouts/floatingw.png"
theme.layout_magnifier = "/usr/share/awesome/themes/default/layouts/magnifierw.png"
theme.layout_max = "/usr/share/awesome/themes/default/layouts/maxw.png"
theme.layout_fullscreen = "/usr/share/awesome/themes/default/layouts/fullscreenw.png"
theme.layout_tilebottom = "/usr/share/awesome/themes/default/layouts/tilebottomw.png"
theme.layout_tileleft   = "/usr/share/awesome/themes/default/layouts/tileleftw.png"
theme.layout_tile = "/usr/share/awesome/themes/default/layouts/tilew.png"
theme.layout_tiletop = "/usr/share/awesome/themes/default/layouts/tiletopw.png"
theme.layout_spiral  = "/usr/share/awesome/themes/default/layouts/spiralw.png"
theme.layout_dwindle = "/usr/share/awesome/themes/default/layouts/dwindlew.png"

theme.awesome_icon = "/usr/share/awesome/icons/awesome16.png"

return theme
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
---- theme.wallpaper_cmd = { "feh --bg-scale /home/sho/document/wallpaper/Atmo.jpg" } の行は自分で設定する必要あり
---- 壁紙は,feh --bg-scale /path/to/wallpaper で設定.何個か試して,これだけうまくいった.

-- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
---
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/usr/share/awesome/themes/zhuravlik/theme.lua")



使わないレイアウトをコメントアウト
- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
--
-- 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
}
-- }}}



tagに名前をつける
- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
--
-- Define a tag table which hold all screen tags.
tags = {
   names = { "1.work", "2.dev", "3.web", "4.study", "5.skype", "6.twitter", 7, 8, 9 },
   layout = { layouts[2], layouts[2], layouts[2], layouts[2], layouts[2],
              layouts[2], layouts[2], layouts[2], layouts[2] }
}



メニューの編集
- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
--
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
                                    { "Ubuntu", debian.menu.Debian_menu.Debian },
                                    { "Shutdown", function () awful.util.spawn_with_shell("gksu 'shutdown -h now'") end  },
                                    { "Reboot", function () awful.util.spawn_with_shell("gksu 'reboot'") end  },
                                    { "Suspend", function () awful.util.spawn_with_shell("gksu 'pm-suspend'") end  }
                                 }
                       })

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



アプリごとに表示するタグを設定
- rc.luaの変更箇所(変更箇所の周りの記述で検索かけてください):
--
  -- Set skype to always map on tags number 5 of screen 1.
   { rule = { name = "Skype" },
     properties = { tag = tags[1][5] } },
   -- Set peraperaprv to always map on tags number 3 of screen 1.
   { rule = { name = "PeraPeraPrv" },
     properties = { tag = tags[1][6] } },
   -- Set Firefox to always map on tags number 2 of screen 1.
   -- { rule = { class = "Firefox" },
   --   properties = { tag = tags[1][2] } },

-- class = "hoge" に入れる文字列は,以下のようにして調べる.
--- xprop コマンドを起動
--- 調べたいアプリのウィンドウをクリック
--- WM_CLASSの2つめの文字列が目的の文字列



awesome WM起動時に,いくつかのアプリを起動
- rc.luaの変更箇所(ファイルの最後の方に追加):
--
-- Startup scripts
function run_once(prg,arg_string,screen) -- NOTE: screen and tag are different.
    if not prg then
        do return nil end
    end
    if not arg_string then 
        awful.util.spawn_with_shell("pgrep -f -u $USER -x " .. prg .. " || (" .. prg .. ")",screen)
    else
        awful.util.spawn_with_shell("pgrep -f -u $USER -x " .. prg .. " || (" .. prg .. " " .. arg_string .. ")",screen)
    end
end
run_once("xcompmgr", nil, 1)
run_once("wicd-gtk", nil, 1)
run_once("skype", nil, 1)
run_once("peraperaprv", nil, 1)



ウィンドウを半透明化する
-
sudo apt-get install xcompmgr
- rc.luaの変更箇所(ファイルの最後の方に追加):
--
-- Make some windows transparent
-- ref: http://nekolinux.blogspot.com/2009/05/awesomexcompmgr.html
-- Hook function to execute when focusing a client.                                                             
awful.hooks.focus.register(function (c)
    if not awful.client.ismarked(c) then
       c.border_color = beautiful.border_focus
       c.opacity = 0.9
    end
end)

-- Hook function to execute when unfocusing a client.                                                           
awful.hooks.unfocus.register(function (c)
    if not awful.client.ismarked(c) then
       c.border_color = beautiful.border_normal
       c.opacity = 0.5 
    end
end)
-- 上記「awesome WM起動時に,いくつかのアプリを起動」で,xcompmgr コマンドを起動していることが必要
[参考] http://nekolinux.blogspot.com/2009/05/awesomexcompmgr.html




以上です.この他にも,Emacsにlua-modeを入れたりflymake-luaを使えるようにしてます.

誰かのお役に立てれば幸いです.

0 件のコメント:

コメントを投稿