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.

618 lines
24 KiB

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