Guest User

Untitled

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