Advertisement
Guest User

rc.lua

a guest
Feb 17th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.84 KB | None | 0 0
  1. -- {{{ License
  2. --
  3. -- Awesome configuration, using awesome 3.4.13 on Arch GNU/Linux
  4. -- * Adrian C. <anrxc@sysphere.org>
  5.  
  6. -- Screenshot: http://sysphere.org/gallery/snapshots
  7.  
  8. -- This work is licensed under the Creative Commons Attribution-Share
  9. -- Alike License: http://creativecommons.org/licenses/by-sa/3.0/
  10. -- }}}
  11.  
  12.  
  13. -- {{{ Libraries
  14. require("awful")
  15. require("awful.rules")
  16. require("awful.autofocus")
  17. freedesktop_utils = require('freedesktop.utils')
  18. freedesktop_menu = require('freedesktop.menu')
  19. -- User libraries
  20. vicious = require("vicious")
  21. -- }}}
  22.  
  23.  
  24. -- {{{ Variable definitions
  25. local altkey = "Mod1"
  26. local modkey = "Mod4"
  27.  
  28. local os = os
  29. local home = os.getenv("HOME")
  30. local exec = awful.util.spawn
  31. local sexec = awful.util.spawn_with_shell
  32. local scount = screen.count()
  33.  
  34. -- Beautiful theme
  35. beautiful.init("/opt/local/share/awesome/themes/default/theme.lua")
  36.  
  37. -- Window management layouts
  38. layouts = {
  39. awful.layout.suit.tile, -- 1
  40. awful.layout.suit.tile.bottom, -- 2
  41. awful.layout.suit.fair, -- 3
  42. awful.layout.suit.max, -- 4
  43. awful.layout.suit.magnifier, -- 5
  44. awful.layout.suit.floating -- 6
  45. }
  46. -- }}}
  47.  
  48.  
  49. -- {{{ Tags
  50. tags = {
  51. names = { "1", "2", "3", "4", "5", 6, 7, "8", "9" },
  52. layout = { layouts[2], layouts[1], layouts[1], layouts[4], layouts[1],
  53. layouts[6], layouts[6], layouts[5], layouts[6]
  54. }}
  55.  
  56. for s = 1, scount do
  57. tags[s] = awful.tag(tags.names, s, tags.layout)
  58. for i, t in ipairs(tags[s]) do
  59. awful.tag.setproperty(t, "mwfact", i==5 and 0.13 or 0.5)
  60. awful.tag.setproperty(t, "hide", (i==6 or i==7) and true)
  61. end
  62. end
  63. -- }}}
  64.  
  65.  
  66.  
  67.  
  68. -- {{{ Wibox
  69. --
  70. -- {{{ Widgets configuration
  71. --
  72. -- {{{ Reusable separator
  73. separator = widget({ type = "imagebox" })
  74. separator.image = image(beautiful.widget_sep)
  75. -- }}}
  76.  
  77. -- {{{ Reusable spacer
  78. spacer = widget({ type = "textbox" })
  79. spacer.text = " "
  80. -- }}}
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. -- {{{ Battery state
  93. baticon = widget({ type = "imagebox" })
  94. baticon.image = image(beautiful.widget_bat)
  95. -- Initialize widget
  96. batwidget = widget({ type = "textbox" })
  97. -- Register widget
  98. vicious.register(batwidget, vicious.widgets.bat, "$1$2%", 61, "BAT0")
  99. -- }}}
  100.  
  101.  
  102. -- }}}
  103.  
  104. -- {{{ File system usage
  105. fsicon = widget({ type = "imagebox" })
  106. fsicon.image = image(beautiful.widget_fs)
  107. -- Initialize widgets
  108. fs = {
  109. b = awful.widget.progressbar(), r = awful.widget.progressbar(),
  110. h = awful.widget.progressbar(), s = awful.widget.progressbar()
  111. }
  112. -- Progressbar properties
  113. for _, w in pairs(fs) do
  114. w:set_vertical(true):set_ticks(true)
  115. w:set_height(14):set_width(5):set_ticks_size(2)
  116. w:set_border_color(beautiful.border_widget)
  117. w:set_background_color(beautiful.fg_off_widget)
  118. w:set_gradient_colors({ beautiful.fg_widget,
  119. beautiful.fg_center_widget, beautiful.fg_end_widget
  120. }) -- Register buttons
  121. w.widget:buttons(awful.util.table.join(
  122. awful.button({ }, 1, function () exec("rox", false) end)
  123. ))
  124. end -- Enable caching
  125. vicious.cache(vicious.widgets.fs)
  126. -- Register widgets
  127. vicious.register(fs.b, vicious.widgets.fs, "${/boot used_p}", 599)
  128. vicious.register(fs.r, vicious.widgets.fs, "${/ used_p}", 599)
  129. vicious.register(fs.h, vicious.widgets.fs, "${/home used_p}", 599)
  130. vicious.register(fs.s, vicious.widgets.fs, "${/mnt/storage used_p}", 599)
  131. -- }}}
  132.  
  133.  
  134. -- {{{ Mail subject
  135. mygmail = widget({ type = "textbox" })
  136. gmail_t = awful.tooltip({ objects = { mygmail },})
  137.  
  138. mygmailimg = widget({ type = "imagebox" })
  139. mygmailimg.image = image(beautiful.widget_mail)
  140.  
  141. vicious.register(mygmail, vicious.widgets.gmail,
  142. function (widget, args)
  143. gmail_t:set_text(args["{subject}"])
  144. gmail_t:add_to_object(mygmailimg)
  145. return args["{count}"]
  146. end, 120)
  147. --the '120' here means check every 2 minutes.
  148. mygmail:buttons(awful.util.table.join(
  149. awful.button({ }, 1, function () exec("google-chrome\ https://gmail.com") end)
  150. ))
  151. -- }}}
  152.  
  153.  
  154. -- {{{ Volume level
  155. volicon = widget({ type = "imagebox" })
  156. volicon.image = image(beautiful.widget_vol)
  157. -- Initialize widgets
  158. volbar = awful.widget.progressbar()
  159. volwidget = widget({ type = "textbox" })
  160. -- Progressbar properties
  161. volbar:set_vertical(true):set_ticks(false)
  162. volbar:set_height(12):set_width(8):set_ticks_size(2)
  163. volbar:set_background_color(beautiful.fg_off_widget)
  164. volbar:set_gradient_colors({ beautiful.fg_end_widget,
  165. beautiful.fg_center_widget, beautiful.fg_widget
  166. }) -- Enable caching
  167. vicious.cache(vicious.widgets.volume)
  168. -- Register widgets
  169. vicious.register(volbar, vicious.widgets.volume, "$1", 2, "Master")
  170. vicious.register(volwidget, vicious.widgets.volume, "$1%", 2, "Master")
  171.  
  172. -- }}}
  173.  
  174.  
  175.  
  176.  
  177.  
  178. -- {{{ Date and time
  179. dateicon = widget({ type = "imagebox" })
  180. dateicon.image = image(beautiful.widget_date)
  181. -- Initialize widget
  182. datewidget = widget({ type = "textbox" })
  183. -- Register widget
  184. vicious.register(datewidget, vicious.widgets.date, "<span font-family='terminus' color='#999999'>%b %d, %l:%M:</span>%p", 1)
  185.  
  186.  
  187. -- Register buttons
  188. datewidget:buttons(awful.util.table.join(
  189. awful.button({ }, 1, function () exec("pylendar.py") end)
  190. ))
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. -- }}}
  203.  
  204. -- {{{ System tray
  205. systray = widget({ type = "systray" })
  206. -- }}}
  207. -- }}}
  208.  
  209. -- MPD Initialize widget
  210. mpdwidget = widget({ type = "textbox"})
  211. mpdwidget.align = "center"
  212. mpdwidget.width = 600
  213. -- Register widget
  214. vicious.register(mpdwidget, vicious.widgets.mpd,
  215. function (widget, args)
  216. if args["{state}"] == "Stop" then
  217. return "...No music :("
  218. else
  219. a = "<span color='#35A1D7'>" .. args["{Artist}"] .. "</span>"
  220. return a..' - '.. args["{Title}"]
  221. end
  222. end, 1)
  223.  
  224.  
  225. -- {{{ Wibox initialisation
  226. wibox = {}
  227. promptbox = {}
  228. layoutbox = {}
  229. taglist = {}
  230. taglist.buttons = awful.util.table.join(
  231. awful.button({ }, 1, awful.tag.viewonly),
  232. awful.button({ modkey }, 1, awful.client.movetotag),
  233. awful.button({ }, 3, awful.tag.viewtoggle),
  234. awful.button({ modkey }, 3, awful.client.toggletag),
  235. awful.button({ }, 5, awful.tag.viewnext),
  236. awful.button({ }, 4, awful.tag.viewprev
  237. ))
  238.  
  239. for s = 1, scount do
  240. -- Create a promptbox
  241. promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  242. -- Create a layoutbox
  243. layoutbox[s] = awful.widget.layoutbox(s)
  244. layoutbox[s]:buttons(awful.util.table.join(
  245. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  246. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  247. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  248. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)
  249. ))
  250.  
  251. -- Create the taglist
  252. taglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, taglist.buttons)
  253. -- Create the wibox
  254. wibox[s] = awful.wibox({ screen = s,
  255. fg = beautiful.fg_normal, height = 12,
  256. bg = beautiful.bg_normal, position = "top",
  257. border_color = beautiful.border_focus,
  258. border_width = beautiful.border_width
  259. })
  260. -- Add widgets to the wibox
  261. wibox[s].widgets = {
  262. { taglist[s], layoutbox[s], separator, promptbox[s],
  263. mpdwidget,
  264. ["layout"] = awful.widget.layout.horizontal.leftright
  265. },
  266.  
  267.  
  268.  
  269.  
  270. s == 1 and systray or nil,
  271. datewidget, dateicon,
  272.  
  273.  
  274.  
  275. -- separator, upicon, netwidget, dnicon,
  276. separator, netwidget,
  277. separator, fs.s.widget, fs.h.widget, fs.r.widget, fs.b.widget, fsicon,
  278. separator, memicon,
  279. separator, tzswidget, cpuicon,
  280. separator, pacwidget, pacicon,
  281. separator, ["layout"] = awful.widget.layout.horizontal.rightleft
  282. }
  283. end
  284. -- }}}
  285.  
  286. -- }}}
  287.  
  288.  
  289. -- {{{ Mouse bindings
  290. root.buttons(awful.util.table.join(
  291. awful.button({ }, 5, awful.tag.viewnext),
  292. awful.button({ }, 4, awful.tag.viewprev)
  293. ))
  294.  
  295. -- Client bindings
  296. clientbuttons = awful.util.table.join(
  297. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  298. awful.button({ modkey }, 1, awful.mouse.client.move),
  299. awful.button({ modkey }, 3, awful.mouse.client.resize)
  300. )
  301.  
  302. -- {{{ Client manipulation
  303. clientkeys = awful.util.table.join(
  304. awful.key({ modkey }, "c", function (c) c:kill() end),
  305. awful.key({ modkey }, "d", function (c) scratch.pad.set(c, 0.60, 0.60, true) end),
  306. awful.key({ modkey }, "f", function (c) c.fullscreen = not c.fullscreen end),
  307. awful.key({ modkey }, "m", function (c)
  308. c.maximized_horizontal = not c.maximized_horizontal
  309. c.maximized_vertical = not c.maximized_vertical
  310. end),
  311. awful.key({ modkey }, "o", awful.client.movetoscreen),
  312. awful.key({ modkey }, "Next", function () awful.client.moveresize( 20, 20, -40, -40) end),
  313. awful.key({ modkey }, "Prior", function () awful.client.moveresize(-20, -20, 40, 40) end),
  314. awful.key({ modkey }, "Down", function () awful.client.moveresize( 0, 20, 0, 0) end),
  315. awful.key({ modkey }, "Up", function () awful.client.moveresize( 0, -20, 0, 0) end),
  316. awful.key({ modkey }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end),
  317. awful.key({ modkey }, "Right", function () awful.client.moveresize( 20, 0, 0, 0) end),
  318. awful.key({ modkey, "Control"},"r", function (c) c:redraw() end),
  319. awful.key({ modkey, "Shift" }, "0", function (c) c.sticky = not c.sticky end),
  320. awful.key({ modkey, "Shift" }, "m", function (c) c:swap(awful.client.getmaster()) end),
  321. awful.key({ modkey, "Shift" }, "c", function (c) exec("kill -CONT " .. c.pid) end),
  322. awful.key({ modkey, "Shift" }, "s", function (c) exec("kill -STOP " .. c.pid) end),
  323. awful.key({ modkey, "Shift" }, "t", function (c)
  324. if c.titlebar then awful.titlebar.remove(c)
  325. else awful.titlebar.add(c, { modkey = modkey }) end
  326. end),
  327. awful.key({ modkey, "Shift" }, "f", function (c) if awful.client.floating.get(c)
  328. then awful.client.floating.delete(c); awful.titlebar.remove(c)
  329. else awful.client.floating.set(c, true); awful.titlebar.add(c) end
  330. end)
  331. )
  332. -- }}}
  333.  
  334. -- {{{ Keyboard digits
  335. local keynumber = 0
  336. for s = 1, scount do
  337. keynumber = math.min(9, math.max(#tags[s], keynumber));
  338. end
  339. -- }}}
  340.  
  341. -- {{{ Tag controls
  342. for i = 1, keynumber do
  343. globalkeys = awful.util.table.join( globalkeys,
  344. awful.key({ modkey }, "#" .. i + 9, function ()
  345. local screen = mouse.screen
  346. if tags[screen][i] then awful.tag.viewonly(tags[screen][i]) end
  347. end),
  348. awful.key({ modkey, "Control" }, "#" .. i + 9, function ()
  349. local screen = mouse.screen
  350. if tags[screen][i] then awful.tag.viewtoggle(tags[screen][i]) end
  351. end),
  352. awful.key({ modkey, "Shift" }, "#" .. i + 9, function ()
  353. if client.focus and tags[client.focus.screen][i] then
  354. awful.client.movetotag(tags[client.focus.screen][i])
  355. end
  356. end),
  357. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function ()
  358. if client.focus and tags[client.focus.screen][i] then
  359. awful.client.toggletag(tags[client.focus.screen][i])
  360. end
  361. end))
  362. end
  363. -- }}}
  364.  
  365. -- Set keys
  366. root.keys(globalkeys)
  367. -- }}}
  368.  
  369.  
  370. -- {{{ Rules
  371. function titlebarwithsettings(c)
  372. awful.titlebar.add(c, {modkey = modkey})
  373. end
  374.  
  375. awful.rules.rules = {
  376. { rule = { }, properties = {
  377. focus = true, size_hints_honor = false,
  378. keys = clientkeys, buttons = clientbuttons,
  379. border_width = beautiful.border_width,
  380. border_color = beautiful.border_normal }
  381. },
  382. { rule = { class = "Firefox", instance = "Navigator" },
  383. properties = { tag = tags[scount][3] } },
  384. { rule = { class = "Google-chrome", instance = "google-chrome" },
  385. properties = { tag = tags[scount][3] } },
  386. { rule = { class = "Emacs", instance = "emacs" },
  387. properties = { tag = tags[1][2] } },
  388. { rule = { class = "Emacs", instance = "_Remember_" },
  389. properties = { floating = true }, callback = awful.titlebar.add },
  390. { rule = { class = "Xmessage", instance = "xmessage" },
  391. properties = { floating = true }, callback = awful.titlebar.add },
  392. { rule = { instance = "plugin-container" },
  393. properties = { floating = true }, callback = awful.titlebar.add },
  394. { rule = { class = "Akregator" }, properties = { tag = tags[scount][8]}},
  395. { rule = { name = "Alpine" }, properties = { tag = tags[1][4]} },
  396. { rule = { class = "Gajim" }, properties = { tag = tags[1][5]} },
  397. { rule = { class = "Ark" }, properties = { floating = true } },
  398. { rule = { class = "Geeqie" }, properties = { floating = true } },
  399. { rule = { class = "ROX-Filer" }, properties = { floating = true } },
  400. { rule = { class = "Pinentry.*" }, properties = { floating = true } },
  401. { rule = { class = "Conky", instance = "Conky" },
  402. properties = { floating = true }, callback = awful.titlebar.add },
  403. { rule = { class = "Xfce4-notifyd", instance = "xfce4-notifyd" },
  404. properties = { floating = true }, callback = awful.titlebar.add },
  405. }
  406. -- }}}
  407.  
  408.  
  409. -- {{{ Signals
  410. --
  411. -- {{{ Manage signal handler
  412. client.add_signal("manage", function (c, startup)
  413. -- Add titlebar to floaters, but remove those from rule callback
  414. if awful.client.floating.get(c)
  415. or awful.layout.get(c.screen) == awful.layout.suit.floating then
  416. if c.titlebar then awful.titlebar.remove(c)
  417. else awful.titlebar.add(c, {modkey = modkey}) end
  418. end
  419.  
  420. -- Enable sloppy focus
  421. c:add_signal("mouse::enter", function (c)
  422. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  423. and awful.client.focus.filter(c) then
  424. client.focus = c
  425. end
  426. end)
  427.  
  428. -- Client placement
  429. if not startup then
  430. awful.client.setslave(c)
  431.  
  432. if not c.size_hints.program_position
  433. and not c.size_hints.user_position then
  434. awful.placement.no_overlap(c)
  435. awful.placement.no_offscreen(c)
  436. end
  437. end
  438. end)
  439. -- }}}
  440.  
  441. -- {{{ Focus signal handlers
  442. client.add_signal("focus", function (c) c.border_color = beautiful.border_focus end)
  443. client.add_signal("unfocus", function (c) c.border_color = beautiful.border_normal end)
  444. -- }}}
  445.  
  446. -- {{{ Arrange signal handler
  447. for s = 1, scount do screen[s]:add_signal("arrange", function ()
  448. local clients = awful.client.visible(s)
  449. local layout = awful.layout.getname(awful.layout.get(s))
  450.  
  451. for _, c in pairs(clients) do -- Floaters are always on top
  452. if awful.client.floating.get(c) or layout == "floating"
  453. then if not c.fullscreen then c.above = true end
  454. else c.above = false end
  455. end
  456. end)
  457. end
  458. -- }}}
  459. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement