Advertisement
Guest User

Config en Awesome WM

a guest
Dec 14th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.53 KB | None | 0 0
  1. --[[
  2.  
  3. Awesome WM configuration template
  4. github.com/lcpz
  5.  
  6. --]]
  7.  
  8. -- {{{ Required libraries
  9. --
  10. require("vicious")
  11. --
  12. local awesome, client, mouse, screen, tag = awesome, client, mouse, screen, tag
  13. local ipairs, string, os, table, tostring, tonumber, type = ipairs, string, os, table, tostring, tonumber, type
  14.  
  15. local gears = require("gears")
  16. local awful = require("awful")
  17. require("awful.autofocus")
  18. local wibox = require("wibox")
  19. local beautiful = require("beautiful")
  20. local naughty = require("naughty")
  21. local lain = require("lain")
  22. --local menubar = require("menubar")
  23. local freedesktop = require("freedesktop")
  24. local hotkeys_popup = require("awful.hotkeys_popup").widget
  25. -- }}}
  26.  
  27. -- {{{ Error handling
  28. if awesome.startup_errors then
  29. naughty.notify({ preset = naughty.config.presets.critical,
  30. title = "Oops, there were errors during startup!",
  31. text = awesome.startup_errors })
  32. end
  33.  
  34. do
  35. local in_error = false
  36. awesome.connect_signal("debug::error", function (err)
  37. if in_error then return end
  38. in_error = true
  39.  
  40. naughty.notify({ preset = naughty.config.presets.critical,
  41. title = "Oops, an error happened!",
  42. text = tostring(err) })
  43. in_error = false
  44. end)
  45. end
  46. -- }}}
  47.  
  48. -- {{{ Autostart windowless processes
  49. local function run_once(cmd_arr)
  50. for _, cmd in ipairs(cmd_arr) do
  51. findme = cmd
  52. firstspace = cmd:find(" ")
  53. if firstspace then
  54. findme = cmd:sub(0, firstspace-1)
  55. end
  56. awful.spawn.with_shell(string.format("pgrep -u $USER -x %s > /dev/null || (%s)", findme, cmd))
  57. end
  58. end
  59.  
  60. run_once({ "unclutter -root" }) -- entries must be comma-separated
  61. -- }}}
  62.  
  63. -- {{{ Variable definitions
  64.  
  65. local themes = {
  66. "blackburn", -- 1
  67. "copland", -- 2
  68. "dremora", -- 3
  69. "holo", -- 4
  70. "multicolor", -- 5
  71. "powerarrow", -- 6
  72. "powerarrow-dark", -- 7
  73. "rainbow", -- 8
  74. "steamburn", -- 9
  75. "vertex", -- 10
  76. }
  77.  
  78. local chosen_theme = themes[7]
  79. -- local modkey = "Mod4"
  80. -- local altkey = "Mod1"
  81. local modkey = "Mod4"
  82. local altkey = "Mod1"
  83. -- local terminal = "xterm"
  84. local terminal = "terminator"
  85. local editor = os.getenv("EDITOR") or "nano"
  86. -- local gui_editor = "gvim"
  87. local gui_editor = "vim"
  88. -- local browser = "firefox"
  89. local browser = "google-chrome"
  90. -- local guieditor = "atom"
  91. local guieditor = "geany"
  92. local gmrun = "gmrun"
  93. local scrot = "scrot"
  94.  
  95. awful.util.terminal = terminal
  96. awful.util.tagnames = { "arcadia", "harlock", "miime", "yuki", "dev", "net" }
  97. awful.layout.layouts = {
  98. awful.layout.suit.floating,
  99. awful.layout.suit.tile,
  100. awful.layout.suit.tile.left,
  101. awful.layout.suit.tile.bottom,
  102. awful.layout.suit.tile.top,
  103. --awful.layout.suit.fair,
  104. --awful.layout.suit.fair.horizontal,
  105. --awful.layout.suit.spiral,
  106. --awful.layout.suit.spiral.dwindle,
  107. --awful.layout.suit.max,
  108. --awful.layout.suit.max.fullscreen,
  109. --awful.layout.suit.magnifier,
  110. --awful.layout.suit.corner.nw,
  111. --awful.layout.suit.corner.ne,
  112. --awful.layout.suit.corner.sw,
  113. --awful.layout.suit.corner.se,
  114. --lain.layout.cascade,
  115. --lain.layout.cascade.tile,
  116. --lain.layout.centerwork,
  117. --lain.layout.centerwork.horizontal,
  118. --lain.layout.termfair,
  119. --lain.layout.termfair.center,
  120. }
  121. awful.util.taglist_buttons = awful.util.table.join(
  122. awful.button({ }, 1, function(t) t:view_only() end),
  123. awful.button({ modkey }, 1, function(t)
  124. if client.focus then
  125. client.focus:move_to_tag(t)
  126. end
  127. end),
  128. awful.button({ }, 3, awful.tag.viewtoggle),
  129. awful.button({ modkey }, 3, function(t)
  130. if client.focus then
  131. client.focus:toggle_tag(t)
  132. end
  133. end),
  134. awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
  135. awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
  136. )
  137. awful.util.tasklist_buttons = awful.util.table.join(
  138. awful.button({ }, 1, function (c)
  139. if c == client.focus then
  140. c.minimized = true
  141. else
  142. -- Without this, the following
  143. -- :isvisible() makes no sense
  144. c.minimized = false
  145. if not c:isvisible() and c.first_tag then
  146. c.first_tag:view_only()
  147. end
  148. -- This will also un-minimize
  149. -- the client, if needed
  150. client.focus = c
  151. c:raise()
  152. end
  153. end),
  154. awful.button({ }, 3, function()
  155. local instance = nil
  156.  
  157. return function ()
  158. if instance and instance.wibox.visible then
  159. instance:hide()
  160. instance = nil
  161. else
  162. instance = awful.menu.clients({ theme = { width = 250 } })
  163. end
  164. end
  165. end),
  166. awful.button({ }, 4, function ()
  167. awful.client.focus.byidx(1)
  168. end),
  169. awful.button({ }, 5, function ()
  170. awful.client.focus.byidx(-1)
  171. end))
  172.  
  173. lain.layout.termfair.nmaster = 3
  174. lain.layout.termfair.ncol = 1
  175. lain.layout.termfair.center.nmaster = 3
  176. lain.layout.termfair.center.ncol = 1
  177. lain.layout.cascade.tile.offset_x = 2
  178. lain.layout.cascade.tile.offset_y = 32
  179. lain.layout.cascade.tile.extra_padding = 5
  180. lain.layout.cascade.tile.nmaster = 5
  181. lain.layout.cascade.tile.ncol = 2
  182.  
  183. local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme)
  184. beautiful.init(theme_path)
  185. -- }}}
  186.  
  187. -- {{{ Menu
  188. local myawesomemenu = {
  189. { "hotkeys", function() return false, hotkeys_popup.show_help end },
  190. { "manual", terminal .. " -e man awesome" },
  191. { "edit config", string.format("%s -e %s %s", terminal, editor, awesome.conffile) },
  192. { "restart", awesome.restart },
  193. { "quit", function() awesome.quit() end }
  194. }
  195. awful.util.mymainmenu = freedesktop.menu.build({
  196. icon_size = beautiful.menu_height or 16,
  197. before = {
  198. { "Awesome", myawesomemenu, beautiful.awesome_icon },
  199. -- other triads can be put here
  200. },
  201. after = {
  202. { "Open terminal", terminal },
  203. -- other triads can be put here
  204. }
  205. })
  206. --menubar.utils.terminal = terminal -- Set the Menubar terminal for applications that require it
  207. -- }}}
  208.  
  209. -- {{{ Screen
  210. -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
  211. screen.connect_signal("property::geometry", function(s)
  212. -- Wallpaper
  213. if beautiful.wallpaper then
  214. local wallpaper = beautiful.wallpaper
  215. -- If wallpaper is a function, call it with the screen
  216. if type(wallpaper) == "function" then
  217. wallpaper = wallpaper(s)
  218. end
  219. gears.wallpaper.maximized(wallpaper, s, true)
  220. end
  221. end)
  222. -- Create a wibox for each screen and add it
  223. awful.screen.connect_for_each_screen(function(s) beautiful.at_screen_connect(s) end)
  224. -- }}}
  225.  
  226. -- {{{ Mouse bindings
  227. root.buttons(awful.util.table.join(
  228. awful.button({ }, 3, function () awful.util.mymainmenu:toggle() end),
  229. awful.button({ }, 4, awful.tag.viewnext),
  230. awful.button({ }, 5, awful.tag.viewprev)
  231. ))
  232. -- }}}
  233.  
  234. -- {{{ Key bindings
  235. globalkeys = awful.util.table.join(
  236. -- Take a screenshot
  237. -- https://github.com/lcpz/dots/blob/master/bin/screenshot
  238. awful.key({ modkey }, "p", function() os.execute("scrot ~/Descargas/%b%d::%H%M%S.png") end,
  239. {description = "take a screenshot", group = "hotkeys"}),
  240.  
  241. -- Hotkeys
  242. awful.key({ modkey, }, "s", hotkeys_popup.show_help,
  243. {description = "show help", group="awesome"}),
  244. -- Tag browsing
  245. awful.key({ modkey, }, "Left", awful.tag.viewprev,
  246. {description = "view previous", group = "tag"}),
  247. awful.key({ modkey, }, "Right", awful.tag.viewnext,
  248. {description = "view next", group = "tag"}),
  249. awful.key({ modkey, }, "Escape", awful.tag.history.restore,
  250. {description = "go back", group = "tag"}),
  251.  
  252. -- Non-empty tag browsing
  253. awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end,
  254. {description = "view previous nonempty", group = "tag"}),
  255. awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end,
  256. {description = "view previous nonempty", group = "tag"}),
  257.  
  258. -- Default client focus
  259. awful.key({ altkey, }, "j",
  260. function ()
  261. awful.client.focus.byidx( 1)
  262. end,
  263. {description = "focus next by index", group = "client"}
  264. ),
  265. awful.key({ altkey, }, "k",
  266. function ()
  267. awful.client.focus.byidx(-1)
  268. end,
  269. {description = "focus previous by index", group = "client"}
  270. ),
  271.  
  272. -- By direction client focus
  273. awful.key({ modkey }, "j",
  274. function()
  275. awful.client.focus.bydirection("down")
  276. if client.focus then client.focus:raise() end
  277. end,
  278. {description = "focus down", group = "client"}),
  279. awful.key({ modkey }, "k",
  280. function()
  281. awful.client.focus.bydirection("up")
  282. if client.focus then client.focus:raise() end
  283. end,
  284. {description = "focus up", group = "client"}),
  285. awful.key({ modkey }, "h",
  286. function()
  287. awful.client.focus.bydirection("left")
  288. if client.focus then client.focus:raise() end
  289. end,
  290. {description = "focus left", group = "client"}),
  291. awful.key({ modkey }, "l",
  292. function()
  293. awful.client.focus.bydirection("right")
  294. if client.focus then client.focus:raise() end
  295. end,
  296. {description = "focus right", group = "client"}),
  297. awful.key({ modkey, }, "w", function () awful.util.mymainmenu:show() end,
  298. {description = "show main menu", group = "awesome"}),
  299.  
  300. -- Layout manipulation
  301. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
  302. {description = "swap with next client by index", group = "client"}),
  303. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
  304. {description = "swap with previous client by index", group = "client"}),
  305. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
  306. {description = "focus the next screen", group = "screen"}),
  307. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
  308. {description = "focus the previous screen", group = "screen"}),
  309. awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
  310. {description = "jump to urgent client", group = "client"}),
  311. awful.key({ modkey, }, "Tab",
  312. function ()
  313. awful.client.focus.history.previous()
  314. if client.focus then
  315. client.focus:raise()
  316. end
  317. end,
  318. {description = "go back", group = "client"}),
  319.  
  320. -- Show/Hide Wibox
  321. awful.key({ modkey }, "b", function ()
  322. for s in screen do
  323. s.mywibox.visible = not s.mywibox.visible
  324. if s.mybottomwibox then
  325. s.mybottomwibox.visible = not s.mybottomwibox.visible
  326. end
  327. end
  328. end,
  329. {description = "toggle wibox", group = "awesome"}),
  330.  
  331. -- On the fly useless gaps change
  332. awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end,
  333. {description = "increment useless gaps", group = "tag"}),
  334. awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end,
  335. {description = "decrement useless gaps", group = "tag"}),
  336.  
  337. -- Dynamic tagging
  338. awful.key({ modkey, "Shift" }, "n", function () lain.util.add_tag() end,
  339. {description = "add new tag", group = "tag"}),
  340. awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag() end,
  341. {description = "rename tag", group = "tag"}),
  342. awful.key({ modkey, "Shift" }, "Left", function () lain.util.move_tag(-1) end,
  343. {description = "move tag to the left", group = "tag"}),
  344. awful.key({ modkey, "Shift" }, "Right", function () lain.util.move_tag(1) end,
  345. {description = "move tag to the right", group = "tag"}),
  346. awful.key({ modkey, "Shift" }, "d", function () lain.util.delete_tag() end,
  347. {description = "delete tag", group = "tag"}),
  348.  
  349. -- Standard program
  350. awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
  351. {description = "open a terminal", group = "launcher"}),
  352. awful.key({ modkey, "Control" }, "r", awesome.restart,
  353. {description = "reload awesome", group = "awesome"}),
  354. awful.key({ modkey, "Shift" }, "q", awesome.quit,
  355. {description = "quit awesome", group = "awesome"}),
  356.  
  357. awful.key({ modkey, }, "F2", function () awful.spawn(gmrun) end,
  358. {description = "open gmrun", group = "launcher"}),
  359. awful.key({ modkey, "Control"}, "l", function () awful.spawn("xtrlock") end,
  360. {description = "lock xtrlock", group = "launcher"}),
  361.  
  362. awful.key({ altkey, "Shift" }, "l", function () awful.tag.incmwfact( 0.05) end,
  363. {description = "increase master width factor", group = "layout"}),
  364. awful.key({ altkey, "Shift" }, "h", function () awful.tag.incmwfact(-0.05) end,
  365. {description = "decrease master width factor", group = "layout"}),
  366. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
  367. {description = "increase the number of master clients", group = "layout"}),
  368. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
  369. {description = "decrease the number of master clients", group = "layout"}),
  370. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
  371. {description = "increase the number of columns", group = "layout"}),
  372. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
  373. {description = "decrease the number of columns", group = "layout"}),
  374. awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
  375. {description = "select next", group = "layout"}),
  376. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
  377. {description = "select previous", group = "layout"}),
  378.  
  379. awful.key({ modkey, "Control" }, "n",
  380. function ()
  381. local c = awful.client.restore()
  382. -- Focus restored client
  383. if c then
  384. client.focus = c
  385. c:raise()
  386. end
  387. end,
  388. {description = "restore minimized", group = "client"}),
  389.  
  390. -- Dropdown application
  391. awful.key({ modkey, }, "z", function () awful.screen.focused().quake:toggle() end,
  392. {description = "dropdown application", group = "launcher"}),
  393.  
  394. -- Widgets popups
  395. awful.key({ altkey, }, "c", function () lain.widget.calendar.show(7) end,
  396. {description = "show calendar", group = "widgets"}),
  397. awful.key({ altkey, }, "h", function () if beautiful.fs then beautiful.fs.show(7) end end,
  398. {description = "show filesystem", group = "widgets"}),
  399. awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end,
  400. {description = "show weather", group = "widgets"}),
  401.  
  402. -- Brightness
  403. awful.key({ }, "XF86MonBrightnessUp", function () awful.util.spawn("xbacklight -inc 10") end,
  404. {description = "+10%", group = "hotkeys"}),
  405. awful.key({ }, "XF86MonBrightnessDown", function () awful.util.spawn("xbacklight -dec 10") end,
  406. {description = "-10%", group = "hotkeys"}),
  407.  
  408. -- ALSA volume control
  409. -- awful.key({ altkey }, "Up",
  410. awful.key({ modkey }, "Up",
  411. function ()
  412. os.execute(string.format("amixer -q set %s 1%%+", beautiful.volume.channel))
  413. beautiful.volume.update()
  414. end,
  415. {description = "volume up", group = "hotkeys"}),
  416. awful.key({ modkey }, "Down",
  417. function ()
  418. os.execute(string.format("amixer -q set %s 1%%-", beautiful.volume.channel))
  419. beautiful.volume.update()
  420. end,
  421. {description = "volume down", group = "hotkeys"}),
  422. awful.key({ altkey }, "m",
  423. function ()
  424. os.execute(string.format("amixer -q set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel))
  425. beautiful.volume.update()
  426. end,
  427. {description = "toggle mute", group = "hotkeys"}),
  428. awful.key({ altkey, "Control" }, "m",
  429. function ()
  430. os.execute(string.format("amixer -q set %s 100%%", beautiful.volume.channel))
  431. beautiful.volume.update()
  432. end,
  433. {description = "volume 100%", group = "hotkeys"}),
  434. awful.key({ altkey, "Control" }, "0",
  435. function ()
  436. os.execute(string.format("amixer -q set %s 0%%", beautiful.volume.channel))
  437. beautiful.volume.update()
  438. end,
  439. {description = "volume 0%", group = "hotkeys"}),
  440.  
  441. -- MPD control
  442. awful.key({ altkey, "Control" }, "Up",
  443. function ()
  444. awful.spawn.with_shell("mpc toggle")
  445. beautiful.mpd.update()
  446. end,
  447. {description = "mpc toggle", group = "widgets"}),
  448. awful.key({ altkey, "Control" }, "Down",
  449. function ()
  450. awful.spawn.with_shell("mpc stop")
  451. beautiful.mpd.update()
  452. end,
  453. {description = "mpc stop", group = "widgets"}),
  454. awful.key({ altkey, "Control" }, "Left",
  455. function ()
  456. awful.spawn.with_shell("mpc prev")
  457. beautiful.mpd.update()
  458. end,
  459. {description = "mpc prev", group = "widgets"}),
  460. awful.key({ altkey, "Control" }, "Right",
  461. function ()
  462. awful.spawn.with_shell("mpc next")
  463. beautiful.mpd.update()
  464. end,
  465. {description = "mpc next", group = "widgets"}),
  466. awful.key({ altkey }, "0",
  467. function ()
  468. local common = { text = "MPD widget ", position = "top_middle", timeout = 2 }
  469. if beautiful.mpd.timer.started then
  470. beautiful.mpd.timer:stop()
  471. common.text = common.text .. lain.util.markup.bold("OFF")
  472. else
  473. beautiful.mpd.timer:start()
  474. common.text = common.text .. lain.util.markup.bold("ON")
  475. end
  476. naughty.notify(common)
  477. end,
  478. {description = "mpc on/off", group = "widgets"}),
  479.  
  480. -- Copy primary to clipboard (terminals to gtk)
  481. awful.key({ modkey }, "c", function () awful.spawn("xsel | xsel -i -b") end,
  482. {description = "copy terminal to gtk", group = "hotkeys"}),
  483. -- Copy clipboard to primary (gtk to terminals)
  484. awful.key({ modkey }, "v", function () awful.spawn("xsel -b | xsel") end,
  485. {description = "copy gtk to terminal", group = "hotkeys"}),
  486.  
  487. -- User programs
  488. awful.key({ modkey }, "q", function () awful.spawn(browser) end,
  489. {description = "run browser", group = "launcher"}),
  490. awful.key({ modkey }, "a", function () awful.spawn(guieditor) end,
  491. {description = "run gui editor", group = "launcher"}),
  492.  
  493. -- Default
  494. --[[ Menubar
  495. awful.key({ modkey }, "p", function() menubar.show() end,
  496. {description = "show the menubar", group = "launcher"})
  497. --]]
  498. --[[ dmenu
  499. awful.key({ modkey }, "x", function ()
  500. awful.spawn(string.format("dmenu_run -i -fn 'Monospace' -nb '%s' -nf '%s' -sb '%s' -sf '%s'",
  501. beautiful.bg_normal, beautiful.fg_normal, beautiful.bg_focus, beautiful.fg_focus))
  502. end,
  503. {description = "show dmenu", group = "launcher"})
  504. --]]
  505. -- Prompt
  506. awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
  507. {description = "run prompt", group = "launcher"}),
  508.  
  509. awful.key({ modkey }, "x",
  510. function ()
  511. awful.prompt.run {
  512. prompt = "Run Lua code: ",
  513. textbox = awful.screen.focused().mypromptbox.widget,
  514. exe_callback = awful.util.eval,
  515. history_path = awful.util.get_cache_dir() .. "/history_eval"
  516. }
  517. end,
  518. {description = "lua execute prompt", group = "awesome"})
  519. --]]
  520. )
  521.  
  522. clientkeys = awful.util.table.join(
  523. awful.key({ altkey, "Shift" }, "m", lain.util.magnify_client,
  524. {description = "magnify client", group = "client"}),
  525. awful.key({ modkey, }, "f",
  526. function (c)
  527. c.fullscreen = not c.fullscreen
  528. c:raise()
  529. end,
  530. {description = "toggle fullscreen", group = "client"}),
  531. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
  532. {description = "close", group = "client"}),
  533. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
  534. {description = "toggle floating", group = "client"}),
  535. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
  536. {description = "move to master", group = "client"}),
  537. awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
  538. {description = "move to screen", group = "client"}),
  539. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
  540. {description = "toggle keep on top", group = "client"}),
  541. awful.key({ modkey, }, "n",
  542. function (c)
  543. -- The client currently has the input focus, so it cannot be
  544. -- minimized, since minimized clients can't have the focus.
  545. c.minimized = true
  546. end ,
  547. {description = "minimize", group = "client"}),
  548. awful.key({ modkey, }, "m",
  549. function (c)
  550. c.maximized = not c.maximized
  551. c:raise()
  552. end ,
  553. {description = "maximize", group = "client"})
  554. )
  555.  
  556. -- Bind all key numbers to tags.
  557. -- Be careful: we use keycodes to make it works on any keyboard layout.
  558. -- This should map on the top row of your keyboard, usually 1 to 9.
  559. for i = 1, 9 do
  560. -- Hack to only show tags 1 and 9 in the shortcut window (mod+s)
  561. local descr_view, descr_toggle, descr_move, descr_toggle_focus
  562. if i == 1 or i == 9 then
  563. descr_view = {description = "view tag #", group = "tag"}
  564. descr_toggle = {description = "toggle tag #", group = "tag"}
  565. descr_move = {description = "move focused client to tag #", group = "tag"}
  566. descr_toggle_focus = {description = "toggle focused client on tag #", group = "tag"}
  567. end
  568. globalkeys = awful.util.table.join(globalkeys,
  569. -- View tag only.
  570. awful.key({ modkey }, "#" .. i + 9,
  571. function ()
  572. local screen = awful.screen.focused()
  573. local tag = screen.tags[i]
  574. if tag then
  575. tag:view_only()
  576. end
  577. end,
  578. descr_view),
  579. -- Toggle tag display.
  580. awful.key({ modkey, "Control" }, "#" .. i + 9,
  581. function ()
  582. local screen = awful.screen.focused()
  583. local tag = screen.tags[i]
  584. if tag then
  585. awful.tag.viewtoggle(tag)
  586. end
  587. end,
  588. descr_toggle),
  589. -- Move client to tag.
  590. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  591. function ()
  592. if client.focus then
  593. local tag = client.focus.screen.tags[i]
  594. if tag then
  595. client.focus:move_to_tag(tag)
  596. end
  597. end
  598. end,
  599. descr_move),
  600. -- Toggle tag on focused client.
  601. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  602. function ()
  603. if client.focus then
  604. local tag = client.focus.screen.tags[i]
  605. if tag then
  606. client.focus:toggle_tag(tag)
  607. end
  608. end
  609. end,
  610. descr_toggle_focus)
  611. )
  612. end
  613.  
  614. clientbuttons = awful.util.table.join(
  615. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  616. awful.button({ modkey }, 1, awful.mouse.client.move),
  617. awful.button({ modkey }, 3, awful.mouse.client.resize))
  618.  
  619. -- Set keys
  620. root.keys(globalkeys)
  621. -- }}}
  622.  
  623. -- {{{ Rules
  624. -- Rules to apply to new clients (through the "manage" signal).
  625. awful.rules.rules = {
  626. -- All clients will match this rule.
  627. { rule = { },
  628. properties = { border_width = beautiful.border_width,
  629. border_color = beautiful.border_normal,
  630. focus = awful.client.focus.filter,
  631. raise = true,
  632. keys = clientkeys,
  633. buttons = clientbuttons,
  634. screen = awful.screen.preferred,
  635. placement = awful.placement.no_overlap+awful.placement.no_offscreen,
  636. size_hints_honor = false
  637. }
  638. },
  639.  
  640. -- Titlebars
  641. { rule_any = { type = { "dialog", "normal" } },
  642. properties = { titlebars_enabled = true } },
  643.  
  644. -- Set Firefox to always map on the first tag on screen 1.
  645. { rule = { class = "Firefox" },
  646. properties = { screen = 1, tag = awful.util.tagnames[1] } },
  647.  
  648. { rule = { class = "Gimp", role = "gimp-image-window" },
  649. properties = { maximized = true } },
  650. }
  651. -- }}}
  652.  
  653. -- {{{ Signals
  654. -- Signal function to execute when a new client appears.
  655. client.connect_signal("manage", function (c)
  656. -- Set the windows at the slave,
  657. -- i.e. put it at the end of others instead of setting it master.
  658. -- if not awesome.startup then awful.client.setslave(c) end
  659.  
  660. if awesome.startup and
  661. not c.size_hints.user_position
  662. and not c.size_hints.program_position then
  663. -- Prevent clients from being unreachable after screen count changes.
  664. awful.placement.no_offscreen(c)
  665. end
  666. end)
  667.  
  668. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  669. client.connect_signal("request::titlebars", function(c)
  670. -- Custom
  671. if beautiful.titlebar_fun then
  672. beautiful.titlebar_fun(c)
  673. return
  674. end
  675.  
  676. -- Default
  677. -- buttons for the titlebar
  678. local buttons = awful.util.table.join(
  679. awful.button({ }, 1, function()
  680. client.focus = c
  681. c:raise()
  682. awful.mouse.client.move(c)
  683. end),
  684. awful.button({ }, 3, function()
  685. client.focus = c
  686. c:raise()
  687. awful.mouse.client.resize(c)
  688. end)
  689. )
  690.  
  691. awful.titlebar(c, {size = 16}) : setup {
  692. { -- Left
  693. awful.titlebar.widget.iconwidget(c),
  694. buttons = buttons,
  695. layout = wibox.layout.fixed.horizontal
  696. },
  697. { -- Middle
  698. { -- Title
  699. align = "center",
  700. widget = awful.titlebar.widget.titlewidget(c)
  701. },
  702. buttons = buttons,
  703. layout = wibox.layout.flex.horizontal
  704. },
  705. { -- Right
  706. awful.titlebar.widget.floatingbutton (c),
  707. awful.titlebar.widget.maximizedbutton(c),
  708. awful.titlebar.widget.stickybutton (c),
  709. awful.titlebar.widget.ontopbutton (c),
  710. awful.titlebar.widget.closebutton (c),
  711. layout = wibox.layout.fixed.horizontal()
  712. },
  713. layout = wibox.layout.align.horizontal
  714. }
  715. end)
  716.  
  717. -- Enable sloppy focus, so that focus follows mouse.
  718. client.connect_signal("mouse::enter", function(c)
  719. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  720. and awful.client.focus.filter(c) then
  721. client.focus = c
  722. end
  723. end)
  724.  
  725. -- No border for maximized clients
  726. client.connect_signal("focus",
  727. function(c)
  728. if c.maximized then -- no borders if only 1 client visible
  729. c.border_width = 0
  730. elseif #awful.screen.focused().clients > 1 then
  731. c.border_width = beautiful.border_width
  732. c.border_color = beautiful.border_focus
  733. end
  734. end)
  735. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  736. -- }}}
  737. --
  738. do
  739. local cmdsx =
  740. {
  741. "/home/miusuario/inicio.sh"
  742. }
  743. for _,i in pairs(cmdsx) do
  744. awful.util.spawn(i)
  745. end
  746. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement