Advertisement
Guest User

Untitled

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