Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.64 KB | None | 0 0
  1.  
  2.  
  3. -- Standard awesome library
  4. local gears = require("gears")
  5. local awful = require("awful")
  6. awful.rules = require("awful.rules")
  7. require("awful.autofocus")
  8. -- Widget and layout library
  9. local wibox = require("wibox")
  10. -- Theme handling library
  11. local beautiful = require("beautiful")
  12. -- Notification library
  13. local naughty = require("naughty")
  14. local menubar = require("menubar")
  15.  
  16. -- {{{ Error handling
  17. -- Check if awesome encountered an error during startup and fell back to
  18. -- another config (This code will only ever execute for the fallback config)
  19. if awesome.startup_errors then
  20. naughty.notify({ preset = naughty.config.presets.critical,
  21. title = "Oops, there were errors during startup!",
  22. text = awesome.startup_errors })
  23. end
  24.  
  25. -- Handle runtime errors after startup
  26. do
  27. local in_error = false
  28. awesome.connect_signal("debug::error", function (err)
  29. -- Make sure we don't go into an endless error loop
  30. if in_error then return end
  31. in_error = true
  32.  
  33. naughty.notify({ preset = naughty.config.presets.critical,
  34. title = "Oops, an error happened!",
  35. text = err })
  36. in_error = false
  37. end)
  38. end
  39. -- }}}
  40.  
  41. -- {{{ Variable definitions
  42. -- Themes define colours, icons, font and wallpapers.
  43. beautiful.init("/home/jap/.config/awesome/themes/wabbit/theme.lua")
  44.  
  45. -- This is used later as the default terminal and editor to run.
  46. terminal = "urxvt"
  47. editor = os.getenv("EDITOR") or "nano"
  48. editor_cmd = terminal .. " -e " .. editor
  49. vlc = "vlc"
  50. spacefm = "spacefm"
  51. seamonkey = "seamonkey"
  52. cmus = terminal .. " -e cmus"
  53. mc = terminal .. " -e mc"
  54.  
  55. -- Default modkey.
  56. -- Usually, Mod4 is the key with a logo between Control and Alt.
  57. -- If you do not like this or do not have such a key,
  58. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  59. -- However, you can use another modifier like Mod1, but it may interact with others.
  60. modkey = "Mod4"
  61.  
  62. -- Table of layouts to cover with awful.layout.inc, order matters.
  63. local layouts =
  64. {
  65. awful.layout.suit.floating,
  66. awful.layout.suit.tile,
  67. awful.layout.suit.tile.left,
  68. awful.layout.suit.tile.bottom,
  69. awful.layout.suit.tile.top,
  70. awful.layout.suit.fair,
  71. awful.layout.suit.fair.horizontal,
  72. awful.layout.suit.spiral,
  73. awful.layout.suit.spiral.dwindle,
  74. awful.layout.suit.max,
  75. awful.layout.suit.max.fullscreen,
  76. awful.layout.suit.magnifier
  77. }
  78. -- }}}
  79.  
  80. -- {{{ Wallpaper
  81. if beautiful.wallpaper then
  82. for s = 1, screen.count() do
  83. gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  84. end
  85. end
  86. -- }}}
  87.  
  88. -- {{{ Tags
  89. -- Define a tag table which hold all screen tags.
  90. tags = {
  91. names = { "main", "www", "A/V", "open", "open", "open", "open", "open" },
  92. layout = { layouts[2], layouts[3], layouts[3], layouts[1], layouts[1], layouts[1], layouts[1], layouts[1]
  93. }}
  94. for s = 1, screen.count() do
  95. -- Each screen has its own tag table.
  96. tags[s] = awful.tag(tags.names, s, tags.layout)
  97. end
  98. -- }}}
  99.  
  100. -- {{{ Menu
  101. -- Create a laucher widget and a main menu
  102. myawesomemenu = {
  103. { "manual", terminal .. " -e man awesome" },
  104. { "edit config", editor_cmd .. " " .. awesome.conffile },
  105. { "restart", awesome.restart },
  106. { "quit", awesome.quit }
  107. }
  108.  
  109. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  110. { "open terminal", terminal },
  111. { "vlc", vlc },
  112. { "spacefm", spacefm },
  113. { seamonkey, seamonkey }
  114. }
  115. })
  116.  
  117. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  118. menu = mymainmenu })
  119.  
  120. -- Menubar configuration
  121. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  122. -- }}}
  123.  
  124. -- {{{ Wibox
  125. -- Create a textclock widget
  126. mytextclock = awful.widget.textclock()
  127.  
  128. -- Create a wibox for each screen and add it
  129. mywibox = {}
  130. mypromptbox = {}
  131. mylayoutbox = {}
  132. mytaglist = {}
  133. mytaglist.buttons = awful.util.table.join(
  134. awful.button({ }, 1, awful.tag.viewonly),
  135. awful.button({ modkey }, 1, awful.client.movetotag),
  136. awful.button({ }, 3, awful.tag.viewtoggle),
  137. awful.button({ modkey }, 3, awful.client.toggletag),
  138. awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  139. awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  140. )
  141. mytasklist = {}
  142. mytasklist.buttons = awful.util.table.join(
  143. awful.button({ }, 1, function (c)
  144. if c == client.focus then
  145. c.minimized = true
  146. else
  147. -- Without this, the following
  148. -- :isvisible() makes no sense
  149. c.minimized = false
  150. if not c:isvisible() then
  151. awful.tag.viewonly(c:tags()[1])
  152. end
  153. -- This will also un-minimize
  154. -- the client, if needed
  155. client.focus = c
  156. c:raise()
  157. end
  158. end),
  159. awful.button({ }, 3, function ()
  160. if instance then
  161. instance:hide()
  162. instance = nil
  163. else
  164. instance = awful.menu.clients({
  165. theme = { width = 250 }
  166. })
  167. end
  168. end),
  169. awful.button({ }, 4, function ()
  170. awful.client.focus.byidx(1)
  171. if client.focus then client.focus:raise() end
  172. end),
  173. awful.button({ }, 5, function ()
  174. awful.client.focus.byidx(-1)
  175. if client.focus then client.focus:raise() end
  176. end))
  177.  
  178. for s = 1, screen.count() do
  179. -- Create a promptbox for each screen
  180. mypromptbox[s] = awful.widget.prompt()
  181. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  182. -- We need one layoutbox per screen.
  183. mylayoutbox[s] = awful.widget.layoutbox(s)
  184. mylayoutbox[s]:buttons(awful.util.table.join(
  185. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  186. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  187. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  188. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  189. -- Create a taglist widget
  190. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  191.  
  192. -- Create a tasklist widget
  193. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  194.  
  195. -- Create the wibox
  196. mywibox[s] = awful.wibox({ position = "top", screen = s })
  197.  
  198. -- Widgets that are aligned to the left
  199. local left_layout = wibox.layout.fixed.horizontal()
  200. left_layout:add(mylauncher)
  201. left_layout:add(mytaglist[s])
  202. left_layout:add(mypromptbox[s])
  203.  
  204. -- Widgets that are aligned to the right
  205. local right_layout = wibox.layout.fixed.horizontal()
  206. if s == 1 then right_layout:add(wibox.widget.systray()) end
  207. right_layout:add(mytextclock)
  208. right_layout:add(mylayoutbox[s])
  209.  
  210. -- Now bring it all together (with the tasklist in the middle)
  211. local layout = wibox.layout.align.horizontal()
  212. layout:set_left(left_layout)
  213. layout:set_middle(mytasklist[s])
  214. layout:set_right(right_layout)
  215.  
  216. mywibox[s]:set_widget(layout)
  217. end
  218. -- }}}
  219.  
  220. -- {{{ Mouse bindings
  221. root.buttons(awful.util.table.join(
  222. awful.button({ }, 3, function () mymainmenu:toggle() end),
  223. awful.button({ }, 4, awful.tag.viewnext),
  224. awful.button({ }, 5, awful.tag.viewprev)
  225. ))
  226. -- }}}
  227.  
  228. -- {{{ Key bindings
  229. globalkeys = awful.util.table.join(
  230. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  231. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  232. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  233.  
  234. awful.key({ modkey, }, "j",
  235. function ()
  236. awful.client.focus.byidx( 1)
  237. if client.focus then client.focus:raise() end
  238. end),
  239. awful.key({ modkey, }, "k",
  240. function ()
  241. awful.client.focus.byidx(-1)
  242. if client.focus then client.focus:raise() end
  243. end),
  244. awful.key({ modkey, }, "w", function () mymainmenu:show() end),
  245.  
  246. -- Layout manipulation
  247. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  248. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  249. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  250. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  251. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  252. awful.key({ modkey, }, "Tab",
  253. function ()
  254. awful.client.focus.history.previous()
  255. if client.focus then
  256. client.focus:raise()
  257. end
  258. end),
  259.  
  260. -- Standard program
  261. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  262. awful.key({ modkey, "Control" }, "r", awesome.restart),
  263. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  264.  
  265. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  266. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  267. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  268. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  269. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  270. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  271. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  272. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  273.  
  274. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  275.  
  276. -- Prompt
  277. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  278.  
  279. awful.key({ modkey }, "x",
  280. function ()
  281. awful.prompt.run({ prompt = "Run Lua code: " },
  282. mypromptbox[mouse.screen].widget,
  283. awful.util.eval, nil,
  284. awful.util.getdir("cache") .. "/history_eval")
  285. end),
  286. -- Menubar
  287. awful.key({ modkey }, "p", function() menubar.show() end)
  288. ,
  289. awful.key({ }, "Print", function() awful.util.spawn_with_shell("imlib2_grab ~/screenshot/$(date '+%Y%m%d-%H%M%S').png") end)
  290. ,
  291. awful.key({ }, "#232", function() awful.util.spawn_with_shell("xbacklight -dec 10") end)
  292. ,
  293. awful.key({ }, "#233", function() awful.util.spawn_with_shell("xbacklight -inc 10") end)
  294. ,
  295. awful.key({ }, "#122", function() awful.util.spawn_with_shell("pactl set-sink-mute 0 false ; pactl set-sink-volume 0 -5%") end)
  296. ,
  297. awful.key({ }, "#123", function() awful.util.spawn_with_shell("pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%") end)
  298. ,
  299. awful.key({ modkey, "Shift", "Control" }, "h", function() awful.util.spawn(cmus) end)
  300. ,
  301. awful.key({ modkey, "Shift", "Control" }, "j", function() awful.util.spawn(mc) end)
  302. ,
  303. awful.key({ modkey, "Shift", "Control" }, "k", function() awful.util.spawn(seamonkey) end)
  304. ,
  305. awful.key({ modkey, "Shift", "Control" }, "l", function() awful.util.spawn(vlc) end)
  306. )
  307.  
  308. clientkeys = awful.util.table.join(
  309. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  310. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  311. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  312. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  313. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  314. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  315. awful.key({ modkey, }, "n",
  316. function (c)
  317. -- The client currently has the input focus, so it cannot be
  318. -- minimized, since minimized clients can't have the focus.
  319. c.minimized = true
  320. end),
  321. awful.key({ modkey, }, "m",
  322. function (c)
  323. c.maximized_horizontal = not c.maximized_horizontal
  324. c.maximized_vertical = not c.maximized_vertical
  325. end)
  326. )
  327.  
  328. -- Bind all key numbers to tags.
  329. -- Be careful: we use keycodes to make it works on any keyboard layout.
  330. -- This should map on the top row of your keyboard, usually 1 to 9.
  331. for i = 1, 9 do
  332. globalkeys = awful.util.table.join(globalkeys,
  333. -- View tag only.
  334. awful.key({ modkey }, "#" .. i + 9,
  335. function ()
  336. local screen = mouse.screen
  337. local tag = awful.tag.gettags(screen)[i]
  338. if tag then
  339. awful.tag.viewonly(tag)
  340. end
  341. end),
  342. -- Toggle tag.
  343. awful.key({ modkey, "Control" }, "#" .. i + 9,
  344. function ()
  345. local screen = mouse.screen
  346. local tag = awful.tag.gettags(screen)[i]
  347. if tag then
  348. awful.tag.viewtoggle(tag)
  349. end
  350. end),
  351. -- Move client to tag.
  352. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  353. function ()
  354. if client.focus then
  355. local tag = awful.tag.gettags(client.focus.screen)[i]
  356. if tag then
  357. awful.client.movetotag(tag)
  358. end
  359. end
  360. end),
  361. -- Toggle tag.
  362. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  363. function ()
  364. if client.focus then
  365. local tag = awful.tag.gettags(client.focus.screen)[i]
  366. if tag then
  367. awful.client.toggletag(tag)
  368. end
  369. end
  370. end))
  371. end
  372.  
  373. clientbuttons = awful.util.table.join(
  374. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  375. awful.button({ modkey }, 1, awful.mouse.client.move),
  376. awful.button({ modkey }, 3, awful.mouse.client.resize))
  377.  
  378. -- Set keys
  379. root.keys(globalkeys)
  380. -- }}}
  381.  
  382. -- {{{ Rules
  383. -- Rules to apply to new clients (through the "manage" signal).
  384. awful.rules.rules = {
  385. -- All clients will match this rule.
  386. { rule = { },
  387. properties = { border_width = beautiful.border_width,
  388. border_color = beautiful.border_normal,
  389. focus = awful.client.focus.filter,
  390. raise = true,
  391. keys = clientkeys,
  392. buttons = clientbuttons } },
  393. { rule = { class = "Vlc" },
  394. properties = { tag = tags[1][3] } },
  395. { rule = { class = "Seamonkey" },
  396. properties = { tag = tags[1][2] } },
  397. { rule = { class = "Urxvt" },
  398. properties = { floating = true }
  399. ,
  400. maximized_horizontal = true
  401. ,
  402. maximized_vertical = true
  403. },
  404. { rule = { class = "Spacefm" },
  405. properties = { floating = true } },
  406. }
  407. -- }}}
  408.  
  409. -- {{{ Signals
  410. -- Signal function to execute when a new client appears.
  411. client.connect_signal("manage", function (c, startup)
  412. -- Enable sloppy focus
  413. c:connect_signal("mouse::enter", function(c)
  414. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  415. and awful.client.focus.filter(c) then
  416. client.focus = c
  417. end
  418. end)
  419.  
  420. if not startup then
  421. -- Set the windows at the slave,
  422. -- i.e. put it at the end of others instead of setting it master.
  423. -- awful.client.setslave(c)
  424.  
  425. -- Put windows in a smart way, only if they does not set an initial position.
  426. if not c.size_hints.user_position and not c.size_hints.program_position then
  427. awful.placement.no_overlap(c)
  428. awful.placement.no_offscreen(c)
  429. end
  430. end
  431.  
  432. local titlebars_enabled = false
  433. if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  434. -- buttons for the titlebar
  435. local buttons = awful.util.table.join(
  436. awful.button({ }, 1, function()
  437. client.focus = c
  438. c:raise()
  439. awful.mouse.client.move(c)
  440. end),
  441. awful.button({ }, 3, function()
  442. client.focus = c
  443. c:raise()
  444. awful.mouse.client.resize(c)
  445. end)
  446. )
  447.  
  448. -- Widgets that are aligned to the left
  449. local left_layout = wibox.layout.fixed.horizontal()
  450. left_layout:add(awful.titlebar.widget.iconwidget(c))
  451. left_layout:buttons(buttons)
  452.  
  453. -- Widgets that are aligned to the right
  454. local right_layout = wibox.layout.fixed.horizontal()
  455. right_layout:add(awful.titlebar.widget.floatingbutton(c))
  456. right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  457. right_layout:add(awful.titlebar.widget.stickybutton(c))
  458. right_layout:add(awful.titlebar.widget.ontopbutton(c))
  459. right_layout:add(awful.titlebar.widget.closebutton(c))
  460.  
  461. -- The title goes in the middle
  462. local middle_layout = wibox.layout.flex.horizontal()
  463. local title = awful.titlebar.widget.titlewidget(c)
  464. title:set_align("center")
  465. middle_layout:add(title)
  466. middle_layout:buttons(buttons)
  467.  
  468. -- Now bring it all together
  469. local layout = wibox.layout.align.horizontal()
  470. layout:set_left(left_layout)
  471. layout:set_right(right_layout)
  472. layout:set_middle(middle_layout)
  473.  
  474. awful.titlebar(c):set_widget(layout)
  475. end
  476. end)
  477.  
  478. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  479. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  480.  
  481. --awful.tag.viewonly(main)
  482. --awful.tag.incmwfact(0.15, main)
  483. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement