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.

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