Guest User

Untitled

a guest
Jun 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.17 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. -- Load Debian menu entries
  11. require("debian.menu")
  12.  
  13. -- {{{ Variable definitions
  14. -- Themes define colours, icons, and wallpapers
  15. beautiful.init("/home/ryan/.config/awesome/default/theme.lua")
  16.  
  17. -- This is used later as the default terminal and editor to run.
  18. terminal = "xterm"
  19. editor = os.getenv("EDITOR") or "editor"
  20. editor_cmd = terminal .. " -e " .. editor
  21.  
  22. -- Default modkey.
  23. -- Usually, Mod4 is the key with a logo between Control and Alt.
  24. -- If you do not like this or do not have such a key,
  25. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  26. -- However, you can use another modifier like Mod1, but it may interact with others.
  27. modkey = "Mod4"
  28.  
  29. -- Table of layouts to cover with awful.layout.inc, order matters.
  30. layouts =
  31. {
  32. awful.layout.suit.floating,
  33. awful.layout.suit.tile,
  34. awful.layout.suit.tile.left,
  35. awful.layout.suit.tile.bottom,
  36. awful.layout.suit.tile.top,
  37. awful.layout.suit.fair,
  38. awful.layout.suit.fair.horizontal,
  39. awful.layout.suit.spiral,
  40. awful.layout.suit.spiral.dwindle,
  41. awful.layout.suit.max,
  42. awful.layout.suit.max.fullscreen,
  43. awful.layout.suit.magnifier
  44. }
  45. -- }}}
  46.  
  47. -- {{{ Tags
  48. -- Define a tag table which will hold all screen tags.
  49. tags = {
  50. names = { "main", "web", "irssi", "music", "edit", "meow", "whasst", "piss", "shit", "fuck" },
  51. layout = { layouts[1], layouts[2], layouts[1], layouts[5], layouts[6],
  52. layouts[12], layouts[9], layouts[3], layouts[7]
  53. }}
  54. for s = 1, screen.count() do
  55. -- Each screen has its own tag table.
  56. tags[s] = awful.tag(tags.names, s, tags.layout)
  57. end
  58. -- }}}
  59.  
  60. -- {{{ Menu
  61. -- Create a laucher widget and a main menu
  62. myawesomemenu = {
  63. { "manual", terminal .. " -e man awesome" },
  64. { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  65. { "restart", awesome.restart },
  66. { "quit", awesome.quit }
  67. }
  68.  
  69. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  70. { "Debian", debian.menu.Debian_menu.Debian },
  71. { "open terminal", terminal }
  72. }
  73. })
  74.  
  75. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  76. menu = mymainmenu })
  77. -- }}}
  78.  
  79. -- {{{ Wibox
  80. -- Create a textclock widget
  81. mytextclock = awful.widget.textclock({ align = "right" })
  82.  
  83. -- Create a systray
  84. mysystray = widget({ type = "systray" })
  85.  
  86. -- Create a wibox for each screen and add it
  87. mywibox = {}
  88. mypromptbox = {}
  89. mylayoutbox = {}
  90. mytaglist = {}
  91. mytaglist.buttons = awful.util.table.join(
  92. awful.button({ }, 1, awful.tag.viewonly),
  93. awful.button({ modkey }, 1, awful.client.movetotag),
  94. awful.button({ }, 3, awful.tag.viewtoggle),
  95. awful.button({ modkey }, 3, awful.client.toggletag),
  96. awful.button({ }, 4, awful.tag.viewnext),
  97. awful.button({ }, 5, awful.tag.viewprev)
  98. )
  99. mytasklist = {}
  100. mytasklist.buttons = awful.util.table.join(
  101. awful.button({ }, 1, function (c)
  102. if not c:isvisible() then
  103. awful.tag.viewonly(c:tags()[1])
  104. end
  105. client.focus = c
  106. c:raise()
  107. end),
  108. awful.button({ }, 3, function ()
  109. if instance then
  110. instance:hide()
  111. instance = nil
  112. else
  113. instance = awful.menu.clients({ width=250 })
  114. end
  115. end),
  116. awful.button({ }, 4, function ()
  117. awful.client.focus.byidx(1)
  118. if client.focus then client.focus:raise() end
  119. end),
  120. awful.button({ }, 5, function ()
  121. awful.client.focus.byidx(-1)
  122. if client.focus then client.focus:raise() end
  123. end))
  124.  
  125. for s = 1, screen.count() do
  126. -- Create a promptbox for each screen
  127. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  128. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  129. -- We need one layoutbox per screen.
  130. mylayoutbox[s] = awful.widget.layoutbox(s)
  131. mylayoutbox[s]:buttons(awful.util.table.join(
  132. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  133. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  134. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  135. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  136. -- Create a taglist widget
  137. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  138.  
  139. -- Create a tasklist widget
  140. mytasklist[s] = awful.widget.tasklist(function(c)
  141. return awful.widget.tasklist.label.currenttags(c, s)
  142. end, mytasklist.buttons)
  143.  
  144. -- Create the wibox
  145. mywibox[s] = awful.wibox({ position = "top", screen = s })
  146. -- Add widgets to the wibox - order matters
  147. mywibox[s].widgets = {
  148. {
  149. mylauncher,
  150. mytaglist[s],
  151. mypromptbox[s],
  152. layout = awful.widget.layout.horizontal.leftright
  153. },
  154. mylayoutbox[s],
  155. mytextclock,
  156. -- s == 1 and mysystray or nil,
  157. mytasklist[s],
  158. layout = awful.widget.layout.horizontal.rightleft
  159. }
  160. end
  161. -- }}}
  162.  
  163. -- {{{ Mouse bindings
  164. root.buttons(awful.util.table.join(
  165. awful.button({ }, 3, function () mymainmenu:toggle() end),
  166. awful.button({ }, 4, awful.tag.viewnext),
  167. awful.button({ }, 5, awful.tag.viewprev)
  168. ))
  169. -- }}}
  170.  
  171. -- {{{ Key bindings
  172. globalkeys = awful.util.table.join(
  173. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  174. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  175. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  176.  
  177. awful.key({ modkey, }, "j",
  178. function ()
  179. awful.client.focus.byidx( 1)
  180. if client.focus then client.focus:raise() end
  181. end),
  182. awful.key({ modkey, }, "k",
  183. function ()
  184. awful.client.focus.byidx(-1)
  185. if client.focus then client.focus:raise() end
  186. end),
  187. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  188.  
  189. -- Layout manipulation
  190. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  191. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  192. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  193. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  194. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  195. awful.key({ modkey, }, "Tab",
  196. function ()
  197. awful.client.focus.history.previous()
  198. if client.focus then
  199. client.focus:raise()
  200. end
  201. end),
  202.  
  203. -- Standard program
  204. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  205. awful.key({ modkey, "Control" }, "r", awesome.restart),
  206. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  207.  
  208. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  209. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  210. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  211. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  212. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  213. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  214. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  215. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  216.  
  217. -- Prompt
  218. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  219.  
  220. awful.key({ modkey }, "x",
  221. function ()
  222. awful.prompt.run({ prompt = "Run Lua code: " },
  223. mypromptbox[mouse.screen].widget,
  224. awful.util.eval, nil,
  225. awful.util.getdir("cache") .. "/history_eval")
  226. end)
  227. )
  228.  
  229. clientkeys = awful.util.table.join(
  230. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  231. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  232. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  233. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  234. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  235. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  236. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  237. awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
  238. awful.key({ modkey, }, "m",
  239. function (c)
  240. c.maximized_horizontal = not c.maximized_horizontal
  241. c.maximized_vertical = not c.maximized_vertical
  242. end)
  243. )
  244.  
  245. -- Compute the maximum number of digit we need, limited to 9
  246. keynumber = 0
  247. for s = 1, screen.count() do
  248. keynumber = math.min(9, math.max(#tags[s], keynumber));
  249. end
  250.  
  251. -- Bind all key numbers to tags.
  252. -- Be careful: we use keycodes to make it works on any keyboard layout.
  253. -- This should map on the top row of your keyboard, usually 1 to 9.
  254. for i = 1, keynumber do
  255. globalkeys = awful.util.table.join(globalkeys,
  256. awful.key({ modkey }, "#" .. i + 9,
  257. function ()
  258. local screen = mouse.screen
  259. if tags[screen][i] then
  260. awful.tag.viewonly(tags[screen][i])
  261. end
  262. end),
  263. awful.key({ modkey, "Control" }, "#" .. i + 9,
  264. function ()
  265. local screen = mouse.screen
  266. if tags[screen][i] then
  267. awful.tag.viewtoggle(tags[screen][i])
  268. end
  269. end),
  270. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  271. function ()
  272. if client.focus and tags[client.focus.screen][i] then
  273. awful.client.movetotag(tags[client.focus.screen][i])
  274. end
  275. end),
  276. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  277. function ()
  278. if client.focus and tags[client.focus.screen][i] then
  279. awful.client.toggletag(tags[client.focus.screen][i])
  280. end
  281. end))
  282. end
  283.  
  284. clientbuttons = awful.util.table.join(
  285. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  286. awful.button({ modkey }, 1, awful.mouse.client.move),
  287. awful.button({ modkey }, 3, awful.mouse.client.resize))
  288.  
  289. -- Set keys
  290. root.keys(globalkeys)
  291. -- }}}
  292.  
  293. -- {{{ Rules
  294. awful.rules.rules = {
  295. -- All clients will match this rule.
  296. { rule = { },
  297. properties = { border_width = beautiful.border_width,
  298. border_color = beautiful.border_normal,
  299. focus = true,
  300. keys = clientkeys,
  301. buttons = clientbuttons } },
  302. { rule = { class = "MPlayer" },
  303. properties = { floating = true } },
  304. { rule = { class = "pinentry" },
  305. properties = { floating = true } },
  306. { rule = { class = "gimp" },
  307. properties = { floating = true } },
  308. -- Set Firefox to always map on tags number 2 of screen 1.
  309. -- { rule = { class = "Firefox" },
  310. -- properties = { tag = tags[1][2] } },
  311. }
  312. -- }}}
  313.  
  314. -- {{{ Signals
  315. -- Signal function to execute when a new client appears.
  316. client.add_signal("manage", function (c, startup)
  317. -- Add a titlebar
  318. -- awful.titlebar.add(c, { modkey = modkey })
  319.  
  320. -- Enable sloppy focus
  321. c:add_signal("mouse::enter", function(c)
  322. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  323. and awful.client.focus.filter(c) then
  324. client.focus = c
  325. end
  326. end)
  327.  
  328. if not startup then
  329. -- Set the windows at the slave,
  330. -- i.e. put it at the end of others instead of setting it master.
  331. -- awful.client.setslave(c)
  332.  
  333. -- Put windows in a smart way, only if they does not set an initial position.
  334. if not c.size_hints.user_position and not c.size_hints.program_position then
  335. awful.placement.no_overlap(c)
  336. awful.placement.no_offscreen(c)
  337. end
  338. end
  339. end)
  340.  
  341. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  342. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  343. -- }}}
Add Comment
Please, Sign In to add comment