Mirror of Awesome WM window manager
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.

awesomerc.lua 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. -- awesome_mode: api-level=4:screen=on
  2. -- If LuaRocks is installed, make sure that packages installed through it are
  3. -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
  4. pcall(require, "luarocks.loader")
  5. -- @DOC_REQUIRE_SECTION@
  6. -- Standard awesome library
  7. local gears = require("gears")
  8. local awful = require("awful")
  9. require("awful.autofocus")
  10. -- Widget and layout library
  11. local wibox = require("wibox")
  12. -- Theme handling library
  13. local beautiful = require("beautiful")
  14. -- Notification library
  15. local naughty = require("naughty")
  16. -- Declarative object management
  17. local ruled = require("ruled")
  18. local menubar = require("menubar")
  19. local hotkeys_popup = require("awful.hotkeys_popup")
  20. -- Enable hotkeys help widget for VIM and other apps
  21. -- when client with a matching name is opened:
  22. require("awful.hotkeys_popup.keys")
  23. -- {{{ Error handling
  24. -- Check if awesome encountered an error during startup and fell back to
  25. -- another config (This code will only ever execute for the fallback config)
  26. -- @DOC_ERROR_HANDLING@
  27. naughty.connect_signal("request::display_error", function(message, startup)
  28. naughty.notification {
  29. urgency = "critical",
  30. title = "Oops, an error happened"..(startup and " during startup!" or "!"),
  31. message = message
  32. }
  33. end)
  34. -- }}}
  35. -- {{{ Variable definitions
  36. -- @DOC_LOAD_THEME@
  37. -- Themes define colours, icons, font and wallpapers.
  38. beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
  39. -- @DOC_DEFAULT_APPLICATIONS@
  40. -- This is used later as the default terminal and editor to run.
  41. terminal = "xterm"
  42. editor = os.getenv("EDITOR") or "nano"
  43. editor_cmd = terminal .. " -e " .. editor
  44. -- Default modkey.
  45. -- Usually, Mod4 is the key with a logo between Control and Alt.
  46. -- If you do not like this or do not have such a key,
  47. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  48. -- However, you can use another modifier like Mod1, but it may interact with others.
  49. modkey = "Mod4"
  50. -- }}}
  51. -- {{{ Menu
  52. -- @DOC_MENU@
  53. -- Create a launcher widget and a main menu
  54. myawesomemenu = {
  55. { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
  56. { "manual", terminal .. " -e man awesome" },
  57. { "edit config", editor_cmd .. " " .. awesome.conffile },
  58. { "restart", awesome.restart },
  59. { "quit", function() awesome.quit() end },
  60. }
  61. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  62. { "open terminal", terminal }
  63. }
  64. })
  65. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  66. menu = mymainmenu })
  67. -- Menubar configuration
  68. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  69. -- }}}
  70. -- {{{ Tag
  71. -- @DOC_LAYOUT@
  72. -- Table of layouts to cover with awful.layout.inc, order matters.
  73. tag.connect_signal("request::default_layouts", function()
  74. awful.layout.append_default_layouts({
  75. awful.layout.suit.floating,
  76. awful.layout.suit.tile,
  77. awful.layout.suit.tile.left,
  78. awful.layout.suit.tile.bottom,
  79. awful.layout.suit.tile.top,
  80. awful.layout.suit.fair,
  81. awful.layout.suit.fair.horizontal,
  82. awful.layout.suit.spiral,
  83. awful.layout.suit.spiral.dwindle,
  84. awful.layout.suit.max,
  85. awful.layout.suit.max.fullscreen,
  86. awful.layout.suit.magnifier,
  87. awful.layout.suit.corner.nw,
  88. })
  89. end)
  90. -- }}}
  91. -- {{{ Wibar
  92. -- Keyboard map indicator and switcher
  93. mykeyboardlayout = awful.widget.keyboardlayout()
  94. -- Create a textclock widget
  95. mytextclock = wibox.widget.textclock()
  96. -- @DOC_WALLPAPER@
  97. screen.connect_signal("request::wallpaper", function(s)
  98. -- Wallpaper
  99. if beautiful.wallpaper then
  100. local wallpaper = beautiful.wallpaper
  101. -- If wallpaper is a function, call it with the screen
  102. if type(wallpaper) == "function" then
  103. wallpaper = wallpaper(s)
  104. end
  105. gears.wallpaper.maximized(wallpaper, s, true)
  106. end
  107. end)
  108. -- @DOC_FOR_EACH_SCREEN@
  109. screen.connect_signal("request::desktop_decoration", function(s)
  110. -- Each screen has its own tag table.
  111. awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
  112. -- Create a promptbox for each screen
  113. s.mypromptbox = awful.widget.prompt()
  114. -- Create an imagebox widget which will contain an icon indicating which layout we're using.
  115. -- We need one layoutbox per screen.
  116. s.mylayoutbox = awful.widget.layoutbox {
  117. screen = s,
  118. buttons = {
  119. awful.button({ }, 1, function () awful.layout.inc( 1) end),
  120. awful.button({ }, 3, function () awful.layout.inc(-1) end),
  121. awful.button({ }, 4, function () awful.layout.inc( 1) end),
  122. awful.button({ }, 5, function () awful.layout.inc(-1) end),
  123. }
  124. }
  125. -- Create a taglist widget
  126. s.mytaglist = awful.widget.taglist {
  127. screen = s,
  128. filter = awful.widget.taglist.filter.all,
  129. buttons = {
  130. awful.button({ }, 1, function(t) t:view_only() end),
  131. awful.button({ modkey }, 1, function(t)
  132. if client.focus then
  133. client.focus:move_to_tag(t)
  134. end
  135. end),
  136. awful.button({ }, 3, awful.tag.viewtoggle),
  137. awful.button({ modkey }, 3, function(t)
  138. if client.focus then
  139. client.focus:toggle_tag(t)
  140. end
  141. end),
  142. awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
  143. awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end),
  144. }
  145. }
  146. -- @TASKLIST_BUTTON@
  147. -- Create a tasklist widget
  148. s.mytasklist = awful.widget.tasklist {
  149. screen = s,
  150. filter = awful.widget.tasklist.filter.currenttags,
  151. buttons = {
  152. awful.button({ }, 1, function (c)
  153. c:activate { context = "tasklist", action = "toggle_minimization" }
  154. end),
  155. awful.button({ }, 3, function() awful.menu.client_list { theme = { width = 250 } } end),
  156. awful.button({ }, 4, function() awful.client.focus.byidx( 1) end),
  157. awful.button({ }, 5, function() awful.client.focus.byidx(-1) end),
  158. }
  159. }
  160. -- @DOC_WIBAR@
  161. -- Create the wibox
  162. s.mywibox = awful.wibar({ position = "top", screen = s })
  163. -- @DOC_SETUP_WIDGETS@
  164. -- Add widgets to the wibox
  165. s.mywibox.widget = {
  166. layout = wibox.layout.align.horizontal,
  167. { -- Left widgets
  168. layout = wibox.layout.fixed.horizontal,
  169. mylauncher,
  170. s.mytaglist,
  171. s.mypromptbox,
  172. },
  173. s.mytasklist, -- Middle widget
  174. { -- Right widgets
  175. layout = wibox.layout.fixed.horizontal,
  176. mykeyboardlayout,
  177. wibox.widget.systray(),
  178. mytextclock,
  179. s.mylayoutbox,
  180. },
  181. }
  182. end)
  183. -- }}}
  184. -- {{{ Mouse bindings
  185. -- @DOC_ROOT_BUTTONS@
  186. awful.mouse.append_global_mousebindings({
  187. awful.button({ }, 3, function () mymainmenu:toggle() end),
  188. awful.button({ }, 4, awful.tag.viewnext),
  189. awful.button({ }, 5, awful.tag.viewprev),
  190. })
  191. -- }}}
  192. -- {{{ Key bindings
  193. -- @DOC_GLOBAL_KEYBINDINGS@
  194. -- General Awesome keys
  195. awful.keyboard.append_global_keybindings({
  196. awful.key({ modkey, }, "s", hotkeys_popup.show_help,
  197. {description="show help", group="awesome"}),
  198. awful.key({ modkey, }, "w", function () mymainmenu:show() end,
  199. {description = "show main menu", group = "awesome"}),
  200. awful.key({ modkey, "Control" }, "r", awesome.restart,
  201. {description = "reload awesome", group = "awesome"}),
  202. awful.key({ modkey, "Shift" }, "q", awesome.quit,
  203. {description = "quit awesome", group = "awesome"}),
  204. awful.key({ modkey }, "x",
  205. function ()
  206. awful.prompt.run {
  207. prompt = "Run Lua code: ",
  208. textbox = awful.screen.focused().mypromptbox.widget,
  209. exe_callback = awful.util.eval,
  210. history_path = awful.util.get_cache_dir() .. "/history_eval"
  211. }
  212. end,
  213. {description = "lua execute prompt", group = "awesome"}),
  214. awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
  215. {description = "open a terminal", group = "launcher"}),
  216. awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
  217. {description = "run prompt", group = "launcher"}),
  218. awful.key({ modkey }, "p", function() menubar.show() end,
  219. {description = "show the menubar", group = "launcher"}),
  220. })
  221. -- Tags related keybindings
  222. awful.keyboard.append_global_keybindings({
  223. awful.key({ modkey, }, "Left", awful.tag.viewprev,
  224. {description = "view previous", group = "tag"}),
  225. awful.key({ modkey, }, "Right", awful.tag.viewnext,
  226. {description = "view next", group = "tag"}),
  227. awful.key({ modkey, }, "Escape", awful.tag.history.restore,
  228. {description = "go back", group = "tag"}),
  229. })
  230. -- Focus related keybindings
  231. awful.keyboard.append_global_keybindings({
  232. awful.key({ modkey, }, "j",
  233. function ()
  234. awful.client.focus.byidx( 1)
  235. end,
  236. {description = "focus next by index", group = "client"}
  237. ),
  238. awful.key({ modkey, }, "k",
  239. function ()
  240. awful.client.focus.byidx(-1)
  241. end,
  242. {description = "focus previous by index", group = "client"}
  243. ),
  244. awful.key({ modkey, }, "Tab",
  245. function ()
  246. awful.client.focus.history.previous()
  247. if client.focus then
  248. client.focus:raise()
  249. end
  250. end,
  251. {description = "go back", group = "client"}),
  252. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
  253. {description = "focus the next screen", group = "screen"}),
  254. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
  255. {description = "focus the previous screen", group = "screen"}),
  256. awful.key({ modkey, "Control" }, "n",
  257. function ()
  258. local c = awful.client.restore()
  259. -- Focus restored client
  260. if c then
  261. c:activate { raise = true, context = "key.unminimize" }
  262. end
  263. end,
  264. {description = "restore minimized", group = "client"}),
  265. })
  266. -- Layout related keybindings
  267. awful.keyboard.append_global_keybindings({
  268. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
  269. {description = "swap with next client by index", group = "client"}),
  270. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
  271. {description = "swap with previous client by index", group = "client"}),
  272. awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
  273. {description = "jump to urgent client", group = "client"}),
  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. -- @DOC_NUMBER_KEYBINDINGS@
  292. awful.keyboard.append_global_keybindings({
  293. awful.key {
  294. modifiers = { modkey },
  295. keygroup = "numrow",
  296. description = "only view tag",
  297. group = "tag",
  298. on_press = function (index)
  299. local screen = awful.screen.focused()
  300. local tag = screen.tags[index]
  301. if tag then
  302. tag:view_only()
  303. end
  304. end,
  305. },
  306. awful.key {
  307. modifiers = { modkey, "Control" },
  308. keygroup = "numrow",
  309. description = "toggle tag",
  310. group = "tag",
  311. on_press = function (index)
  312. local screen = awful.screen.focused()
  313. local tag = screen.tags[index]
  314. if tag then
  315. awful.tag.viewtoggle(tag)
  316. end
  317. end,
  318. },
  319. awful.key {
  320. modifiers = { modkey, "Shift" },
  321. keygroup = "numrow",
  322. description = "move focused client to tag",
  323. group = "tag",
  324. on_press = function (index)
  325. if client.focus then
  326. local tag = client.focus.screen.tags[index]
  327. if tag then
  328. client.focus:move_to_tag(tag)
  329. end
  330. end
  331. end,
  332. },
  333. awful.key {
  334. modifiers = { modkey, "Control", "Shift" },
  335. keygroup = "numrow",
  336. description = "toggle focused client on tag",
  337. group = "tag",
  338. on_press = function (index)
  339. if client.focus then
  340. local tag = client.focus.screen.tags[index]
  341. if tag then
  342. client.focus:toggle_tag(tag)
  343. end
  344. end
  345. end,
  346. },
  347. awful.key {
  348. modifiers = { modkey },
  349. keygroup = "numpad",
  350. description = "select layout directly",
  351. group = "layout",
  352. on_press = function (index)
  353. local t = awful.screen.focused().selected_tag
  354. if t then
  355. t.layout = t.layouts[index] or t.layout
  356. end
  357. end,
  358. }
  359. })
  360. -- @DOC_CLIENT_BUTTONS@
  361. client.connect_signal("request::default_mousebindings", function()
  362. awful.mouse.append_client_mousebindings({
  363. awful.button({ }, 1, function (c)
  364. c:activate { context = "mouse_click" }
  365. end),
  366. awful.button({ modkey }, 1, function (c)
  367. c:activate { context = "mouse_click", action = "mouse_move" }
  368. end),
  369. awful.button({ modkey }, 3, function (c)
  370. c:activate { context = "mouse_click", action = "mouse_resize"}
  371. end),
  372. })
  373. end)
  374. -- @DOC_CLIENT_KEYBINDINGS@
  375. client.connect_signal("request::default_keybindings", function()
  376. awful.keyboard.append_client_keybindings({
  377. awful.key({ modkey, }, "f",
  378. function (c)
  379. c.fullscreen = not c.fullscreen
  380. c:raise()
  381. end,
  382. {description = "toggle fullscreen", group = "client"}),
  383. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
  384. {description = "close", group = "client"}),
  385. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
  386. {description = "toggle floating", group = "client"}),
  387. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
  388. {description = "move to master", group = "client"}),
  389. awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
  390. {description = "move to screen", group = "client"}),
  391. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
  392. {description = "toggle keep on top", group = "client"}),
  393. awful.key({ modkey, }, "n",
  394. function (c)
  395. -- The client currently has the input focus, so it cannot be
  396. -- minimized, since minimized clients can't have the focus.
  397. c.minimized = true
  398. end ,
  399. {description = "minimize", group = "client"}),
  400. awful.key({ modkey, }, "m",
  401. function (c)
  402. c.maximized = not c.maximized
  403. c:raise()
  404. end ,
  405. {description = "(un)maximize", group = "client"}),
  406. awful.key({ modkey, "Control" }, "m",
  407. function (c)
  408. c.maximized_vertical = not c.maximized_vertical
  409. c:raise()
  410. end ,
  411. {description = "(un)maximize vertically", group = "client"}),
  412. awful.key({ modkey, "Shift" }, "m",
  413. function (c)
  414. c.maximized_horizontal = not c.maximized_horizontal
  415. c:raise()
  416. end ,
  417. {description = "(un)maximize horizontally", group = "client"}),
  418. })
  419. end)
  420. -- }}}
  421. -- {{{ Rules
  422. -- Rules to apply to new clients.
  423. -- @DOC_RULES@
  424. ruled.client.connect_signal("request::rules", function()
  425. -- @DOC_GLOBAL_RULE@
  426. -- All clients will match this rule.
  427. ruled.client.append_rule {
  428. id = "global",
  429. rule = { },
  430. properties = {
  431. focus = awful.client.focus.filter,
  432. raise = true,
  433. screen = awful.screen.preferred,
  434. placement = awful.placement.no_overlap+awful.placement.no_offscreen
  435. }
  436. }
  437. -- @DOC_FLOATING_RULE@
  438. -- Floating clients.
  439. ruled.client.append_rule {
  440. id = "floating",
  441. rule_any = {
  442. instance = { "copyq", "pinentry" },
  443. class = {
  444. "Arandr", "Blueman-manager", "Gpick", "Kruler", "Sxiv",
  445. "Tor Browser", "Wpa_gui", "veromix", "xtightvncviewer"
  446. },
  447. -- Note that the name property shown in xprop might be set slightly after creation of the client
  448. -- and the name shown there might not match defined rules here.
  449. name = {
  450. "Event Tester", -- xev.
  451. },
  452. role = {
  453. "AlarmWindow", -- Thunderbird's calendar.
  454. "ConfigManager", -- Thunderbird's about:config.
  455. "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
  456. }
  457. },
  458. properties = { floating = true }
  459. }
  460. -- @DOC_DIALOG_RULE@
  461. -- Add titlebars to normal clients and dialogs
  462. ruled.client.append_rule {
  463. -- @DOC_CSD_TITLEBARS@
  464. id = "titlebars",
  465. rule_any = { type = { "normal", "dialog" } },
  466. properties = { titlebars_enabled = true }
  467. }
  468. -- Set Firefox to always map on the tag named "2" on screen 1.
  469. -- ruled.client.append_rule {
  470. -- rule = { class = "Firefox" },
  471. -- properties = { screen = 1, tag = "2" }
  472. -- }
  473. end)
  474. -- }}}
  475. -- {{{ Titlebars
  476. -- @DOC_TITLEBARS@
  477. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  478. client.connect_signal("request::titlebars", function(c)
  479. -- buttons for the titlebar
  480. local buttons = {
  481. awful.button({ }, 1, function()
  482. c:activate { context = "titlebar", action = "mouse_move" }
  483. end),
  484. awful.button({ }, 3, function()
  485. c:activate { context = "titlebar", action = "mouse_resize"}
  486. end),
  487. }
  488. awful.titlebar(c).widget = {
  489. { -- Left
  490. awful.titlebar.widget.iconwidget(c),
  491. buttons = buttons,
  492. layout = wibox.layout.fixed.horizontal
  493. },
  494. { -- Middle
  495. { -- Title
  496. align = "center",
  497. widget = awful.titlebar.widget.titlewidget(c)
  498. },
  499. buttons = buttons,
  500. layout = wibox.layout.flex.horizontal
  501. },
  502. { -- Right
  503. awful.titlebar.widget.floatingbutton (c),
  504. awful.titlebar.widget.maximizedbutton(c),
  505. awful.titlebar.widget.stickybutton (c),
  506. awful.titlebar.widget.ontopbutton (c),
  507. awful.titlebar.widget.closebutton (c),
  508. layout = wibox.layout.fixed.horizontal()
  509. },
  510. layout = wibox.layout.align.horizontal
  511. }
  512. end)
  513. -- {{{ Notifications
  514. ruled.notification.connect_signal('request::rules', function()
  515. -- All notifications will match this rule.
  516. ruled.notification.append_rule {
  517. rule = { },
  518. properties = {
  519. screen = awful.screen.preferred,
  520. implicit_timeout = 5,
  521. }
  522. }
  523. end)
  524. naughty.connect_signal("request::display", function(n)
  525. naughty.layout.box { notification = n }
  526. end)
  527. -- }}}
  528. -- Enable sloppy focus, so that focus follows mouse.
  529. client.connect_signal("mouse::enter", function(c)
  530. c:activate { context = "mouse_enter", raise = false }
  531. end)