Advertisement
Guest User

Untitled

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