zamotivator

~/.config/awesome/rc.lua

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