Stormer97

rc.lua broken

May 3rd, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.68 KB | None | 0 0
  1. vicious = require("vicious")
  2. -- Standard awesome library
  3. require("awful")
  4. require("awful.autofocus")
  5. require("awful.rules")
  6. -- Theme handling library
  7. require("beautiful")
  8. -- Notification library
  9. require("naughty")
  10. require("wicked")
  11. --require("vicious")
  12. -- Load Debian menu entries
  13. require("debian.menu")
  14.  
  15. -- {{{ Error handling
  16. -- Check if awesome encountered an error during startup and fell back to
  17. -- another config (This code will only ever execute for the fallback config)
  18. if awesome.startup_errors then
  19. naughty.notify({ preset = naughty.config.presets.critical,
  20. title = "Oops, there were errors during startup!",
  21. text = awesome.startup_errors })
  22. end
  23.  
  24. -- Handle runtime errors after startup
  25. do
  26. local in_error = false
  27. awesome.add_signal("debug::error", function (err)
  28. -- Make sure we don't go into an endless error loop
  29. if in_error then return end
  30. in_error = true
  31.  
  32. naughty.notify({ preset = naughty.config.presets.critical,
  33. title = "Oops, an error happened!",
  34. text = err })
  35. in_error = false
  36. end)
  37. end
  38. -- }}}
  39.  
  40. -- {{{ Variable definitions
  41. -- Themes define colours, icons, and wallpapers
  42. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  43.  
  44. -- This is used later as the default terminal and editor to run.
  45. terminal = "x-terminal-emulator"
  46. editor = os.getenv("EDITOR") or "editor"
  47. editor_cmd = terminal .. " -e " .. editor
  48.  
  49. -- Default modkey.
  50. -- Usually, Mod4 is the key with a logo between Control and Alt.
  51. -- If you do not like this or do not have such a key,
  52. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  53. -- However, you can use another modifier like Mod1, but it may interact with others.
  54. modkey = "Mod4"
  55.  
  56. -- Table of layouts to cover with awful.layout.inc, order matters.
  57. layouts =
  58. {
  59. awful.layout.suit.floating,
  60. awful.layout.suit.tile,
  61. awful.layout.suit.tile.left,
  62. awful.layout.suit.tile.bottom,
  63. awful.layout.suit.tile.top,
  64. awful.layout.suit.fair,
  65. awful.layout.suit.fair.horizontal,
  66. awful.layout.suit.spiral,
  67. awful.layout.suit.spiral.dwindle,
  68. awful.layout.suit.max,
  69. awful.layout.suit.max.fullscreen,
  70. awful.layout.suit.magnifier
  71. }
  72. -- }}}
  73.  
  74. -- {{{ Tags
  75. -- Define a tag table which hold all screen tags.
  76. tags = {}
  77. for s = 1, screen.count() do
  78. -- Each screen has its own tag table.
  79. tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  80. end
  81. -- }}}
  82.  
  83. -- {{{ Menu
  84. -- Create a laucher widget and a main menu
  85. myawesomemenu = {
  86. { "manual", terminal .. " -e man awesome" },
  87. { "edit config", editor_cmd .. " " .. awesome.conffile },
  88. { "restart", awesome.restart },
  89. { "quit", awesome.quit }
  90. }
  91.  
  92. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  93. { "Debian", debian.menu.Debian_menu.Debian },
  94. { "open terminal", terminal }
  95. }
  96. })
  97.  
  98. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  99. menu = mymainmenu })
  100. -- }}}
  101.  
  102. -- {{{ Wibox
  103. netwidget = widget({type = "textbox"})
  104. vicious.register(netwidget, vicious.widgets.net, '<span color="#CC9393">${eth0 down_kb}</span> <span color="#7F9F7F">${eth0 up_kb}</span>', 3)
  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. netwidget,
  188. s == 1 and mysystray or nil,
  189. mytasklist[s],
  190. layout = awful.widget.layout.horizontal.rightleft
  191. }
  192. end
  193. -- }}}
  194.  
  195. -- {{{ Mouse bindings
  196. root.buttons(awful.util.table.join(
  197. awful.button({ }, 3, function () mymainmenu:toggle() end),
  198. awful.button({ }, 4, awful.tag.viewnext),
  199. awful.button({ }, 5, awful.tag.viewprev)
  200. ))
  201. -- }}}
  202.  
  203. -- {{{ Key bindings
  204. globalkeys = awful.util.table.join(
  205. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  206. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  207. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  208.  
  209. awful.key({ modkey, }, "j",
  210. function ()
  211. awful.client.focus.byidx( 1)
  212. if client.focus then client.focus:raise() end
  213. end),
  214. awful.key({ modkey, }, "k",
  215. function ()
  216. awful.client.focus.byidx(-1)
  217. if client.focus then client.focus:raise() end
  218. end),
  219. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  220.  
  221. -- Layout manipulation
  222. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  223. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  224. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  225. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  226. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  227. awful.key({ modkey, }, "Tab",
  228. function ()
  229. awful.client.focus.history.previous()
  230. if client.focus then
  231. client.focus:raise()
  232. end
  233. end),
  234.  
  235. -- Standard program
  236. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  237. awful.key({ modkey, "Control" }, "r", awesome.restart),
  238. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  239.  
  240. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  241. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  242. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  243. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  244. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  245. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  246. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  247. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  248.  
  249. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  250.  
  251. -- Prompt
  252. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  253.  
  254. awful.key({ modkey }, "x",
  255. function ()
  256. awful.prompt.run({ prompt = "Run Lua code: " },
  257. mypromptbox[mouse.screen].widget,
  258. awful.util.eval, nil,
  259. awful.util.getdir("cache") .. "/history_eval")
  260. end)
  261. )
  262.  
  263. clientkeys = awful.util.table.join(
  264. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  265. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  266. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  267. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  268. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  269. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  270. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  271. awful.key({ modkey, }, "n",
  272. function (c)
  273. -- The client currently has the input focus, so it cannot be
  274. -- minimized, since minimized clients can't have the focus.
  275. c.minimized = true
  276. end),
  277. awful.key({ modkey, }, "m",
  278. function (c)
  279. c.maximized_horizontal = not c.maximized_horizontal
  280. c.maximized_vertical = not c.maximized_vertical
  281. end)
  282. )
  283.  
  284. -- Compute the maximum number of digit we need, limited to 9
  285. keynumber = 0
  286. for s = 1, screen.count() do
  287. keynumber = math.min(9, math.max(#tags[s], keynumber));
  288. end
  289.  
  290. -- Bind all key numbers to tags.
  291. -- Be careful: we use keycodes to make it works on any keyboard layout.
  292. -- This should map on the top row of your keyboard, usually 1 to 9.
  293. for i = 1, keynumber do
  294. globalkeys = awful.util.table.join(globalkeys,
  295. awful.key({ modkey }, "#" .. i + 9,
  296. function ()
  297. local screen = mouse.screen
  298. if tags[screen][i] then
  299. awful.tag.viewonly(tags[screen][i])
  300. end
  301. end),
  302. awful.key({ modkey, "Control" }, "#" .. i + 9,
  303. function ()
  304. local screen = mouse.screen
  305. if tags[screen][i] then
  306. awful.tag.viewtoggle(tags[screen][i])
  307. end
  308. end),
  309. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  310. function ()
  311. if client.focus and tags[client.focus.screen][i] then
  312. awful.client.movetotag(tags[client.focus.screen][i])
  313. end
  314. end),
  315. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  316. function ()
  317. if client.focus and tags[client.focus.screen][i] then
  318. awful.client.toggletag(tags[client.focus.screen][i])
  319. end
  320. end))
  321. end
  322.  
  323. clientbuttons = awful.util.table.join(
  324. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  325. awful.button({ modkey }, 1, awful.mouse.client.move),
  326. awful.button({ modkey }, 3, awful.mouse.client.resize))
  327.  
  328. -- Set keys
  329. root.keys(globalkeys)
  330. -- }}}
  331.  
  332. -- {{{ Rules
  333. awful.rules.rules = {
  334. -- All clients will match this rule.
  335. { rule = { },
  336. properties = { border_width = beautiful.border_width,
  337. border_color = beautiful.border_normal,
  338. focus = true,
  339. keys = clientkeys,
  340. buttons = clientbuttons } },
  341. { rule = { class = "MPlayer" },
  342. properties = { floating = true } },
  343. { rule = { class = "pinentry" },
  344. properties = { floating = true } },
  345. { rule = { class = "gimp" },
  346. properties = { floating = true } },
  347. -- Set Firefox to always map on tags number 2 of screen 1.
  348. -- { rule = { class = "Firefox" },
  349. -- properties = { tag = tags[1][2] } },
  350. }
  351. -- }}}
  352.  
  353. -- {{{ Signals
  354. -- Signal function to execute when a new client appears.
  355. client.add_signal("manage", function (c, startup)
  356. -- Add a titlebar
  357. -- awful.titlebar.add(c, { modkey = modkey })
  358.  
  359. -- Enable sloppy focus
  360. c:add_signal("mouse::enter", function(c)
  361. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  362. and awful.client.focus.filter(c) then
  363. client.focus = c
  364. end
  365. end)
  366.  
  367. if not startup then
  368. -- Set the windows at the slave,
  369. -- i.e. put it at the end of others instead of setting it master.
  370. -- awful.client.setslave(c)
  371.  
  372. -- Put windows in a smart way, only if they does not set an initial position.
  373. if not c.size_hints.user_position and not c.size_hints.program_position then
  374. awful.placement.no_overlap(c)
  375. awful.placement.no_offscreen(c)
  376. end
  377. end
  378. end)
  379.  
  380. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  381. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  382. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment