Advertisement
Guest User

Untitled

a guest
Nov 19th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.50 KB | None | 0 0
  1. -- If LuaRocks is installed, make sure that packages installed through it are
  2. -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
  3. pcall(require, "luarocks.loader")
  4.  
  5. -- Standard awesome library
  6. local gears = require("gears")
  7. local awful = require("awful")
  8. require("awful.autofocus")
  9. -- Widget and layout library
  10. local wibox = require("wibox")
  11. -- Theme handling library
  12. local beautiful = require("beautiful")
  13. -- Notification library
  14. local naughty = require("naughty")
  15. local menubar = require("menubar")
  16. local hotkeys_popup = require("awful.hotkeys_popup")
  17. -- Enable hotkeys help widget for VIM and other apps
  18. -- when client with a matching name is opened:
  19. require("awful.hotkeys_popup.keys")
  20.  
  21. -- {{{ Error handling
  22. -- Check if awesome encountered an error during startup and fell back to
  23. -- another config (This code will only ever execute for the fallback config)
  24. if awesome.startup_errors then
  25. naughty.notify({ preset = naughty.config.presets.critical,
  26. title = "Oops, there were errors during startup!",
  27. text = awesome.startup_errors })
  28. end
  29.  
  30. -- Handle runtime errors after startup
  31. do
  32. local in_error = false
  33. awesome.connect_signal("debug::error", function (err)
  34. -- Make sure we don't go into an endless error loop
  35. if in_error then return end
  36. in_error = true
  37.  
  38. naughty.notify({ preset = naughty.config.presets.critical,
  39. title = "Oops, an error happened!",
  40. text = tostring(err) })
  41. in_error = false
  42. end)
  43. end
  44. -- }}}
  45.  
  46. -- {{{ Variable definitions
  47. -- Themes define colours, icons, font and wallpapers.
  48. beautiful.init("/home/azuneer/.config/awesome/theme.lua")
  49. beautiful.font = "Terminus 10"
  50.  
  51. -- This is used later as the default terminal and editor to run.
  52. terminal = "kitty"
  53. editor = os.getenv("EDITOR") or "vim"
  54. editor_cmd = terminal .. " -e " .. editor
  55.  
  56. -- Default modkey.
  57. -- Usually, Mod4 is the key with a logo between Control and Alt.
  58. -- If you do not like this or do not have such a key,
  59. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  60. -- However, you can use another modifier like Mod1, but it may interact with others.
  61. modkey = "Mod4"
  62.  
  63. -- Table of layouts to cover with awful.layout.inc, order matters.
  64. awful.layout.layouts = {
  65. awful.layout.suit.tile,
  66. awful.layout.suit.floating,
  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. -- awful.layout.suit.corner.nw,
  78. -- awful.layout.suit.corner.ne,
  79. -- awful.layout.suit.corner.sw,
  80. -- awful.layout.suit.corner.se,
  81. }
  82. -- }}}
  83.  
  84. -- {{{ Menu
  85. -- Create a launcher widget and a main menu
  86. myawesomemenu = {
  87. { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
  88. { "manual", terminal .. " -e man awesome" },
  89. { "edit config", editor_cmd .. " " .. awesome.conffile },
  90. { "restart", awesome.restart },
  91. { "quit", function() awesome.quit() end },
  92. }
  93.  
  94. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  95. { "open terminal", terminal }
  96. }
  97. })
  98.  
  99. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  100. menu = mymainmenu })
  101.  
  102. -- Menubar configuration
  103. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  104. -- }}}
  105.  
  106. -- Keyboard map indicator and switcher
  107. mykeyboardlayout = awful.widget.keyboardlayout()
  108.  
  109. -- {{{ Wibar
  110. -- Create a textclock widget
  111. mytextclock = wibox.widget.textclock()
  112.  
  113. -- Create a wibox for each screen and add it
  114. local taglist_buttons = gears.table.join(
  115. awful.button({ }, 1, function(t) t:view_only() end),
  116. awful.button({ modkey }, 1, function(t)
  117. if client.focus then
  118. client.focus:move_to_tag(t)
  119. end
  120. end),
  121. awful.button({ }, 3, awful.tag.viewtoggle),
  122. awful.button({ modkey }, 3, function(t)
  123. if client.focus then
  124. client.focus:toggle_tag(t)
  125. end
  126. end),
  127. awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
  128. awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
  129. )
  130.  
  131. local tasklist_buttons = gears.table.join(
  132. awful.button({ }, 1, function (c)
  133. if c == client.focus then
  134. c.minimized = true
  135. else
  136. c:emit_signal(
  137. "request::activate",
  138. "tasklist",
  139. {raise = true}
  140. )
  141. end
  142. end),
  143. awful.button({ }, 3, function()
  144. awful.menu.client_list({ theme = { width = 250 } })
  145. end),
  146. awful.button({ }, 4, function ()
  147. awful.client.focus.byidx(1)
  148. end),
  149. awful.button({ }, 5, function ()
  150. awful.client.focus.byidx(-1)
  151. end))
  152.  
  153. local function set_wallpaper(s)
  154. -- Wallpaper
  155. if beautiful.wallpaper then
  156. local wallpaper = beautiful.wallpaper
  157. -- If wallpaper is a function, call it with the screen
  158. if type(wallpaper) == "function" then
  159. wallpaper = wallpaper(s)
  160. end
  161. gears.wallpaper.maximized(wallpaper, s, true)
  162. end
  163. end
  164.  
  165. -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
  166. screen.connect_signal("property::geometry", set_wallpaper)
  167.  
  168. awful.screen.connect_for_each_screen(function(s)
  169. -- Wallpaper
  170. set_wallpaper(s)
  171.  
  172. -- Each screen has its own tag table.
  173.  
  174. local names = { "main", "web", "code", "discord", "work", "vm", "spotify" }
  175. local l = awful.layout.suit -- Just to save some typing: use an alias.
  176. local layouts = { l.tile, l.tile, l.tile, l.tile, l.tile,
  177. l.tile, l.tile }
  178. awful.tag(names, s, layouts)
  179.  
  180. -- Create a promptbox for each screen
  181. s.mypromptbox = awful.widget.prompt()
  182. -- Create an imagebox widget which will contain an icon indicating which layout we're using.
  183. -- We need one layoutbox per screen.
  184. s.mylayoutbox = awful.widget.layoutbox(s)
  185. s.mylayoutbox:buttons(gears.table.join(
  186. awful.button({ }, 1, function () awful.layout.inc( 1) end),
  187. awful.button({ }, 3, function () awful.layout.inc(-1) end),
  188. awful.button({ }, 4, function () awful.layout.inc( 1) end),
  189. awful.button({ }, 5, function () awful.layout.inc(-1) end)))
  190. -- Create a taglist widget
  191. s.mytaglist = awful.widget.taglist {
  192. screen = s,
  193. filter = awful.widget.taglist.filter.all,
  194. buttons = taglist_buttons
  195. }
  196.  
  197. -- Create a tasklist widget
  198. s.mytasklist = awful.widget.tasklist {
  199. screen = s,
  200. filter = awful.widget.tasklist.filter.currenttags,
  201. buttons = tasklist_buttons
  202. }
  203.  
  204. -- Create the wibox
  205. s.mywibox = awful.wibar({ position = "top", screen = s })
  206.  
  207. -- Add widgets to the wibox
  208. s.mywibox:setup {
  209. layout = wibox.layout.align.horizontal,
  210. { -- Left widgets
  211. layout = wibox.layout.fixed.horizontal,
  212. s.mytaglist,
  213. s.mypromptbox,
  214. },
  215. nil, -- Middle widget
  216. { -- Right widgets
  217. layout = wibox.layout.fixed.horizontal,
  218. mykeyboardlayout,
  219. wibox.widget.systray(),
  220. mytextclock,
  221. },
  222. }
  223. end)
  224. -- }}}
  225.  
  226. -- {{{ Mouse bindings
  227. root.buttons(gears.table.join(
  228. awful.button({ }, 3, function () mymainmenu:toggle() end),
  229. awful.button({ }, 4, awful.tag.viewnext),
  230. awful.button({ }, 5, awful.tag.viewprev)
  231. ))
  232. -- }}}
  233.  
  234. -- {{{ Key bindings
  235. globalkeys = gears.table.join(
  236. awful.key({ modkey, }, "s", hotkeys_popup.show_help,
  237. {description="show help", group="awesome"}),
  238. awful.key({ modkey, }, "Left", awful.tag.viewprev,
  239. {description = "view previous", group = "tag"}),
  240. awful.key({ modkey, }, "Right", awful.tag.viewnext,
  241. {description = "view next", group = "tag"}),
  242. awful.key({ modkey, }, "Escape", awful.tag.history.restore,
  243. {description = "go back", group = "tag"}),
  244.  
  245. awful.key({ modkey, }, "j",
  246. function ()
  247. awful.client.focus.byidx( 1)
  248. end,
  249. {description = "focus next by index", group = "client"}
  250. ),
  251. awful.key({ modkey, }, "k",
  252. function ()
  253. awful.client.focus.byidx(-1)
  254. end,
  255. {description = "focus previous by index", group = "client"}
  256. ),
  257. awful.key({ modkey, }, "w", function () mymainmenu:show() end,
  258. {description = "show main menu", group = "awesome"}),
  259.  
  260. -- Layout manipulation
  261. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
  262. {description = "swap with next client by index", group = "client"}),
  263. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
  264. {description = "swap with previous client by index", group = "client"}),
  265. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
  266. {description = "focus the next screen", group = "screen"}),
  267. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
  268. {description = "focus the previous screen", group = "screen"}),
  269. awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
  270. {description = "jump to urgent client", group = "client"}),
  271. awful.key({ modkey, }, "Tab",
  272. function ()
  273. awful.client.focus.history.previous()
  274. if client.focus then
  275. client.focus:raise()
  276. end
  277. end,
  278. {description = "go back", group = "client"}),
  279.  
  280. -- Standard program
  281. awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
  282. {description = "open a terminal", group = "launcher"}),
  283. awful.key({ modkey, "Control" }, "r", awesome.restart,
  284. {description = "reload awesome", group = "awesome"}),
  285. awful.key({ modkey, "Shift" }, "q", awesome.quit,
  286. {description = "quit awesome", group = "awesome"}),
  287.  
  288. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
  289. {description = "increase master width factor", group = "layout"}),
  290. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
  291. {description = "decrease master width factor", group = "layout"}),
  292. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
  293. {description = "increase the number of master clients", group = "layout"}),
  294. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
  295. {description = "decrease the number of master clients", group = "layout"}),
  296. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
  297. {description = "increase the number of columns", group = "layout"}),
  298. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
  299. {description = "decrease the number of columns", group = "layout"}),
  300. awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
  301. {description = "select next", group = "layout"}),
  302. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
  303. {description = "select previous", group = "layout"}),
  304.  
  305. awful.key({ modkey, "Control" }, "n",
  306. function ()
  307. local c = awful.client.restore()
  308. -- Focus restored client
  309. if c then
  310. c:emit_signal(
  311. "request::activate", "key.unminimize", {raise = true}
  312. )
  313. end
  314. end,
  315. {description = "restore minimized", group = "client"}),
  316.  
  317. -- Prompt
  318. awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
  319. {description = "run prompt", group = "launcher"}),
  320.  
  321. awful.key({ modkey }, "x",
  322. function ()
  323. awful.prompt.run {
  324. prompt = "Run Lua code: ",
  325. textbox = awful.screen.focused().mypromptbox.widget,
  326. exe_callback = awful.util.eval,
  327. history_path = awful.util.get_cache_dir() .. "/history_eval"
  328. }
  329. end,
  330. {description = "lua execute prompt", group = "awesome"}),
  331. -- Menubar
  332. awful.key({ modkey }, "d", function() awful.spawn("rofi -show drun") end,
  333. {description = "show rofi", group = "launcher"})
  334. )
  335.  
  336. clientkeys = gears.table.join(
  337. awful.key({ modkey, }, "f",
  338. function (c)
  339. c.fullscreen = not c.fullscreen
  340. c:raise()
  341. end,
  342. {description = "toggle fullscreen", group = "client"}),
  343. awful.key({ modkey, }, "q", function (c) c:kill() end,
  344. {description = "close", group = "client"}),
  345. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
  346. {description = "toggle floating", group = "client"}),
  347. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
  348. {description = "move to master", group = "client"}),
  349. awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
  350. {description = "move to screen", group = "client"}),
  351. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
  352. {description = "toggle keep on top", group = "client"}),
  353. awful.key({ modkey, }, "n",
  354. function (c)
  355. -- The client currently has the input focus, so it cannot be
  356. -- minimized, since minimized clients can't have the focus.
  357. c.minimized = true
  358. end ,
  359. {description = "minimize", group = "client"}),
  360. awful.key({ modkey, }, "m",
  361. function (c)
  362. c.maximized = not c.maximized
  363. c:raise()
  364. end ,
  365. {description = "(un)maximize", group = "client"}),
  366. awful.key({ modkey, "Control" }, "m",
  367. function (c)
  368. c.maximized_vertical = not c.maximized_vertical
  369. c:raise()
  370. end ,
  371. {description = "(un)maximize vertically", group = "client"}),
  372. awful.key({ modkey, "Shift" }, "m",
  373. function (c)
  374. c.maximized_horizontal = not c.maximized_horizontal
  375. c:raise()
  376. end ,
  377. {description = "(un)maximize horizontally", group = "client"})
  378. )
  379.  
  380. -- Bind all key numbers to tags.
  381. -- Be careful: we use keycodes to make it work on any keyboard layout.
  382. -- This should map on the top row of your keyboard, usually 1 to 9.
  383. for i = 1, 9 do
  384. globalkeys = gears.table.join(globalkeys,
  385. -- View tag only.
  386. awful.key({ modkey }, "#" .. i + 9,
  387. function ()
  388. local screen = awful.screen.focused()
  389. local tag = screen.tags[i]
  390. if tag then
  391. tag:view_only()
  392. end
  393. end,
  394. {description = "view tag #"..i, group = "tag"}),
  395. -- Toggle tag display.
  396. awful.key({ modkey, "Control" }, "#" .. i + 9,
  397. function ()
  398. local screen = awful.screen.focused()
  399. local tag = screen.tags[i]
  400. if tag then
  401. awful.tag.viewtoggle(tag)
  402. end
  403. end,
  404. {description = "toggle tag #" .. i, group = "tag"}),
  405. -- Move client to tag.
  406. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  407. function ()
  408. if client.focus then
  409. local tag = client.focus.screen.tags[i]
  410. if tag then
  411. client.focus:move_to_tag(tag)
  412. end
  413. end
  414. end,
  415. {description = "move focused client to tag #"..i, group = "tag"}),
  416. -- Toggle tag on focused client.
  417. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  418. function ()
  419. if client.focus then
  420. local tag = client.focus.screen.tags[i]
  421. if tag then
  422. client.focus:toggle_tag(tag)
  423. end
  424. end
  425. end,
  426. {description = "toggle focused client on tag #" .. i, group = "tag"})
  427. )
  428. end
  429.  
  430. clientbuttons = gears.table.join(
  431. awful.button({ }, 1, function (c)
  432. c:emit_signal("request::activate", "mouse_click", {raise = true})
  433. end),
  434. awful.button({ modkey }, 1, function (c)
  435. c:emit_signal("request::activate", "mouse_click", {raise = true})
  436. awful.mouse.client.move(c)
  437. end),
  438. awful.button({ modkey }, 3, function (c)
  439. c:emit_signal("request::activate", "mouse_click", {raise = true})
  440. awful.mouse.client.resize(c)
  441. end)
  442. )
  443.  
  444. -- Set keys
  445. root.keys(globalkeys)
  446. -- }}}
  447.  
  448. -- {{{ Rules
  449. -- Rules to apply to new clients (through the "manage" signal).
  450. awful.rules.rules = {
  451. -- All clients will match this rule.
  452. { rule = { },
  453. properties = { border_width = beautiful.border_width,
  454. border_color = beautiful.border_normal,
  455. focus = awful.client.focus.filter,
  456. raise = true,
  457. keys = clientkeys,
  458. buttons = clientbuttons,
  459. screen = awful.screen.preferred,
  460. placement = awful.placement.no_overlap+awful.placement.no_offscreen
  461. }
  462. },
  463.  
  464. -- Floating clients.
  465. { rule_any = {
  466. instance = {
  467. "DTA", -- Firefox addon DownThemAll.
  468. "copyq", -- Includes session name in class.
  469. "pinentry",
  470. },
  471. class = {
  472. "Arandr",
  473. "Blueman-manager",
  474. "Gpick",
  475. "Kruler",
  476. "MessageWin", -- kalarm.
  477. "Sxiv",
  478. "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
  479. "Wpa_gui",
  480. "veromix",
  481. "xtightvncviewer"},
  482.  
  483. -- Note that the name property shown in xprop might be set slightly after creation of the client
  484. -- and the name shown there might not match defined rules here.
  485. name = {
  486. "Event Tester", -- xev.
  487. },
  488. role = {
  489. "AlarmWindow", -- Thunderbird's calendar.
  490. "ConfigManager", -- Thunderbird's about:config.
  491. "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
  492. }
  493. }, properties = { floating = true }},
  494.  
  495. -- Add titlebars to normal clients and dialogs
  496. { rule_any = {type = { "normal", "dialog" }
  497. }, properties = { titlebars_enabled = false }
  498. },
  499.  
  500. -- Set Firefox to always map on the tag named "2" on screen 1.
  501. -- { rule = { class = "Firefox" },
  502. -- properties = { screen = 1, tag = "2" } },
  503. }
  504. -- }}}
  505.  
  506. -- {{{ Signals
  507. -- Signal function to execute when a new client appears.
  508. client.connect_signal("manage", function (c)
  509. -- Set the windows at the slave,
  510. -- i.e. put it at the end of others instead of setting it master.
  511. -- if not awesome.startup then awful.client.setslave(c) end
  512.  
  513. if awesome.startup
  514. and not c.size_hints.user_position
  515. and not c.size_hints.program_position then
  516. -- Prevent clients from being unreachable after screen count changes.
  517. awful.placement.no_offscreen(c)
  518. end
  519. end)
  520.  
  521. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  522. client.connect_signal("request::titlebars", function(c)
  523. -- buttons for the titlebar
  524. local buttons = gears.table.join(
  525. awful.button({ }, 1, function()
  526. c:emit_signal("request::activate", "titlebar", {raise = true})
  527. awful.mouse.client.move(c)
  528. end),
  529. awful.button({ }, 3, function()
  530. c:emit_signal("request::activate", "titlebar", {raise = true})
  531. awful.mouse.client.resize(c)
  532. end)
  533. )
  534.  
  535. awful.titlebar(c) : setup {
  536. { -- Left
  537. awful.titlebar.widget.iconwidget(c),
  538. buttons = buttons,
  539. layout = wibox.layout.fixed.horizontal
  540. },
  541. { -- Middle
  542. { -- Title
  543. align = "center",
  544. widget = awful.titlebar.widget.titlewidget(c)
  545. },
  546. buttons = buttons,
  547. layout = wibox.layout.flex.horizontal
  548. },
  549. { -- Right
  550. awful.titlebar.widget.floatingbutton (c),
  551. awful.titlebar.widget.maximizedbutton(c),
  552. awful.titlebar.widget.stickybutton (c),
  553. awful.titlebar.widget.ontopbutton (c),
  554. awful.titlebar.widget.closebutton (c),
  555. layout = wibox.layout.fixed.horizontal()
  556. },
  557. layout = wibox.layout.align.horizontal
  558. }
  559. end)
  560.  
  561. -- Enable sloppy focus, so that focus follows mouse.
  562. client.connect_signal("mouse::enter", function(c)
  563. c:emit_signal("request::activate", "mouse_enter", {raise = false})
  564. end)
  565.  
  566. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  567. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  568. -- }}}
  569.  
  570. -- Autostart applications
  571. awful.spawn.with_shell("feh --bg-scale /home/azuneer/Wallpapers/gentoo-abducted-1680x1050.png")
  572. awful.spawn.with_shell("discord")
  573. awful.spawn.with_shell("picom")
  574.  
  575. -- Gaps
  576. beautiful.useless_gap = 10
  577.  
  578. -- Enable floating
  579. awful.key({ modkey, }, "space", awful.client.floating.toggle,
  580. {description = "toggle floating", group = "client"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement