Guest User

awesome-git_rc.lua

a guest
Feb 28th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.46 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Widget and layout library
  6. require("wibox")
  7. -- Theme handling library
  8. require("beautiful")
  9. -- Notification library
  10. require("naughty")
  11. require("bashets")
  12.  
  13. -- {{{ Error handling
  14. -- Check if awesome encountered an error during startup and fell back to
  15. -- another config (This code will only ever execute for the fallback config)
  16. if awesome.startup_errors then
  17. naughty.notify({ preset = naughty.config.presets.critical,
  18. title = "Oops, there were errors during startup!",
  19. text = awesome.startup_errors })
  20. end
  21.  
  22. -- Handle runtime errors after startup
  23. do
  24. local in_error = false
  25. awesome.connect_signal("debug::error", function (err)
  26. -- Make sure we don't go into an endless error loop
  27. if in_error then return end
  28. in_error = true
  29.  
  30. naughty.notify({ preset = naughty.config.presets.critical,
  31. title = "Oops, an error happened!",
  32. text = err })
  33. in_error = false
  34. end)
  35. end
  36. -- }}}
  37.  
  38. -- {{{ Variable definitions
  39. -- Themes define colours, icons, and wallpapers
  40. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  41.  
  42. -- This is used later as the default terminal and editor to run.
  43. terminal = "urxvt"
  44. editor = os.getenv("EDITOR") or "vim"
  45. editor_cmd = terminal .. " -e " .. editor
  46.  
  47. -- Default modkey.
  48. -- Usually, Mod4 is the key with a logo between Control and Alt.
  49. -- If you do not like this or do not have such a key,
  50. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  51. -- However, you can use another modifier like Mod1, but it may interact with others.
  52. modkey = "Mod4"
  53.  
  54. -- Table of layouts to cover with awful.layout.inc, order matters.
  55. layouts =
  56. {
  57. awful.layout.suit.floating,
  58. awful.layout.suit.tile,
  59. awful.layout.suit.tile.left,
  60. awful.layout.suit.tile.bottom,
  61. awful.layout.suit.tile.top,
  62. awful.layout.suit.fair,
  63. awful.layout.suit.fair.horizontal,
  64. awful.layout.suit.spiral,
  65. awful.layout.suit.spiral.dwindle,
  66. awful.layout.suit.max,
  67. awful.layout.suit.max.fullscreen,
  68. awful.layout.suit.magnifier
  69. }
  70. -- }}}
  71.  
  72. -- {{{ Tags
  73. -- Define a tag table which hold all screen tags.
  74. tags = {}
  75. for s = 1, screen.count() do
  76. -- Each screen has its own tag table.
  77. tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  78. end
  79. -- }}}
  80.  
  81. -- {{{ Menu
  82. -- Create a laucher widget and a main menu
  83. myawesomemenu = {
  84. { "manual", terminal .. " -e man awesome" },
  85. { "edit config", editor_cmd .. " " .. awesome.conffile },
  86. { "restart", awesome.restart },
  87. { "quit", awesome.quit }
  88. }
  89.  
  90. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  91. { "open terminal", terminal }
  92. }
  93. })
  94.  
  95. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  96. menu = mymainmenu })
  97. -- }}}
  98.  
  99. -- {{{ Wibox
  100. -- Create a textclock widget
  101. mytextclock = awful.widget.textclock()
  102.  
  103. -- test_mail --
  104. gmail = wibox.widget.textbox()
  105. --gmail = widget({ type = "textbox", name = "gmail" })
  106. bashets.register("/home/riso/.config/awesome/script", {widget = gmail, update_time=10})
  107.  
  108.  
  109. -- Create a wibox for each screen and add it
  110. mywibox = {}
  111. mypromptbox = {}
  112. mylayoutbox = {}
  113. mytaglist = {}
  114. mytaglist.buttons = awful.util.table.join(
  115. awful.button({ }, 1, awful.tag.viewonly),
  116. awful.button({ modkey }, 1, awful.client.movetotag),
  117. awful.button({ }, 3, awful.tag.viewtoggle),
  118. awful.button({ modkey }, 3, awful.client.toggletag),
  119. awful.button({ }, 4, awful.tag.viewnext),
  120. awful.button({ }, 5, awful.tag.viewprev)
  121. )
  122. mytasklist = {}
  123. mytasklist.buttons = awful.util.table.join(
  124. awful.button({ }, 1, function (c)
  125. if c == client.focus then
  126. c.minimized = true
  127. else
  128. if not c:isvisible() then
  129. awful.tag.viewonly(c:tags()[1])
  130. end
  131. -- This will also un-minimize
  132. -- the client, if needed
  133. client.focus = c
  134. c:raise()
  135. end
  136. end),
  137. awful.button({ }, 3, function ()
  138. if instance then
  139. instance:hide()
  140. instance = nil
  141. else
  142. instance = awful.menu.clients({ width=250 })
  143. end
  144. end),
  145. awful.button({ }, 4, function ()
  146. awful.client.focus.byidx(1)
  147. if client.focus then client.focus:raise() end
  148. end),
  149. awful.button({ }, 5, function ()
  150. awful.client.focus.byidx(-1)
  151. if client.focus then client.focus:raise() end
  152. end))
  153.  
  154. for s = 1, screen.count() do
  155. -- Create a promptbox for each screen
  156. mypromptbox[s] = awful.widget.prompt()
  157. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  158. -- We need one layoutbox per screen.
  159. mylayoutbox[s] = awful.widget.layoutbox(s)
  160. mylayoutbox[s]:buttons(awful.util.table.join(
  161. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  162. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  163. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  164. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  165. -- Create a taglist widget
  166. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  167.  
  168. -- Create a tasklist widget
  169. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  170.  
  171. -- Create the wibox
  172. mywibox[s] = awful.wibox({ position = "top", screen = s })
  173.  
  174. -- Widgets that are aligned to the left
  175. local left_layout = wibox.layout.fixed.horizontal()
  176. left_layout:add(mylauncher)
  177. left_layout:add(mytaglist[s])
  178. left_layout:add(mypromptbox[s])
  179.  
  180. -- Widgets that are aligned to the right
  181. local right_layout = wibox.layout.fixed.horizontal()
  182. if s == 1 then right_layout:add(wibox.widget.systray()) end
  183. right_layout:add(mytextclock)
  184. right_layout:add(gmail)
  185. right_layout:add(mylayoutbox[s])
  186.  
  187. -- Now bring it all together (with the tasklist in the middle)
  188. local layout = wibox.layout.align.horizontal()
  189. layout:set_left(left_layout)
  190. layout:set_middle(mytasklist[s])
  191. layout:set_right(right_layout)
  192.  
  193. mywibox[s]:set_widget(layout)
  194. end
  195. bashets.start()
  196. -- }}}
  197.  
  198. -- {{{ Mouse bindings
  199. root.buttons(awful.util.table.join(
  200. awful.button({ }, 3, function () mymainmenu:toggle() end),
  201. awful.button({ }, 4, awful.tag.viewnext),
  202. awful.button({ }, 5, awful.tag.viewprev)
  203. ))
  204. -- }}}
  205.  
  206. -- {{{ Key bindings
  207. globalkeys = awful.util.table.join(
  208. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  209. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  210. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  211.  
  212. awful.key({ modkey, }, "j",
  213. function ()
  214. awful.client.focus.byidx( 1)
  215. if client.focus then client.focus:raise() end
  216. end),
  217. awful.key({ modkey, }, "k",
  218. function ()
  219. awful.client.focus.byidx(-1)
  220. if client.focus then client.focus:raise() end
  221. end),
  222. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  223.  
  224. -- Layout manipulation
  225. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  226. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  227. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  228. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  229. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  230. awful.key({ modkey, }, "Tab",
  231. function ()
  232. awful.client.focus.history.previous()
  233. if client.focus then
  234. client.focus:raise()
  235. end
  236. end),
  237.  
  238. -- Standard program
  239. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  240. awful.key({ modkey, "Control" }, "r", awesome.restart),
  241. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  242.  
  243. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  244. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  245. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  246. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  247. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  248. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  249. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  250. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  251.  
  252. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  253.  
  254. -- Prompt
  255. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  256.  
  257. awful.key({ modkey }, "x",
  258. function ()
  259. awful.prompt.run({ prompt = "Run Lua code: " },
  260. mypromptbox[mouse.screen].widget,
  261. awful.util.eval, nil,
  262. awful.util.getdir("cache") .. "/history_eval")
  263. end)
  264. )
  265.  
  266. clientkeys = awful.util.table.join(
  267. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  268. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  269. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  270. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  271. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  272. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  273. awful.key({ modkey, }, "n",
  274. function (c)
  275. -- The client currently has the input focus, so it cannot be
  276. -- minimized, since minimized clients can't have the focus.
  277. c.minimized = true
  278. end),
  279. awful.key({ modkey, }, "m",
  280. function (c)
  281. c.maximized_horizontal = not c.maximized_horizontal
  282. c.maximized_vertical = not c.maximized_vertical
  283. end)
  284. )
  285.  
  286. -- Compute the maximum number of digit we need, limited to 9
  287. keynumber = 0
  288. for s = 1, screen.count() do
  289. keynumber = math.min(9, math.max(#tags[s], keynumber));
  290. end
  291.  
  292. -- Bind all key numbers to tags.
  293. -- Be careful: we use keycodes to make it works on any keyboard layout.
  294. -- This should map on the top row of your keyboard, usually 1 to 9.
  295. for i = 1, keynumber do
  296. globalkeys = awful.util.table.join(globalkeys,
  297. awful.key({ modkey }, "#" .. i + 9,
  298. function ()
  299. local screen = mouse.screen
  300. if tags[screen][i] then
  301. awful.tag.viewonly(tags[screen][i])
  302. end
  303. end),
  304. awful.key({ modkey, "Control" }, "#" .. i + 9,
  305. function ()
  306. local screen = mouse.screen
  307. if tags[screen][i] then
  308. awful.tag.viewtoggle(tags[screen][i])
  309. end
  310. end),
  311. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  312. function ()
  313. if client.focus and tags[client.focus.screen][i] then
  314. awful.client.movetotag(tags[client.focus.screen][i])
  315. end
  316. end),
  317. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  318. function ()
  319. if client.focus and tags[client.focus.screen][i] then
  320. awful.client.toggletag(tags[client.focus.screen][i])
  321. end
  322. end))
  323. end
  324.  
  325. clientbuttons = awful.util.table.join(
  326. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  327. awful.button({ modkey }, 1, awful.mouse.client.move),
  328. awful.button({ modkey }, 3, awful.mouse.client.resize))
  329.  
  330. -- Set keys
  331. root.keys(globalkeys)
  332. -- }}}
  333.  
  334. -- {{{ Rules
  335. awful.rules.rules = {
  336. -- All clients will match this rule.
  337. { rule = { },
  338. properties = { border_width = beautiful.border_width,
  339. border_color = beautiful.border_normal,
  340. focus = true,
  341. keys = clientkeys,
  342. buttons = clientbuttons } },
  343. { rule = { class = "MPlayer" },
  344. properties = { floating = true } },
  345. { rule = { class = "pinentry" },
  346. properties = { floating = true } },
  347. { rule = { class = "gimp" },
  348. properties = { floating = true } },
  349. -- Set Firefox to always map on tags number 2 of screen 1.
  350. -- { rule = { class = "Firefox" },
  351. -- properties = { tag = tags[1][2] } },
  352. }
  353. -- }}}
  354.  
  355. -- {{{ Signals
  356. -- Signal function to execute when a new client appears.
  357. client.connect_signal("manage", function (c, startup)
  358. -- Enable sloppy focus
  359. c:connect_signal("mouse::enter", function(c)
  360. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  361. and awful.client.focus.filter(c) then
  362. client.focus = c
  363. end
  364. end)
  365.  
  366. if not startup then
  367. -- Set the windows at the slave,
  368. -- i.e. put it at the end of others instead of setting it master.
  369. -- awful.client.setslave(c)
  370.  
  371. -- Put windows in a smart way, only if they does not set an initial position.
  372. if not c.size_hints.user_position and not c.size_hints.program_position then
  373. awful.placement.no_overlap(c)
  374. awful.placement.no_offscreen(c)
  375. end
  376. end
  377. end)
  378.  
  379. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  380. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  381. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment