Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.50 KB | None | 0 0
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. awful.rules = require("awful.rules")
  5. require("awful.autofocus")
  6. -- Widget and layout library
  7. local wibox = require("wibox")
  8. -- Theme handling library
  9. local beautiful = require("beautiful")
  10. -- Notification library
  11. local naughty = require("naughty")
  12. local menubar = require("menubar")
  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.connect_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/caboose/.config/awesome/theme.lua")
  42.  
  43. -- This is used later as the default terminal and editor to run.
  44. terminal = "urxvt"
  45. --i3lock = "i3lock -i /home/caboose/lock1.png"
  46. editor = os.getenv("EDITOR") or "nano"
  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. local 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. -- {{{ Wallpaper
  75. if beautiful.wallpaper then
  76. for s = 1, screen.count() do
  77. gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  78. end
  79. end
  80. -- }}}
  81.  
  82. -- {{{ Tags
  83. -- Define a tag table which hold all screen tags.
  84. tags = {
  85. names = { "一", "二", "三", "四", "五", "六", "七", "八", "九"},
  86. layout = { layouts[2], layouts[2], layouts[2], layouts[2], layouts[2], layouts[2], layouts[2], layouts[2], layouts[2]}
  87. }
  88. for s = 1, screen.count() do
  89. tags[s] = awful.tag(tags.names, s, tags.layout)
  90. end
  91. --tags = {}
  92. --for s = 1, screen.count() do
  93. -- Each screen has its own tag table.
  94. -- tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, }, s, layouts[2])
  95. --end
  96. -- }}}
  97.  
  98. -- {{{ Menu
  99. -- Create a laucher widget and a main menu
  100. --myawesomemenu = {
  101. -- { "manual", terminal .. " -e man awesome" },
  102. -- { "edit config", editor_cmd .. " " .. awesome.conffile },
  103. -- { "restart", awesome.restart },
  104. -- { "quit", awesome.quit }
  105. --}
  106. --
  107. --mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, --beautiful.awesome_icon },
  108. -- { "open terminal", terminal }
  109. -- }
  110. -- })
  111. --
  112. --mylauncher = awful.widget.launcher({ image =
  113. --beautiful.awesome_icon,
  114. -- menu = mymainmenu })
  115. --
  116. --
  117. -- Menubar configuration
  118. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  119. -- }}}
  120. -- {{{ Wibox
  121. -- Create a textclock widget
  122. mytextclock = awful.widget.textclock()
  123.  
  124.  
  125. -- Create a wibox for each screen and add it
  126. mywibox = {}
  127. mypromptbox = {}
  128. mylayoutbox = {}
  129. mytaglist = {}
  130. mytaglist.buttons = awful.util.table.join(
  131. awful.button({ }, 1, awful.tag.viewonly),
  132. awful.button({ modkey }, 1, awful.client.movetotag),
  133. awful.button({ }, 3, awful.tag.viewtoggle),
  134. awful.button({ modkey }, 3, awful.client.toggletag),
  135. awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  136. awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  137. )
  138. mytasklist = {}
  139. mytasklist.buttons = awful.util.table.join(
  140. awful.button({ }, 1, function (c)
  141. if c == client.focus then
  142. c.minimized = true
  143. else
  144. -- Without this, the following
  145. -- :isvisible() makes no sense
  146. c.minimized = false
  147. if not c:isvisible() then
  148. awful.tag.viewonly(c:tags()[1])
  149. end
  150. -- This will also un-minimize
  151. -- the client, if needed
  152. client.focus = c
  153. c:raise()
  154. end
  155. end),
  156. awful.button({ }, 3, function ()
  157. if instance then
  158. instance:hide()
  159. instance = nil
  160. else
  161. instance = awful.menu.clients({ width=250 })
  162. end
  163. end),
  164. awful.button({ }, 4, function ()
  165. awful.client.focus.byidx(1)
  166. if client.focus then client.focus:raise() end
  167. end),
  168. awful.button({ }, 5, function ()
  169. awful.client.focus.byidx(-1)
  170. if client.focus then client.focus:raise() end
  171. end))
  172.  
  173. for s = 1, screen.count() do
  174. -- Create a promptbox for each screen
  175. mypromptbox[s] = awful.widget.prompt()
  176. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  177. -- We need one layoutbox per screen.
  178. mylayoutbox[s] = awful.widget.layoutbox(s)
  179. mylayoutbox[s]:buttons(awful.util.table.join(
  180. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  181. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  182. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  183. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  184. -- Create a taglist widget
  185. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  186.  
  187. -- Create a tasklist widget
  188. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  189.  
  190. -- Create the wibox
  191. mywibox[s] = awful.wibox({ position = "top", screen = s })
  192.  
  193. -- Widgets that are aligned to the left
  194. local left_layout = wibox.layout.fixed.horizontal()
  195. --left_layout:add(mylauncher)
  196. left_layout:add(mytaglist[s])
  197. left_layout:add(mypromptbox[s])
  198.  
  199. -- Widgets that are aligned to the right
  200. local right_layout = wibox.layout.fixed.horizontal()
  201. if s == 1 then right_layout:add(wibox.widget.systray()) end
  202. right_layout:add(mytextclock)
  203. --right_layout:add(mylayoutbox[s])
  204.  
  205. -- Now bring it all together (with the tasklist in the middle)
  206. local layout = wibox.layout.align.horizontal()
  207. layout:set_left(left_layout)
  208. layout:set_middle(mytasklist[s])
  209. layout:set_right(right_layout)
  210.  
  211. mywibox[s]:set_widget(layout)
  212. end
  213. -- }}}
  214.  
  215. -- {{{ Mouse bindings
  216. root.buttons(awful.util.table.join(
  217. awful.button({ }, 3, function () mymainmenu:toggle() end),
  218. awful.button({ }, 4, awful.tag.viewnext),
  219. awful.button({ }, 5, awful.tag.viewprev)
  220. ))
  221. -- }}}
  222.  
  223. -- {{{ Key bindings
  224. globalkeys = awful.util.table.join(
  225. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  226. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  227. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  228.  
  229. awful.key({ modkey, }, "j",
  230. function ()
  231. awful.client.focus.byidx( 1)
  232. if client.focus then client.focus:raise() end
  233. end),
  234. awful.key({ modkey, }, "k",
  235. function ()
  236. awful.client.focus.byidx(-1)
  237. if client.focus then client.focus:raise() end
  238. end),
  239. awful.key({ modkey, }, "w", function () mymainmenu:show() end),
  240.  
  241. -- Layout manipulation
  242. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  243. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  244. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  245. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  246. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  247. awful.key({ modkey, }, "Tab",
  248. function ()
  249. awful.client.focus.history.previous()
  250. if client.focus then
  251. client.focus:raise()
  252. end
  253. end),
  254.  
  255. -- Standard program
  256. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  257. awful.key({ modkey, "Control" }, "r", awesome.restart),
  258. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  259.  
  260. --awful.key({ modkey, }, "l", function () awful.util.spawn(i3lock) end),
  261. awful.key({ modkey, }, "l", function () awful.util.spawn_with_shell("i3lock -i /home/caboose/lock1.png") end),
  262. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  263. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  264. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  265. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  266. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  267. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  268. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  269.  
  270. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  271.  
  272. -- Prompt
  273. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  274.  
  275. awful.key({ modkey }, "x",
  276. function ()
  277. awful.prompt.run({ prompt = "Run Lua code: " },
  278. mypromptbox[mouse.screen].widget,
  279. awful.util.eval, nil,
  280. awful.util.getdir("cache") .. "/history_eval")
  281. end),
  282. -- Menubar
  283. awful.key({ modkey }, "p", function() menubar.show() end)
  284. )
  285.  
  286. clientkeys = awful.util.table.join(
  287. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  288. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  289. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  290. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  291. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  292. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  293. awful.key({ modkey, }, "n",
  294. function (c)
  295. -- The client currently has the input focus, so it cannot be
  296. -- minimized, since minimized clients can't have the focus.
  297. c.minimized = true
  298. end),
  299. awful.key({ modkey, }, "m",
  300. function (c)
  301. c.maximized_horizontal = not c.maximized_horizontal
  302. c.maximized_vertical = not c.maximized_vertical
  303. end)
  304. )
  305.  
  306. -- Bind all key numbers to tags.
  307. -- Be careful: we use keycodes to make it works on any keyboard layout.
  308. -- This should map on the top row of your keyboard, usually 1 to 9.
  309. for i = 1, 9 do
  310. globalkeys = awful.util.table.join(globalkeys,
  311. awful.key({ modkey }, "#" .. i + 9,
  312. function ()
  313. local screen = mouse.screen
  314. local tag = awful.tag.gettags(screen)[i]
  315. if tag then
  316. awful.tag.viewonly(tag)
  317. end
  318. end),
  319. awful.key({ modkey, "Control" }, "#" .. i + 9,
  320. function ()
  321. local screen = mouse.screen
  322. local tag = awful.tag.gettags(screen)[i]
  323. if tag then
  324. awful.tag.viewtoggle(tag)
  325. end
  326. end),
  327. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  328. function ()
  329. if client.focus then
  330. local tag = awful.tag.gettags(client.focus.screen)[i]
  331. if tag then
  332. awful.client.movetotag(tag)
  333. end
  334. end
  335. end),
  336. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  337. function ()
  338. if client.focus then
  339. local tag = awful.tag.gettags(client.focus.screen)[i]
  340. if tag then
  341. awful.client.toggletag(tag)
  342. end
  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 = awful.client.focus.filter,
  363. keys = clientkeys,
  364. size_hints_honor=false,
  365. buttons = clientbuttons } },
  366. { rule = { class = "MPlayer" },
  367. properties = { floating = true } },
  368. { rule = { class = "pinentry" },
  369. properties = { floating = true } },
  370. { rule = { class = "gimp" },
  371. properties = { floating = true } },
  372. -- Set Firefox to always map on tags number 2 of screen 1.
  373. -- { rule = { class = "Firefox" },
  374. -- properties = { tag = tags[1][2] } },
  375. }
  376. -- }}}
  377.  
  378. -- {{{ Signals
  379. -- Signal function to execute when a new client appears.
  380. client.connect_signal("manage", function (c, startup)
  381. -- Enable sloppy focus
  382. c:connect_signal("mouse::enter", function(c)
  383. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  384. and awful.client.focus.filter(c) then
  385. client.focus = c
  386. end
  387. end)
  388.  
  389. if not startup then
  390. -- Set the windows at the slave,
  391. -- i.e. put it at the end of others instead of setting it master.
  392. -- awful.client.setslave(c)
  393.  
  394. -- Put windows in a smart way, only if they does not set an initial position.
  395. if not c.size_hints.user_position and not c.size_hints.program_position then
  396. awful.placement.no_overlap(c)
  397. awful.placement.no_offscreen(c)
  398. end
  399. end
  400.  
  401. local titlebars_enabled = false
  402. if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  403. -- buttons for the titlebar
  404. local buttons = awful.util.table.join(
  405. awful.button({ }, 1, function()
  406. client.focus = c
  407. c:raise()
  408. awful.mouse.client.move(c)
  409. end),
  410. awful.button({ }, 3, function()
  411. client.focus = c
  412. c:raise()
  413. awful.mouse.client.resize(c)
  414. end)
  415. )
  416.  
  417. -- Widgets that are aligned to the left
  418. local left_layout = wibox.layout.fixed.horizontal()
  419. left_layout:add(awful.titlebar.widget.iconwidget(c))
  420. left_layout:buttons(buttons)
  421.  
  422. -- Widgets that are aligned to the right
  423. local right_layout = wibox.layout.fixed.horizontal()
  424. right_layout:add(awful.titlebar.widget.floatingbutton(c))
  425. right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  426. right_layout:add(awful.titlebar.widget.stickybutton(c))
  427. right_layout:add(awful.titlebar.widget.ontopbutton(c))
  428. right_layout:add(awful.titlebar.widget.closebutton(c))
  429.  
  430. -- The title goes in the middle
  431. local middle_layout = wibox.layout.flex.horizontal()
  432. local title = awful.titlebar.widget.titlewidget(c)
  433. title:set_align("center")
  434. middle_layout:add(title)
  435. middle_layout:buttons(buttons)
  436.  
  437. -- Now bring it all together
  438. local layout = wibox.layout.align.horizontal()
  439. layout:set_left(left_layout)
  440. layout:set_right(right_layout)
  441. layout:set_middle(middle_layout)
  442.  
  443. awful.titlebar(c):set_widget(layout)
  444. end
  445. end)
  446.  
  447. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  448. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  449. -- }}}
  450. awful.util.spawn_with_shell("sh ~/.fehbg &")
  451. awful.util.spawn_with_shell("mpd")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement