This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 327db301927e307afc3497c744f62245627fabe3
tree 9b7ec6e53664069b795bb12b2f955984b9b073d4
parent 80961deea6bba4f821782d038093ee3dde7765a7
tree 9b7ec6e53664069b795bb12b2f955984b9b073d4
parent 80961deea6bba4f821782d038093ee3dde7765a7
| a9ca9adc » | qiukun | 2009-03-24 | 1 | -- Standard awesome library | |
| aad4d4a5 » | qiukun | 2008-09-29 | 2 | require("awful") | |
| a9ca9adc » | qiukun | 2009-03-24 | 3 | -- Theme handling library | |
| aad4d4a5 » | qiukun | 2008-09-29 | 4 | require("beautiful") | |
| a9ca9adc » | qiukun | 2009-03-24 | 5 | -- Notification library | |
| 6 | require("naughty") | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 7 | ||
| 8 | -- {{{ Variable definitions | ||||
| 23166f86 » | qiukun | 2008-12-21 | 9 | -- Themes define colours, icons, and wallpapers | |
| 10 | -- The default is a dark theme | ||||
| 327db301 » | qiukun | 2009-10-11 | 11 | -- theme_path = "/usr/share/awesome/themes/default/theme.lua" | |
| 23166f86 » | qiukun | 2008-12-21 | 12 | -- Uncommment this for a lighter theme | |
| 327db301 » | qiukun | 2009-10-11 | 13 | theme_path = "/usr/share/awesome/themes/sky/theme.lua" | |
| 23166f86 » | qiukun | 2008-12-21 | 14 | ||
| 15 | -- Actually load theme | ||||
| 16 | beautiful.init(theme_path) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 17 | ||
| 23166f86 » | qiukun | 2008-12-21 | 18 | -- This is used later as the default terminal and editor to run. | |
| 3f2126a5 » | qiukun | 2008-10-19 | 19 | terminal = "urxvtcd" | |
| 23166f86 » | qiukun | 2008-12-21 | 20 | editor = os.getenv("EDITOR") or "nano" | |
| 21 | editor_cmd = terminal .. " -e " .. editor | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 22 | ||
| 23 | -- Default modkey. | ||||
| 24 | -- Usually, Mod4 is the key with a logo between Control and Alt. | ||||
| 25 | -- If you do not like this or do not have such a key, | ||||
| 26 | -- I suggest you to remap Mod4 to another key using xmodmap or other tools. | ||||
| 27 | -- However, you can use another modifier like Mod1, but it may interact with others. | ||||
| 28 | modkey = "Mod4" | ||||
| 29 | |||||
| 30 | -- Table of layouts to cover with awful.layout.inc, order matters. | ||||
| 31 | layouts = | ||||
| 32 | { | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 33 | awful.layout.suit.tile, | |
| 34 | awful.layout.suit.tile.left, | ||||
| 35 | awful.layout.suit.tile.bottom, | ||||
| 36 | awful.layout.suit.tile.top, | ||||
| 37 | awful.layout.suit.fair, | ||||
| 38 | awful.layout.suit.fair.horizontal, | ||||
| 39 | awful.layout.suit.max, | ||||
| 40 | awful.layout.suit.max.fullscreen, | ||||
| 41 | awful.layout.suit.magnifier, | ||||
| 42 | awful.layout.suit.floating | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 43 | } | |
| 44 | |||||
| 45 | -- Table of clients that should be set floating. The index may be either | ||||
| 46 | -- the application class or instance. The instance is useful when running | ||||
| 47 | -- a console app in a terminal like (Music on Console) | ||||
| 48 | -- xterm -name mocp -e mocp | ||||
| 49 | floatapps = | ||||
| 50 | { | ||||
| 51 | -- by class | ||||
| 52 | ["MPlayer"] = true, | ||||
| 53 | ["pinentry"] = true, | ||||
| 54 | ["gimp"] = true, | ||||
| 55 | ["Qq"] = true, | ||||
| 23166f86 » | qiukun | 2008-12-21 | 56 | ["pidgin"] = true, | |
| 327db301 » | qiukun | 2009-10-11 | 57 | ["leo"] = true, | |
| aad4d4a5 » | qiukun | 2008-09-29 | 58 | -- by instance | |
| 23166f86 » | qiukun | 2008-12-21 | 59 | ["mocp"] = true, | |
| a5fa0e56 » | qiukun | 2008-12-25 | 60 | ["Download"] = true, | |
| 61 | ["stardict"] = true, | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 62 | } | |
| 63 | |||||
| 64 | -- Applications to be moved to a pre-defined tag by class or instance. | ||||
| 65 | -- Use the screen and tags indices. | ||||
| 66 | apptags = | ||||
| 67 | { | ||||
| 80961dee » | qiukun | 2009-08-21 | 68 | ["Navigator"] = { screen = 1, tag = 2 }, | |
| 23166f86 » | qiukun | 2008-12-21 | 69 | ["Opera"] = { screen = 1, tag = 2 }, | |
| a66ba369 » | qiukun | 2009-02-15 | 70 | ["main.tcl"] = { screen = 1, tag = 2 }, | |
| f09e44cc » | qiukun | 2008-12-21 | 71 | ["Toplevel"] = { screen = 1, tag = 3 }, | |
| a66ba369 » | qiukun | 2009-02-15 | 72 | ["Thunderbird-bin"] = { screen = 1, tag = 3 }, | |
| 23166f86 » | qiukun | 2008-12-21 | 73 | ["qq"] = { screen = 1, tag = 4 }, | |
| 74 | ["pidgin"] = { screen = 1, tag = 4 }, | ||||
| 75 | ["gimp"] = { screen = 1, tag = 5 }, | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 76 | } | |
| 77 | |||||
| 78 | -- Define if we want to use titlebar on all applications. | ||||
| 79 | use_titlebar = false | ||||
| 80 | -- }}} | ||||
| 81 | |||||
| 82 | -- {{{ Tags | ||||
| 83 | -- Define tags table. | ||||
| 84 | tags = {} | ||||
| 85 | for s = 1, screen.count() do | ||||
| 86 | -- Each screen has its own tag table. | ||||
| 87 | tags[s] = {} | ||||
| a66ba369 » | qiukun | 2009-02-15 | 88 | -- Create 5 tags per screen. | |
| 23166f86 » | qiukun | 2008-12-21 | 89 | for tagnumber = 1, 5 do | |
| a9ca9adc » | qiukun | 2009-03-24 | 90 | tags[s][tagnumber] = tag(tagnumber) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 91 | -- Add tags to screen one by one | |
| 92 | tags[s][tagnumber].screen = s | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 93 | awful.layout.set(layouts[1], tags[s][tagnumber]) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 94 | end | |
| 95 | -- I'm sure you want to see at least one tag. | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 96 | tags[s][1].selected = true | |
| aad4d4a5 » | qiukun | 2008-09-29 | 97 | end | |
| 98 | -- }}} | ||||
| 99 | |||||
| 23166f86 » | qiukun | 2008-12-21 | 100 | -- {{{ Wibox | |
| aad4d4a5 » | qiukun | 2008-09-29 | 101 | -- Create a textbox widget | |
| 23166f86 » | qiukun | 2008-12-21 | 102 | mytextbox = widget({ type = "textbox", align = "right" }) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 103 | -- Set the default text in textbox | |
| 80961dee » | qiukun | 2009-08-21 | 104 | mytextbox.text = "<b><small> " .. awesome.release .. " </small></b>" | |
| 23166f86 » | qiukun | 2008-12-21 | 105 | ||
| 106 | -- Create a laucher widget and a main menu | ||||
| 107 | -- myawesomemenu = { | ||||
| 108 | -- { "manual", terminal .. " -e man awesome" }, | ||||
| 109 | -- { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" }, | ||||
| 110 | -- { "restart", awesome.restart }, | ||||
| 111 | -- { "quit", awesome.quit } | ||||
| 112 | -- } | ||||
| 113 | -- | ||||
| 114 | -- mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, | ||||
| 115 | -- { "open terminal", terminal } | ||||
| 116 | -- } | ||||
| 117 | -- }) | ||||
| 118 | -- | ||||
| 119 | -- mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, | ||||
| 120 | -- menu = mymainmenu }) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 121 | ||
| 122 | -- Create a systray | ||||
| 23166f86 » | qiukun | 2008-12-21 | 123 | mysystray = widget({ type = "systray", align = "right" }) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 124 | ||
| 23166f86 » | qiukun | 2008-12-21 | 125 | -- Create a wibox for each screen and add it | |
| 126 | mywibox = {} | ||||
| 127 | mypromptbox = {} | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 128 | mylayoutbox = {} | |
| 23166f86 » | qiukun | 2008-12-21 | 129 | mytaglist = {} | |
| 14ee3909 » | qiukun | 2009-05-23 | 130 | mytaglist.buttons = awful.util.table.join( | |
| 131 | awful.button({ }, 1, awful.tag.viewonly), | ||||
| 132 | awful.button({ modkey }, 1, awful.client.movetotag), | ||||
| 133 | awful.button({ }, 3, function (tag) tag.selected = not tag.selected end), | ||||
| 134 | awful.button({ modkey }, 3, awful.client.toggletag), | ||||
| 135 | awful.button({ }, 4, awful.tag.viewnext), | ||||
| 136 | awful.button({ }, 5, awful.tag.viewprev) | ||||
| 137 | ) | ||||
| 23166f86 » | qiukun | 2008-12-21 | 138 | mytasklist = {} | |
| 14ee3909 » | qiukun | 2009-05-23 | 139 | mytasklist.buttons = awful.util.table.join( | |
| 140 | awful.button({ }, 1, function (c) | ||||
| 141 | if not c:isvisible() then | ||||
| 142 | awful.tag.viewonly(c:tags()[1]) | ||||
| 143 | end | ||||
| 144 | client.focus = c | ||||
| 145 | c:raise() | ||||
| 146 | end), | ||||
| 147 | awful.button({ }, 3, function () | ||||
| 148 | if instance then | ||||
| 149 | instance:hide() | ||||
| 150 | instance = nil | ||||
| 151 | else | ||||
| 152 | instance = awful.menu.clients({ width=250 }) | ||||
| 153 | end | ||||
| 154 | end), | ||||
| 155 | awful.button({ }, 4, function () | ||||
| 156 | awful.client.focus.byidx(1) | ||||
| 157 | if client.focus then client.focus:raise() end | ||||
| 158 | end), | ||||
| 159 | awful.button({ }, 5, function () | ||||
| 160 | awful.client.focus.byidx(-1) | ||||
| 161 | if client.focus then client.focus:raise() end | ||||
| 162 | end)) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 163 | ||
| 164 | for s = 1, screen.count() do | ||||
| 23166f86 » | qiukun | 2008-12-21 | 165 | -- Create a promptbox for each screen | |
| 80961dee » | qiukun | 2009-08-21 | 166 | mypromptbox[s] = awful.widget.prompt({ align = "left" }) | |
| 23166f86 » | qiukun | 2008-12-21 | 167 | -- Create an imagebox widget which will contains an icon indicating which layout we're using. | |
| 168 | -- We need one layoutbox per screen. | ||||
| 169 | mylayoutbox[s] = widget({ type = "imagebox", align = "right" }) | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 170 | mylayoutbox[s]:buttons(awful.util.table.join( | |
| 171 | awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), | ||||
| 172 | awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), | ||||
| 173 | awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), | ||||
| 174 | awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) | ||||
| 23166f86 » | qiukun | 2008-12-21 | 175 | -- Create a taglist widget | |
| 80961dee » | qiukun | 2009-08-21 | 176 | mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons) | |
| 23166f86 » | qiukun | 2008-12-21 | 177 | ||
| 178 | -- Create a tasklist widget | ||||
| 80961dee » | qiukun | 2009-08-21 | 179 | mytasklist[s] = awful.widget.tasklist(function(c) | |
| 180 | return awful.widget.tasklist.label.currenttags(c, s) | ||||
| 181 | end, mytasklist.buttons) | ||||
| 23166f86 » | qiukun | 2008-12-21 | 182 | ||
| 183 | -- Create the wibox | ||||
| 184 | mywibox[s] = wibox({ position = "top", height = 16, fg = beautiful.fg_normal, bg = beautiful.bg_normal }) | ||||
| 185 | -- Add widgets to the wibox - order matters | ||||
| 186 | mywibox[s].widgets = { mylauncher, | ||||
| 187 | mytaglist[s], | ||||
| 188 | mytasklist[s], | ||||
| 189 | mypromptbox[s], | ||||
| 190 | mytextbox, | ||||
| 191 | mylayoutbox[s], | ||||
| 192 | s == 1 and mysystray or nil } | ||||
| 193 | mywibox[s].screen = s | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 194 | end | |
| 195 | -- }}} | ||||
| 196 | |||||
| 197 | -- {{{ Mouse bindings | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 198 | root.buttons(awful.util.table.join( | |
| 199 | awful.button({ }, 3, function () mymainmenu:toggle() end), | ||||
| 200 | awful.button({ }, 4, awful.tag.viewnext), | ||||
| 201 | awful.button({ }, 5, awful.tag.viewprev) | ||||
| 202 | )) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 203 | -- }}} | |
| 204 | |||||
| 205 | -- {{{ Key bindings | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 206 | globalkeys = awful.util.table.join( | |
| 207 | awful.key({ modkey, }, "Left", awful.tag.viewprev ), | ||||
| 208 | awful.key({ modkey, }, "Right", awful.tag.viewnext ), | ||||
| 209 | awful.key({ modkey, }, "Escape", awful.tag.history.restore), | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 210 | ||
| 14ee3909 » | qiukun | 2009-05-23 | 211 | awful.key({ modkey, }, "j", | |
| a9ca9adc » | qiukun | 2009-03-24 | 212 | function () | |
| 213 | awful.client.focus.byidx( 1) | ||||
| 214 | if client.focus then client.focus:raise() end | ||||
| 215 | end), | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 216 | awful.key({ modkey, }, "k", | |
| a9ca9adc » | qiukun | 2009-03-24 | 217 | function () | |
| 218 | awful.client.focus.byidx(-1) | ||||
| 219 | if client.focus then client.focus:raise() end | ||||
| 220 | end), | ||||
| 80961dee » | qiukun | 2009-08-21 | 221 | awful.key({ modkey, }, "w", function () mymainmenu:show(true) end), | |
| a9ca9adc » | qiukun | 2009-03-24 | 222 | ||
| 223 | -- Layout manipulation | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 224 | awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), | |
| 225 | awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), | ||||
| 226 | awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end), | ||||
| 227 | awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end), | ||||
| 228 | awful.key({ modkey, }, "u", awful.client.urgent.jumpto), | ||||
| 229 | awful.key({ modkey, }, "Tab", | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 230 | function () | |
| 231 | awful.client.focus.history.previous() | ||||
| 232 | if client.focus then | ||||
| 233 | client.focus:raise() | ||||
| 234 | end | ||||
| 235 | end), | ||||
| 236 | |||||
| 237 | -- Standard program | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 238 | awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), | |
| 239 | awful.key({ modkey, "Control" }, "r", awesome.restart), | ||||
| 240 | awful.key({ modkey, "Shift" }, "q", awesome.quit), | ||||
| 241 | |||||
| 242 | awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), | ||||
| 243 | awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), | ||||
| 244 | awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), | ||||
| 245 | awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), | ||||
| 246 | awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), | ||||
| 247 | awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), | ||||
| 248 | awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), | ||||
| 249 | awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 250 | ||
| 251 | -- Prompt | ||||
| 80961dee » | qiukun | 2009-08-21 | 252 | awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), | |
| 14ee3909 » | qiukun | 2009-05-23 | 253 | ||
| 254 | awful.key({ modkey }, "x", | ||||
| 255 | function () | ||||
| 256 | awful.prompt.run({ prompt = "Run Lua code: " }, | ||||
| 80961dee » | qiukun | 2009-08-21 | 257 | mypromptbox[mouse.screen].widget, | |
| 14ee3909 » | qiukun | 2009-05-23 | 258 | awful.util.eval, nil, | |
| 259 | awful.util.getdir("cache") .. "/history_eval") | ||||
| 260 | end) | ||||
| 261 | ) | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 262 | ||
| 263 | -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 264 | clientkeys = awful.util.table.join( | |
| 265 | awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), | ||||
| 266 | awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), | ||||
| 267 | awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), | ||||
| 268 | awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), | ||||
| 269 | awful.key({ modkey, }, "o", awful.client.movetoscreen ), | ||||
| 270 | awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), | ||||
| 271 | awful.key({ modkey }, "t", awful.client.togglemarked), | ||||
| 272 | awful.key({ modkey,}, "m", | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 273 | function (c) | |
| 274 | c.maximized_horizontal = not c.maximized_horizontal | ||||
| 275 | c.maximized_vertical = not c.maximized_vertical | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 276 | end) | |
| 277 | ) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 278 | ||
| 279 | -- Compute the maximum number of digit we need, limited to 9 | ||||
| 280 | keynumber = 0 | ||||
| 281 | for s = 1, screen.count() do | ||||
| 282 | keynumber = math.min(9, math.max(#tags[s], keynumber)); | ||||
| 283 | end | ||||
| 284 | |||||
| 285 | for i = 1, keynumber do | ||||
| 80961dee » | qiukun | 2009-08-21 | 286 | globalkeys = awful.util.table.join(globalkeys, | |
| 287 | awful.key({ modkey }, i, | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 288 | function () | |
| 289 | local screen = mouse.screen | ||||
| 290 | if tags[screen][i] then | ||||
| 291 | awful.tag.viewonly(tags[screen][i]) | ||||
| 292 | end | ||||
| 80961dee » | qiukun | 2009-08-21 | 293 | end), | |
| 294 | awful.key({ modkey, "Control" }, i, | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 295 | function () | |
| 296 | local screen = mouse.screen | ||||
| 297 | if tags[screen][i] then | ||||
| 298 | tags[screen][i].selected = not tags[screen][i].selected | ||||
| 299 | end | ||||
| 80961dee » | qiukun | 2009-08-21 | 300 | end), | |
| 301 | awful.key({ modkey, "Shift" }, i, | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 302 | function () | |
| 303 | if client.focus and tags[client.focus.screen][i] then | ||||
| 304 | awful.client.movetotag(tags[client.focus.screen][i]) | ||||
| 305 | end | ||||
| 80961dee » | qiukun | 2009-08-21 | 306 | end), | |
| 307 | awful.key({ modkey, "Control", "Shift" }, i, | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 308 | function () | |
| 309 | if client.focus and tags[client.focus.screen][i] then | ||||
| 310 | awful.client.toggletag(tags[client.focus.screen][i]) | ||||
| 311 | end | ||||
| 80961dee » | qiukun | 2009-08-21 | 312 | end), | |
| 313 | awful.key({ modkey, "Shift" }, "F" .. i, | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 314 | function () | |
| 315 | local screen = mouse.screen | ||||
| 316 | if tags[screen][i] then | ||||
| 317 | for k, c in pairs(awful.client.getmarked()) do | ||||
| 318 | awful.client.movetotag(tags[screen][i], c) | ||||
| 319 | end | ||||
| 320 | end | ||||
| 80961dee » | qiukun | 2009-08-21 | 321 | end)) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 322 | end | |
| a9ca9adc » | qiukun | 2009-03-24 | 323 | ||
| 324 | -- Set keys | ||||
| 325 | root.keys(globalkeys) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 326 | -- }}} | |
| 327 | |||||
| 328 | -- {{{ Hooks | ||||
| 329 | -- Hook function to execute when focusing a client. | ||||
| 23166f86 » | qiukun | 2008-12-21 | 330 | awful.hooks.focus.register(function (c) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 331 | if not awful.client.ismarked(c) then | |
| 332 | c.border_color = beautiful.border_focus | ||||
| 333 | end | ||||
| 23166f86 » | qiukun | 2008-12-21 | 334 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 335 | ||
| 336 | -- Hook function to execute when unfocusing a client. | ||||
| 23166f86 » | qiukun | 2008-12-21 | 337 | awful.hooks.unfocus.register(function (c) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 338 | if not awful.client.ismarked(c) then | |
| 339 | c.border_color = beautiful.border_normal | ||||
| 340 | end | ||||
| 23166f86 » | qiukun | 2008-12-21 | 341 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 342 | ||
| 343 | -- Hook function to execute when marking a client | ||||
| 23166f86 » | qiukun | 2008-12-21 | 344 | awful.hooks.marked.register(function (c) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 345 | c.border_color = beautiful.border_marked | |
| 23166f86 » | qiukun | 2008-12-21 | 346 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 347 | ||
| 23166f86 » | qiukun | 2008-12-21 | 348 | -- Hook function to execute when unmarking a client. | |
| 349 | awful.hooks.unmarked.register(function (c) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 350 | c.border_color = beautiful.border_focus | |
| 23166f86 » | qiukun | 2008-12-21 | 351 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 352 | ||
| 23166f86 » | qiukun | 2008-12-21 | 353 | -- Hook function to execute when the mouse enters a client. | |
| 354 | awful.hooks.mouse_enter.register(function (c) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 355 | -- Sloppy focus, but disabled for magnifier layout | |
| a9ca9adc » | qiukun | 2009-03-24 | 356 | if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier | |
| 23166f86 » | qiukun | 2008-12-21 | 357 | and awful.client.focus.filter(c) then | |
| aad4d4a5 » | qiukun | 2008-09-29 | 358 | client.focus = c | |
| 359 | end | ||||
| 23166f86 » | qiukun | 2008-12-21 | 360 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 361 | ||
| 362 | -- Hook function to execute when a new client appears. | ||||
| a9ca9adc » | qiukun | 2009-03-24 | 363 | awful.hooks.manage.register(function (c, startup) | |
| 364 | -- If we are not managing this application at startup, | ||||
| 365 | -- move it to the screen where the mouse is. | ||||
| 366 | -- We only do it for filtered windows (i.e. no dock, etc). | ||||
| 367 | if not startup and awful.client.focus.filter(c) then | ||||
| 368 | c.screen = mouse.screen | ||||
| 369 | end | ||||
| 370 | |||||
| aad4d4a5 » | qiukun | 2008-09-29 | 371 | if use_titlebar then | |
| 372 | -- Add a titlebar | ||||
| 373 | awful.titlebar.add(c, { modkey = modkey }) | ||||
| 374 | end | ||||
| 375 | -- Add mouse bindings | ||||
| 14ee3909 » | qiukun | 2009-05-23 | 376 | c:buttons(awful.util.table.join( | |
| 377 | awful.button({ }, 1, function (c) client.focus = c; c:raise() end), | ||||
| 378 | awful.button({ modkey }, 1, awful.mouse.client.move), | ||||
| 379 | awful.button({ modkey }, 3, awful.mouse.client.resize) | ||||
| 380 | )) | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 381 | -- New client may not receive focus | |
| 382 | -- if they're not focusable, so set border anyway. | ||||
| 383 | c.border_width = beautiful.border_width | ||||
| 384 | c.border_color = beautiful.border_normal | ||||
| 385 | |||||
| 386 | -- Check if the application should be floating. | ||||
| 387 | local cls = c.class | ||||
| 388 | local inst = c.instance | ||||
| 80961dee » | qiukun | 2009-08-21 | 389 | if floatapps[cls] ~= nil then | |
| a9ca9adc » | qiukun | 2009-03-24 | 390 | awful.client.floating.set(c, floatapps[cls]) | |
| 80961dee » | qiukun | 2009-08-21 | 391 | elseif floatapps[inst] ~= nil then | |
| a9ca9adc » | qiukun | 2009-03-24 | 392 | awful.client.floating.set(c, floatapps[inst]) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 393 | end | |
| 394 | |||||
| 395 | -- Check application->screen/tag mappings. | ||||
| 396 | local target | ||||
| 397 | if apptags[cls] then | ||||
| 398 | target = apptags[cls] | ||||
| 399 | elseif apptags[inst] then | ||||
| 400 | target = apptags[inst] | ||||
| 401 | end | ||||
| 402 | if target then | ||||
| 403 | c.screen = target.screen | ||||
| 404 | awful.client.movetotag(tags[target.screen][target.tag], c) | ||||
| 405 | end | ||||
| 406 | |||||
| 23166f86 » | qiukun | 2008-12-21 | 407 | -- Do this after tag mapping, so you don't see it on the wrong tag for a split second. | |
| 408 | client.focus = c | ||||
| 409 | |||||
| a9ca9adc » | qiukun | 2009-03-24 | 410 | -- Set key bindings | |
| 411 | c:keys(clientkeys) | ||||
| 412 | |||||
| aad4d4a5 » | qiukun | 2008-09-29 | 413 | -- Set the windows at the slave, | |
| 414 | -- i.e. put it at the end of others instead of setting it master. | ||||
| 415 | -- awful.client.setslave(c) | ||||
| 416 | |||||
| 23166f86 » | qiukun | 2008-12-21 | 417 | -- Honor size hints: if you want to drop the gaps between windows, set this to false. | |
| a9ca9adc » | qiukun | 2009-03-24 | 418 | c.size_hints_honor = false | |
| 23166f86 » | qiukun | 2008-12-21 | 419 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 420 | ||
| 23166f86 » | qiukun | 2008-12-21 | 421 | -- Hook function to execute when arranging the screen. | |
| aad4d4a5 » | qiukun | 2008-09-29 | 422 | -- (tag switch, new client, etc) | |
| 23166f86 » | qiukun | 2008-12-21 | 423 | awful.hooks.arrange.register(function (screen) | |
| a9ca9adc » | qiukun | 2009-03-24 | 424 | local layout = awful.layout.getname(awful.layout.get(screen)) | |
| 425 | if layout and beautiful["layout_" ..layout] then | ||||
| 23166f86 » | qiukun | 2008-12-21 | 426 | mylayoutbox[screen].image = image(beautiful["layout_" .. layout]) | |
| 427 | else | ||||
| 428 | mylayoutbox[screen].image = nil | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 429 | end | |
| 430 | |||||
| 23166f86 » | qiukun | 2008-12-21 | 431 | -- Give focus to the latest client in history if no window has focus | |
| 432 | -- or if the current window is a desktop or a dock one. | ||||
| aad4d4a5 » | qiukun | 2008-09-29 | 433 | if not client.focus then | |
| 434 | local c = awful.client.focus.history.get(screen, 0) | ||||
| 435 | if c then client.focus = c end | ||||
| 436 | end | ||||
| 23166f86 » | qiukun | 2008-12-21 | 437 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 438 | ||
| a9ca9adc » | qiukun | 2009-03-24 | 439 | -- Hook called every minute | |
| 440 | awful.hooks.timer.register(60, function () | ||||
| 441 | mytextbox.text = os.date(" %a %b %d, %H:%M ") | ||||
| 23166f86 » | qiukun | 2008-12-21 | 442 | end) | |
| aad4d4a5 » | qiukun | 2008-09-29 | 443 | -- }}} | |







