Advertisement
Guest User

Untitled

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