Advertisement
Guest User

darthlukan

a guest
Nov 22nd, 2009
24,753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.85 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Theme handling library
  6. require("beautiful")
  7. -- Notification library
  8. require("naughty")
  9. -- Widget Lib
  10. require("vicious")
  11.  
  12. -- {{{ Variable definitions
  13. -- Themes define colours, icons, and wallpapers
  14. beautiful.init("/home/darthlukan/.config/awesome/theme.lua")
  15.  
  16. -- This is used later as the default terminal and editor to run.
  17. terminal = "gnome-terminal"
  18. editor = os.getenv("EDITOR") or "nano"
  19. editor_cmd = terminal .. " -e " .. editor
  20.  
  21. -- Default modkey.
  22. -- Usually, Mod4 is the key with a logo between Control and Alt.
  23. -- If you do not like this or do not have such a key,
  24. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  25. -- However, you can use another modifier like Mod1, but it may interact with others.
  26. modkey = "Mod4"
  27.  
  28. -- Table of layouts to cover with awful.layout.inc, order matters.
  29. layouts =
  30. {
  31. awful.layout.suit.tile, --1
  32. awful.layout.suit.tile.left, --2
  33. awful.layout.suit.tile.bottom, --3
  34. awful.layout.suit.tile.top, --4
  35. awful.layout.suit.fair, --5
  36. awful.layout.suit.fair.horizontal, --6
  37. awful.layout.suit.spiral, --7
  38. awful.layout.suit.spiral.dwindle, --8
  39. awful.layout.suit.max, --9
  40. awful.layout.suit.max.fullscreen, --10
  41. awful.layout.suit.magnifier, --11
  42. awful.layout.suit.floating --12
  43. }
  44. -- }}}
  45.  
  46. -- {{{ Tags
  47. -- Define a tag table which hold all screen tags.
  48. tags = {
  49. names = { "irssi", "gedit", "chrome", "fs",
  50. "terms", "vlc", "snd", "dl", "misc",
  51. },
  52. layout = {
  53. layouts[9], layouts[1], layouts[9],
  54. layouts[2], layouts[1], layouts[12],
  55. layouts[5], layouts[3], layouts[12],
  56. }}
  57.  
  58. for s = 1, screen.count() do
  59. tags[s] = awful.tag(tags.names, s, tags.layout)
  60. end
  61. -- }}}
  62.  
  63. -- {{{ Menu
  64. -- Create a laucher widget and a main menu
  65. myawesomemenu = {
  66. { "manual", terminal .. " -e man awesome" },
  67. { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  68. { "restart", awesome.restart },
  69. { "quit", awesome.quit }
  70. }
  71.  
  72. myevilmenu = {
  73. { "GnomeTerm", "gnome-terminal" },
  74. { "Irssi", "gnome-terminal --full-screen -e irssi"},
  75. { "Gedit", "gedit" },
  76. { "BlueFish", "bluefish-unstable" },
  77. { "AlsaMixer", "Eterm -e alsamixer" },
  78. { "Thunar", "thunar" },
  79. { "Chrome", "chromium-browser" },
  80. { "Deluge", "deluge" },
  81. { "DeVeDe", "devede" },
  82. { "VLC", "vlc" },
  83. { "Audacious2", "audacious2"}
  84. }
  85.  
  86. mymainmenu = awful.menu({ items = { { "pure evil", myevilmenu, beautiful.awesome_icon },
  87. { "awesome", myawesomemenu, beautiful.awesome_icon },
  88. { "open terminal", terminal }
  89. }
  90. })
  91.  
  92. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  93. menu = mymainmenu })
  94. -- }}}
  95.  
  96. -- Separators
  97. spacer = widget({ type = "textbox" })
  98. separator = widget({ type = "textbox" })
  99. spacer.text = " "
  100. separator.text = "|"
  101.  
  102. -- {{{ Wibox
  103.  
  104. -- Create a netwidget (usage)
  105. dnicon = widget({ type = "imagebox" })
  106. upicon = widget({ type = "imagebox" })
  107. dnicon.image = image("/home/darthlukan/.config/awesome/icons/down.png")
  108. upicon.image = image("/home/darthlukan/.config/awesome/icons/up.png")
  109. -- Initialize widget
  110. netwidget = widget({ type = "textbox" })
  111. -- Register widget
  112. vicious.register(netwidget, vicious.widgets.net, "${wlan0 up_kb}kb/s / ${wlan0 down_kb}kb/s", 1)
  113.  
  114. -- Create an fswidget (Eat your heart out Saethr!)
  115. fsicon = widget({ type = "imagebox" })
  116. fsicon.image = image("/home/darthlukan/.config/awesome/icons/disk.png")
  117. -- Initialize widget
  118. fswidget = widget({ type = "textbox" })
  119. -- Register widget
  120. vicious.register(fswidget, vicious.widgets.fs, "Root ${/ used}GB / ${/ avail}GB", 37)
  121.  
  122. -- Create a gmailwidget (inbox status)
  123. gmailicon = widget({ type = "imagebox" })
  124. gmailicon.image = image("/home/darthlukan/.config/awesome/icons/mail.png")
  125. -- Initialize widget
  126. gmailwidget = widget({ type = "textbox" })
  127. -- Register widget
  128. vicious.register(gmailwidget, vicious.widgets.gmail, "${count}", 260)
  129.  
  130. -- Create a batwidget (status chrg%)
  131. baticon = widget({ type = "imagebox" })
  132. baticon.image = image("/home/darthlukan/.config/awesome/icons/bat.png")
  133. -- Initialize widget
  134. batwidget = widget({ type = "textbox" })
  135. -- Register widget
  136. vicious.register(batwidget, vicious.widgets.bat, "$1$2%", 31, "BAT1")
  137.  
  138. -- Create a memwidget (usage$ usedMB/TotalMB)
  139. memicon = widget({ type = "imagebox" })
  140. memicon.image = image("/home/darthlukan/.config/awesome/icons/mem.png")
  141. -- Initialize widget
  142. memwidget = widget({ type = "textbox" })
  143. -- Register widget
  144. vicious.register(memwidget, vicious.widgets.mem, "$1% ($2MB/$3MB)", 13)
  145.  
  146. -- Create a cpuwidget (usage%)
  147. cpuicon = widget({ type = "imagebox" })
  148. cpuicon.image = image("/home/darthlukan/.config/awesome/icons/cpu.png")
  149. -- Initialize widget
  150. cpuwidget = widget({ type = "textbox" })
  151. -- Register widget
  152. vicious.register(cpuwidget, vicious.widgets.cpu, "$1%:$2%", 2)
  153.  
  154. -- Create a wifiwidget
  155. wifiicon = widget({ type = "imagebox" })
  156. wifiicon.image = image("/home/darthlukan/.config/awesome/icons/wifi.png")
  157. -- Initialize widget
  158. wifiwidget = widget({ type = "textbox" })
  159. -- Register widget
  160. vicious.register(wifiwidget, vicious.widgets.wifi, "${ssid} ${link}% ${rate}", 5, "wlan0")
  161. -- Create a textclock widget
  162. clockicon = widget({ type = "imagebox" })
  163. clockicon.image = image("/home/darthlukan/.config/awesome/icons/time.png")
  164. mytextclock = awful.widget.textclock({ align = "right" })
  165.  
  166. -- Create a systray
  167. mysystray = widget({ type = "systray" })
  168.  
  169. -- Create a wibox for each screen and add it
  170. mywibox = {}
  171. mypromptbox = {}
  172. mylayoutbox = {}
  173. mytaglist = {}
  174. mytaglist.buttons = awful.util.table.join(
  175. awful.button({ }, 1, awful.tag.viewonly),
  176. awful.button({ modkey }, 1, awful.client.movetotag),
  177. awful.button({ }, 3, awful.tag.viewtoggle),
  178. awful.button({ modkey }, 3, awful.client.toggletag),
  179. awful.button({ }, 4, awful.tag.viewnext),
  180. awful.button({ }, 5, awful.tag.viewprev)
  181. )
  182. mytasklist = {}
  183. mytasklist.buttons = awful.util.table.join(
  184. awful.button({ }, 1, function (c)
  185. if not c:isvisible() then
  186. awful.tag.viewonly(c:tags()[1])
  187. end
  188. client.focus = c
  189. c:raise()
  190. end),
  191. awful.button({ }, 3, function ()
  192. if instance then
  193. instance:hide()
  194. instance = nil
  195. else
  196. instance = awful.menu.clients({ width=250 })
  197. end
  198. end),
  199. awful.button({ }, 4, function ()
  200. awful.client.focus.byidx(1)
  201. if client.focus then client.focus:raise() end
  202. end),
  203. awful.button({ }, 5, function ()
  204. awful.client.focus.byidx(-1)
  205. if client.focus then client.focus:raise() end
  206. end))
  207.  
  208. for s = 1, screen.count() do
  209. -- Create a promptbox for each screen
  210. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  211. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  212. -- We need one layoutbox per screen.
  213. mylayoutbox[s] = awful.widget.layoutbox(s)
  214. mylayoutbox[s]:buttons(awful.util.table.join(
  215. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  216. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  217. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  218. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  219. -- Create a taglist widget
  220. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  221.  
  222. -- Create a tasklist widget
  223. mytasklist[s] = awful.widget.tasklist(function(c)
  224. return awful.widget.tasklist.label.currenttags(c, s)
  225. end, mytasklist.buttons)
  226.  
  227. -- Create the wibox
  228. mywibox[s] = awful.wibox({ position = "top", height = 14, screen = s })
  229. -- Add widgets to the wibox - order matters
  230. mywibox[s].widgets = {
  231. {
  232. mylauncher,
  233. mytaglist[s],
  234. mypromptbox[s],
  235. layout = awful.widget.layout.horizontal.leftright
  236. },
  237. mylayoutbox[s],
  238. mytextclock, spacer, clockicon,
  239. separator, batwidget, spacer, baticon, separator,
  240. upicon, netwidget, dnicon, separator,
  241. wifiwidget, spacer, wifiicon, separator,
  242. fswidget, spacer, fsicon, separator,
  243. memwidget, spacer, memicon, separator,
  244. cpuwidget, spacer, cpuicon, separator,
  245. gmailwidget, spacer, gmailicon, separator,
  246. s == 1 and mysystray or nil,
  247. mytasklist[s],
  248. layout = awful.widget.layout.horizontal.rightleft
  249. }
  250. end
  251. -- }}}
  252.  
  253. -- {{{ Mouse bindings
  254. root.buttons(awful.util.table.join(
  255. awful.button({ }, 3, function () mymainmenu:toggle() end),
  256. awful.button({ }, 4, awful.tag.viewnext),
  257. awful.button({ }, 5, awful.tag.viewprev)
  258. ))
  259. -- }}}
  260.  
  261. -- {{{ Key bindings
  262. globalkeys = awful.util.table.join(
  263. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  264. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  265. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  266.  
  267. awful.key({ modkey, }, "j",
  268. function ()
  269. awful.client.focus.byidx( 1)
  270. if client.focus then client.focus:raise() end
  271. end),
  272. awful.key({ modkey, }, "k",
  273. function ()
  274. awful.client.focus.byidx(-1)
  275. if client.focus then client.focus:raise() end
  276. end),
  277. awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
  278.  
  279. -- Layout manipulation
  280. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  281. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  282. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  283. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  284. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  285. awful.key({ modkey, }, "Tab",
  286. function ()
  287. awful.client.focus.history.previous()
  288. if client.focus then
  289. client.focus:raise()
  290. end
  291. end),
  292.  
  293. -- Standard program
  294. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  295. awful.key({ modkey, "Control" }, "r", awesome.restart),
  296. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  297.  
  298. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  299. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  300. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  301. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  302. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  303. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  304. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  305. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  306.  
  307. -- Prompt
  308. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  309.  
  310. awful.key({ modkey }, "x",
  311. function ()
  312. awful.prompt.run({ prompt = "Run Lua code: " },
  313. mypromptbox[mouse.screen].widget,
  314. awful.util.eval, nil,
  315. awful.util.getdir("cache") .. "/history_eval")
  316. end)
  317. )
  318.  
  319. clientkeys = awful.util.table.join(
  320. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  321. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  322. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  323. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  324. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  325. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  326. awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
  327. awful.key({ modkey, }, "m",
  328. function (c)
  329. c.maximized_horizontal = not c.maximized_horizontal
  330. c.maximized_vertical = not c.maximized_vertical
  331. end)
  332. )
  333.  
  334. -- Compute the maximum number of digit we need, limited to 9
  335. keynumber = 0
  336. for s = 1, screen.count() do
  337. keynumber = math.min(9, math.max(#tags[s], keynumber));
  338. end
  339.  
  340. -- Bind all key numbers to tags.
  341. -- Be careful: we use keycodes to make it works on any keyboard layout.
  342. -- This should map on the top row of your keyboard, usually 1 to 9.
  343. for i = 1, keynumber do
  344. globalkeys = awful.util.table.join(globalkeys,
  345. awful.key({ modkey }, "#" .. i + 9,
  346. function ()
  347. local screen = mouse.screen
  348. if tags[screen][i] then
  349. awful.tag.viewonly(tags[screen][i])
  350. end
  351. end),
  352. awful.key({ modkey, "Control" }, "#" .. i + 9,
  353. function ()
  354. local screen = mouse.screen
  355. if tags[screen][i] then
  356. awful.tag.viewtoggle(tags[screen][i])
  357. end
  358. end),
  359. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  360. function ()
  361. if client.focus and tags[client.focus.screen][i] then
  362. awful.client.movetotag(tags[client.focus.screen][i])
  363. end
  364. end),
  365. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  366. function ()
  367. if client.focus and tags[client.focus.screen][i] then
  368. awful.client.toggletag(tags[client.focus.screen][i])
  369. end
  370. end))
  371. end
  372.  
  373. clientbuttons = awful.util.table.join(
  374. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  375. awful.button({ modkey }, 1, awful.mouse.client.move),
  376. awful.button({ modkey }, 3, awful.mouse.client.resize))
  377.  
  378. -- Set keys
  379. root.keys(globalkeys)
  380. -- }}}
  381.  
  382. -- {{{ Rules
  383. awful.rules.rules = {
  384. -- All clients will match this rule.
  385. { rule = { },
  386. properties = { border_width = beautiful.border_width,
  387. border_color = beautiful.border_normal,
  388. focus = true,
  389. keys = clientkeys,
  390. buttons = clientbuttons } },
  391. -- Set Firefox to always map on tags number 2 of screen 1.
  392. -- { rule = { class = "Firefox" },
  393. -- properties = { tag = tags[1][2] } },
  394. }
  395. -- }}}
  396.  
  397. -- {{{ Signals
  398. -- Signal function to execute when a new client appears.
  399. client.add_signal("manage", function (c, startup)
  400. -- Add a titlebar
  401. -- awful.titlebar.add(c, { modkey = modkey })
  402.  
  403. -- Enable sloppy focus
  404. c:add_signal("mouse::enter", function(c)
  405. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  406. and awful.client.focus.filter(c) then
  407. client.focus = c
  408. end
  409. end)
  410.  
  411. if not startup then
  412. -- Set the windows at the slave,
  413. -- i.e. put it at the end of others instead of setting it master.
  414. -- awful.client.setslave(c)
  415.  
  416. -- Put windows in a smart way, only if they does not set an initial position.
  417. if not c.size_hints.user_position and not c.size_hints.program_position then
  418. awful.placement.no_overlap(c)
  419. awful.placement.no_offscreen(c)
  420. end
  421. end
  422. end)
  423.  
  424. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  425. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  426. -- }}}
  427.  
  428. -- Autostart my personal stuffs
  429.  
  430. os.execute("tilda &")
  431.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement