All of my important config files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

627 lines
24 KiB

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