Guest User

Untitled

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