Advertisement
boswbr25

rc.lua

May 21st, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.50 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 library
  10. require("vicious")
  11. -- Expose Feature
  12. require("revelation")
  13.  
  14. -- {{{ Error handling
  15. -- Check if awesome encountered an error during startup and fell back to
  16. -- another config (This code will only ever execute for the fallback config)
  17. if awesome.startup_errors then
  18. naughty.notify({ preset = naughty.config.presets.critical,
  19. title = "Oops, there were errors during startup!",
  20. text = awesome.startup_errors })
  21. end
  22.  
  23. -- Handle runtime errors after startup
  24. do
  25. local in_error = false
  26. awesome.add_signal("debug::error", function (err)
  27. -- Make sure we don't go into an endless error loop
  28. if in_error then return end
  29. in_error = true
  30.  
  31. naughty.notify({ preset = naughty.config.presets.critical,
  32. title = "Oops, an error happened!",
  33. text = err })
  34. in_error = false
  35. end)
  36. end
  37. -- }}}
  38.  
  39. -- {{{ Variable definitions
  40. -- Themes define colours, icons, and wallpapers
  41. beautiful.init("/home/boswbr25/.config/awesome/themes/zenburn/theme.lua")
  42.  
  43. -- This is used later as the default terminal and editor to run.
  44. terminal = "terminal"
  45. editor = os.getenv("EDITOR") or "nano"
  46. editor_cmd = terminal .. " -e " .. editor
  47.  
  48. -- Default modkey.
  49. -- Usually, Mod4 is the key with a logo between Control and Alt.
  50. -- If you do not like this or do not have such a key,
  51. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  52. -- However, you can use another modifier like Mod1, but it may interact with others.
  53. modkey = "Mod4"
  54.  
  55. -- Table of layouts to cover with awful.layout.inc, order matters.
  56. layouts =
  57. {
  58. awful.layout.suit.floating,
  59. awful.layout.suit.tile,
  60. awful.layout.suit.tile.left,
  61. -- awful.layout.suit.tile.bottom,
  62. -- awful.layout.suit.tile.top,
  63. awful.layout.suit.fair,
  64. -- awful.layout.suit.fair.horizontal,
  65. -- awful.layout.suit.spiral,
  66. -- awful.layout.suit.spiral.dwindle,
  67. awful.layout.suit.max,
  68. -- awful.layout.suit.max.fullscreen,
  69. -- awful.layout.suit.magnifier
  70. }
  71. -- }}}
  72.  
  73. -- {{{ Tags
  74. -- Define a tag table which will hold all screen tags.
  75. tags = {
  76. names = { "www", "term", "email", "music", "tile", "float"},
  77. layout = { layouts[4], layouts[4], layouts[4], layouts[5], layouts[2],
  78. layouts[1]
  79. }}
  80. for s = 1, screen.count() do
  81. -- Each screen has its own tag table.
  82. tags[s] = awful.tag(tags.names, s, tags.layout)
  83. end
  84. -- }}}
  85. function run_once(prg,arg_string,pname,screen)
  86. if not prg then
  87. do return nil end
  88. end
  89.  
  90. if not pname then
  91. pname = prg
  92. end
  93.  
  94. if not arg_string then
  95. awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
  96. else
  97. awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. " " .. arg_string .. ")",screen)
  98. end
  99. end
  100.  
  101. run_once("parcellite",nil)
  102. run_once("postler",nil)
  103.  
  104.  
  105. -- {{{ Menu
  106. -- Create a laucher widget and a main menu
  107. myawesomemenu = {
  108. { "manual", terminal .. " -e man awesome" },
  109. { "edit config", "geany /home/boswbr25/.config/awesome/rc.lua" },
  110. { "restart awesome", awesome.restart },
  111. { "logout", awesome.quit },
  112. { "suspend", "sudo pm-suspend" },
  113. { "reboot", "sudo reboot" },
  114. { "shutdown", "sudo shutdown -h now" }
  115.  
  116. }
  117. mysystem = {
  118. { "Terminal", terminal, "/usr/share/icons/Faenza/apps/96/terminal.png"},
  119. { "Geany", "geany", "/usr/share/icons/hicolor/48x48/apps/geany.png"},
  120. { "File Manager", "thunar", "/usr/share/icons/Faenza/apps/96/thunar.png"},
  121. { "Firewall", "gufw", "/home/boswbr25/builds/gufw/pkg/usr/share/icons/hicolor/48x48/apps/gufw.png" }
  122. }
  123.  
  124. myinternet = {
  125. { "Chrome", "google-chrome", "/usr/share/icons/Faenza/apps/96/google-chrome.png"},
  126. { "Chrome Private", "google-chrome -incognito", "/usr/share/icons/Faenza/apps/96/google-chrome.png"},
  127. { "Postler", "postler", "/usr/share/icons/Faenza/apps/96/evolution.png"},
  128. { "Transmission", "transmission-gtk", "/usr/share/icons/Faenza/apps/96/transmission.png"},
  129. { "Pidgin", "pidgin", "/usr/share/icons/hicolor/48x48/apps/pidgin.png"},
  130. { "TeamViewer", "teamviewer7", "/home/boswbr25/builds/teamviewer/pkg/opt/teamviewer/teamviewer/7/desktop/teamviewer.png" }
  131. }
  132.  
  133. myoffice = {
  134. { "AbiWord", "abiword", "/usr/share/icons/Faenza/mimetypes/96/application-msword.png"},
  135. { "Gnumeric", "gnumeric", "/usr/share/icons/Faenza/mimetypes/96/application-vnd.ms-excel.png"},
  136. { "ePDFViewer", "epdfviewer", "/usr/share/icons/Faenza/mimetypes/96/application-pdf.png" }
  137. }
  138.  
  139. mymultimedia = {
  140. { "Spotify", "spotify", "/usr/share/icons/Faenza/apps/96/spotify.png" },
  141. { "Goggles MM", "gogglesmm", "/usr/share/icons/Faenza/apps/96/rhythmbox.png"},
  142. { "VLC", "vlc", "/usr/share/icons/Faenza/apps/96/vlc.png" },
  143. { "Xfburn", "xfburn", "/usr/share/icons/Faenza/apps/96/xfburn.png" }
  144. }
  145.  
  146. mygraphics = {
  147. { "Gimp", "gimp", "/usr/share/icons/hicolor/256x256/apps/gimp.png" }
  148. }
  149.  
  150. mygames = {
  151. { "Djl", "djl", "/usr/share/icons/Faenza/categories/96/applications-games.png" }
  152. }
  153.  
  154.  
  155. mymainmenu = awful.menu.new({ items = {
  156. { "awesome", myawesomemenu, beautiful.awesome_icon },
  157. { "System", mysystem, "/home/boswbr25/gimp/awesome-icon2.png" },
  158. { "Internet", myinternet, beautiful.awesome_icon },
  159. { "Office", myoffice, "/home/boswbr25/gimp/awesome-icon2.png" },
  160. { "Multimedia", mymultimedia, beautiful.awesome_icon },
  161. { "Graphics", mygraphics, "/home/boswbr25/gimp/awesome-icon2.png" },
  162. { "Games", mygames, beautiful.awesome_icon }
  163. }
  164. })
  165.  
  166. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  167. menu = mymainmenu })
  168. -- }}}
  169.  
  170. -- {{{ Wibox
  171. -- Pacman Widget
  172. pacwidget = widget({type="textbox"})
  173. vicious.register(pacwidget, vicious.widgets.pkg, "<span color='tan'><b> UPDATES: </b></span> $1 ", 1801, "Arch" )
  174. -- Initialize widget
  175. cpuwidget = awful.widget.graph()
  176. -- Graph properties
  177. cpuwidget:set_width(50)
  178. cpuwidget:set_background_color("#494B4F")
  179. cpuwidget:set_color("#FF5656")
  180. cpuwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
  181. -- Register widget
  182. vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
  183. -- Create a textclock widget
  184. mytextclock = awful.widget.textclock({ align = "right" })
  185.  
  186. -- Create a systray
  187. mysystray = widget({ type = "systray" })
  188.  
  189. -- Create a wibox for each screen and add it
  190. mywibox = {}
  191. mypromptbox = {}
  192. mylayoutbox = {}
  193. mytaglist = {}
  194. mytaglist.buttons = awful.util.table.join(
  195. awful.button({ }, 1, awful.tag.viewonly),
  196. awful.button({ modkey }, 1, awful.client.movetotag),
  197. awful.button({ }, 3, awful.tag.viewtoggle),
  198. awful.button({ modkey }, 3, awful.client.toggletag),
  199. awful.button({ }, 4, awful.tag.viewnext),
  200. awful.button({ }, 5, awful.tag.viewprev)
  201. )
  202. mytasklist = {}
  203. mytasklist.buttons = awful.util.table.join(
  204. awful.button({ }, 1, function (c)
  205. if c == client.focus then
  206. c.minimized = true
  207. else
  208. if not c:isvisible() then
  209. awful.tag.viewonly(c:tags()[1])
  210. end
  211. -- This will also un-minimize
  212. -- the client, if needed
  213. client.focus = c
  214. c:raise()
  215. end
  216. end),
  217. awful.button({ }, 3, function ()
  218. if instance then
  219. instance:hide()
  220. instance = nil
  221. else
  222. instance = awful.menu.clients({ width=250 })
  223. end
  224. end),
  225. awful.button({ }, 4, function ()
  226. awful.client.focus.byidx(1)
  227. if client.focus then client.focus:raise() end
  228. end),
  229. awful.button({ }, 5, function ()
  230. awful.client.focus.byidx(-1)
  231. if client.focus then client.focus:raise() end
  232. end))
  233.  
  234. for s = 1, screen.count() do
  235. -- Create a promptbox for each screen
  236. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  237. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  238. -- We need one layoutbox per screen.
  239. mylayoutbox[s] = awful.widget.layoutbox(s)
  240. mylayoutbox[s]:buttons(awful.util.table.join(
  241. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  242. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  243. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  244. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  245. -- Create a taglist widget
  246. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  247.  
  248. -- Create a tasklist widget
  249. mytasklist[s] = awful.widget.tasklist(function(c)
  250. return awful.widget.tasklist.label.currenttags(c, s)
  251. end, mytasklist.buttons)
  252.  
  253. -- Create the wibox
  254. mywibox[s] = awful.wibox({ position = "top", screen = s })
  255. -- Add widgets to the wibox - order matters
  256. mywibox[s].widgets = {
  257. {
  258. mylauncher,
  259. mytaglist[s],
  260. mypromptbox[s],
  261. layout = awful.widget.layout.horizontal.leftright
  262. },
  263. mylayoutbox[s],
  264. mytextclock,
  265. s == 1 and mysystray or nil,
  266. pacwidget,
  267. cpuwidget.widget,
  268. mytasklist[s],
  269. layout = awful.widget.layout.horizontal.rightleft
  270. }
  271. end
  272. -- }}}
  273.  
  274. -- {{{ Mouse bindings
  275. root.buttons(awful.util.table.join(
  276. awful.button({ }, 3, function () mymainmenu:toggle() end),
  277. awful.button({ }, 4, awful.tag.viewnext),
  278. awful.button({ }, 5, awful.tag.viewprev)
  279. ))
  280. -- }}}
  281.  
  282. -- {{{ Key bindings
  283. globalkeys = awful.util.table.join(
  284. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  285. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  286. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  287. awful.key({modkey }, "e", revelation),
  288.  
  289. awful.key({ modkey, }, "j",
  290. function ()
  291. awful.client.focus.byidx( 1)
  292. if client.focus then client.focus:raise() end
  293. end),
  294. awful.key({ modkey, }, "k",
  295. function ()
  296. awful.client.focus.byidx(-1)
  297. if client.focus then client.focus:raise() end
  298. end),
  299. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  300.  
  301. -- Layout manipulation
  302. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  303. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  304. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  305. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  306. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  307. awful.key({ modkey, }, "Tab",
  308. function ()
  309. awful.client.focus.history.previous()
  310. if client.focus then
  311. client.focus:raise()
  312. end
  313. end),
  314.  
  315. -- Standard program
  316. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  317. awful.key({ }, "Print", function () awful.util.spawn("scrot -e 'mv $f ~/screenshots/ 2>/dev/null'") end),
  318. awful.key({ modkey, "Control" }, "r", awesome.restart),
  319. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  320.  
  321. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  322. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  323. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  324. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  325. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  326. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  327. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  328. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  329.  
  330. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  331.  
  332. -- Prompt
  333. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  334.  
  335. awful.key({ modkey }, "x",
  336. function ()
  337. awful.prompt.run({ prompt = "Run Lua code: " },
  338. mypromptbox[mouse.screen].widget,
  339. awful.util.eval, nil,
  340. awful.util.getdir("cache") .. "/history_eval")
  341. end)
  342. )
  343.  
  344. clientkeys = awful.util.table.join(
  345. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  346. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  347. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  348. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  349. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  350. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  351. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  352. awful.key({ modkey, }, "n",
  353. function (c)
  354. -- The client currently has the input focus, so it cannot be
  355. -- minimized, since minimized clients can't have the focus.
  356. c.minimized = true
  357. end),
  358. awful.key({ modkey, }, "m",
  359. function (c)
  360. c.maximized_horizontal = not c.maximized_horizontal
  361. c.maximized_vertical = not c.maximized_vertical
  362. end)
  363. )
  364.  
  365. -- Compute the maximum number of digit we need, limited to 9
  366. keynumber = 0
  367. for s = 1, screen.count() do
  368. keynumber = math.min(9, math.max(#tags[s], keynumber));
  369. end
  370.  
  371. -- Bind all key numbers to tags.
  372. -- Be careful: we use keycodes to make it works on any keyboard layout.
  373. -- This should map on the top row of your keyboard, usually 1 to 9.
  374. for i = 1, keynumber do
  375. globalkeys = awful.util.table.join(globalkeys,
  376. awful.key({ modkey }, "#" .. i + 9,
  377. function ()
  378. local screen = mouse.screen
  379. if tags[screen][i] then
  380. awful.tag.viewonly(tags[screen][i])
  381. end
  382. end),
  383. awful.key({ modkey, "Control" }, "#" .. i + 9,
  384. function ()
  385. local screen = mouse.screen
  386. if tags[screen][i] then
  387. awful.tag.viewtoggle(tags[screen][i])
  388. end
  389. end),
  390. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  391. function ()
  392. if client.focus and tags[client.focus.screen][i] then
  393. awful.client.movetotag(tags[client.focus.screen][i])
  394. end
  395. end),
  396. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  397. function ()
  398. if client.focus and tags[client.focus.screen][i] then
  399. awful.client.toggletag(tags[client.focus.screen][i])
  400. end
  401. end))
  402. end
  403.  
  404. clientbuttons = awful.util.table.join(
  405. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  406. awful.button({ modkey }, 1, awful.mouse.client.move),
  407. awful.button({ modkey }, 3, awful.mouse.client.resize))
  408.  
  409. -- Set keys
  410. root.keys(globalkeys)
  411. -- }}}
  412.  
  413. -- {{{ Rules
  414. awful.rules.rules = {
  415. -- All clients will match this rule.
  416. { rule = { },
  417. properties = { border_width = beautiful.border_width,
  418. border_color = beautiful.border_normal,
  419. focus = true,
  420. keys = clientkeys,
  421. buttons = clientbuttons } },
  422. { rule = { class = "MPlayer" },
  423. properties = { floating = true } },
  424. { rule = { class = "pinentry" },
  425. properties = { floating = true } },
  426. { rule = { instance = "plugin-container" },
  427. properties = { floating = true } },
  428.  
  429. -- Set Google Chrome to always map on tags number 3 of screen 1.
  430. { rule = { class = "Google-chrome" },
  431. properties = { tag = tags[1][1] } },
  432. { rule = { class = "Postler" },
  433. properties = { tag = tags[1][3] } },
  434. }
  435. -- }}}
  436.  
  437. -- {{{ Signals
  438. -- Signal function to execute when a new client appears.
  439. client.add_signal("manage", function (c, startup)
  440. -- Add a titlebar
  441. -- awful.titlebar.add(c, { modkey = modkey })
  442.  
  443. -- Enable sloppy focus
  444. c:add_signal("mouse::enter", function(c)
  445. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  446. and awful.client.focus.filter(c) then
  447. client.focus = c
  448. end
  449. end)
  450.  
  451. if not startup then
  452. -- Set the windows at the slave,
  453. -- i.e. put it at the end of others instead of setting it master.
  454. -- awful.client.setslave(c)
  455.  
  456. -- Put windows in a smart way, only if they does not set an initial position.
  457. if not c.size_hints.user_position and not c.size_hints.program_position then
  458. awful.placement.no_overlap(c)
  459. awful.placement.no_offscreen(c)
  460. end
  461. end
  462. end)
  463.  
  464. -- Transparency
  465. client.add_signal("focus", function(c)
  466. c.border_color = beautiful.border_focus
  467. c.opacity = 1
  468. end)
  469. client.add_signal("unfocus", function(c)
  470. c.border_color = beautiful.border_normal
  471. c.opacity = 0.5
  472. end)
  473.  
  474. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement