unixwz0r

rc.lua

Dec 24th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.82 KB | None | 0 0
  1. --[[
  2.  
  3. Tux Hat Linux Config
  4.  
  5. --]]
  6.  
  7. -- {{{ Required libraries
  8. local gears = require("gears")
  9. local awful = require("awful")
  10. awful.rules = require("awful.rules")
  11. require("awful.autofocus")
  12. local wibox = require("wibox")
  13. local beautiful = require("beautiful")
  14. local naughty = require("naughty")
  15. local menubar = require("menubar")
  16. local vicious = require("vicious")
  17. local drop = require("scratchdrop")
  18. local lain = require("lain")
  19. -- }}}
  20.  
  21. -- {{{ Error handling
  22. if awesome.startup_errors then
  23. naughty.notify({ preset = naughty.config.presets.critical,
  24. title = "Oops, there were errors during startup!",
  25. text = awesome.startup_errors })
  26. end
  27.  
  28. do
  29. local in_error = false
  30. awesome.connect_signal("debug::error", function (err)
  31. if in_error then return end
  32. in_error = true
  33.  
  34. naughty.notify({ preset = naughty.config.presets.critical,
  35. title = "Oops, an error happened!",
  36. text = err })
  37. in_error = false
  38. end)
  39. end
  40. -- }}}
  41.  
  42.  
  43.  
  44. -- {{{ Variable definitions
  45. -- Themes define colours, icons, font and wallpapers.
  46. beautiful.init("/home/arch/.config/awesome/themes/tuxhat/theme.lua")
  47.  
  48. -- This is used later as the default terminal and editor to run.
  49. terminal = "urxvt -e bash"
  50. weechat = "urxvt -e weechat"
  51. mc = "urxvt -e mc"
  52. tmux = "urxvt -e tmux"
  53. firefox = "firefox"
  54. geany = "geany"
  55. filemgr = "spacefm"
  56. openshot = "openshot"
  57. lxappearance = "lxappearance"
  58. nitrogen = "nitrogen"
  59. gimp = "gimp"
  60. smplayer = "smplayer"
  61. top = "urxvt -e top"
  62. VIM = "urxvt -e vim"
  63. fileroller = "file-roller"
  64. gmail = "firefox www.gmail.com"
  65. youtube = "firefox www.youtube.com"
  66. lxmusic = "lxmusic"
  67. GParted = "gksu gparted"
  68. virtualbox = "VirtualBox"
  69. guvcview = "guvcview"
  70. steam = "steam"
  71.  
  72. editor = os.getenv("EDITOR") or "nano"
  73. editor_cmd = terminal .. " -e " .. editor
  74.  
  75. -- Default modkey.
  76. -- Usually, Mod4 is the key with a logo between Control and Alt.
  77. -- If you do not like this or do not have such a key,
  78. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  79. -- However, you can use another modifier like Mod1, but it may interact with others.
  80. modkey = "Mod4"
  81.  
  82. -- Table of layouts to cover with awful.layout.inc, order matters.
  83. local layouts =
  84. {
  85. awful.layout.suit.floating,
  86. awful.layout.suit.tile,
  87. awful.layout.suit.tile.left,
  88. awful.layout.suit.tile.bottom,
  89. awful.layout.suit.tile.top,
  90. awful.layout.suit.fair,
  91. awful.layout.suit.fair.horizontal,
  92. awful.layout.suit.spiral,
  93. awful.layout.suit.spiral.dwindle,
  94. awful.layout.suit.max,
  95. awful.layout.suit.max.fullscreen,
  96. awful.layout.suit.magnifier
  97. }
  98. -- }}}
  99.  
  100. -- {{{ Wallpaper
  101. if beautiful.wallpaper then
  102. for s = 1, screen.count() do
  103. gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  104. end
  105. end
  106. -- }}}
  107.  
  108. -- {{{ Tags
  109. -- Define a tag table which will hold all screen tags.
  110. tags = {
  111. names = { "main", "net", "irc", "term", "edit", "fm", "vm", "media", "xmms2", "steam" },
  112. layout = { layouts[1], layouts[1], layouts[1], layouts[1], layouts[1],
  113. layouts[1], layouts[1], layouts[1], layouts[1], layouts[1]
  114. }}
  115. for s = 1, screen.count() do
  116. -- Each screen has its own tag table.
  117. tags[s] = awful.tag(tags.names, s, tags.layout)
  118. end
  119. -- }}}
  120.  
  121. -- {{{ Menu
  122. -- Create a laucher widget and a main menu
  123. myawesomemenu = {
  124. { "manual", terminal .. " -e man awesome" },
  125. { "edit config", editor_cmd .. " " .. awesome.conffile },
  126. { "restart", awesome.restart },
  127. { "quit", awesome.quit }
  128. }
  129. -- Icons for the Menu
  130. image0 = "/home/arch/.config/awesome/themes/tuxhat/awesome-icon.png"
  131. image1 = "/home/arch/.config/awesome/themes/tuxhat/term.png"
  132. image2 = "/home/arch/.config/awesome/themes/tuxhat/defcon.png"
  133. image3 = "/home/arch/.config/awesome/themes/tuxhat/file-manager.png"
  134. image4 = "/home/arch/.config/awesome/themes/tuxhat/geany.png"
  135. image5 = "/home/arch/.config/awesome/themes/tuxhat/firefox2.png"
  136. image6 = "/home/arch/.config/awesome/themes/tuxhat/mplayer.png"
  137. image7 = "/home/arch/.config/awesome/themes/tuxhat/openshot.png"
  138. image8 = "/home/arch/.config/awesome/themes/tuxhat/gimp.png"
  139. image9 = "/home/arch/.config/awesome/themes/tuxhat/htop.png"
  140. image10 = "/home/arch/.config/awesome/themes/tuxhat/vim.png"
  141. image11 = "/home/arch/.config/awesome/themes/tuxhat/gmail.png"
  142. image12 = "/home/arch/.config/awesome/themes/tuxhat/minitube.png"
  143. image13 = "/home/arch/.config/awesome/themes/tuxhat/lxappearance.png"
  144. image14 = "/home/arch/.config/awesome/themes/tuxhat/nitrogen.png"
  145. image15 = "/home/arch/.config/awesome/themes/tuxhat/file-roller.png"
  146. image16 = "/home/arch/.config/awesome/themes/tuxhat/lxmusic.png"
  147. image17 = "/home/arch/.config/awesome/themes/tuxhat/disk.png"
  148. image18 = "/home/arch/.config/awesome/themes/tuxhat/virtualbox.png"
  149. image19 = "/home/arch/.config/awesome/themes/tuxhat/camera.png"
  150.  
  151.  
  152. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, image0 },
  153. { "VirtualBox", virtualbox, image18 },
  154. { "URXVT Bash $", terminal, image1 },
  155. { "WeeChat", weechat, image2 },
  156. { "Top", top, image9 },
  157. { "GParted", GParted, image17 },
  158. { "FileMgr", filemgr, image3 },
  159. { "File-Roller", fileroller, image15 },
  160. { "Geany", geany, image4 },
  161. { "Vim", VIM, image10 },
  162. { "Firefox", firefox, image5 },
  163. { "LXMusic", lxmusic, image16 },
  164. { "SMplayer", smplayer, image6 },
  165. { "Video Camera", guvcview, image19 },
  166. { "Openshot", openshot, image7 },
  167. { "Gimp", gimp, image8 },
  168. { "LXappearance", lxappearance, image13 },
  169. { "Nitrogen", nitrogen, image14 },
  170. { "GMail", gmail, image11 },
  171. { "Youtube", youtube, image12 },
  172.  
  173.  
  174. }
  175. })
  176.  
  177. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  178. menu = mymainmenu })
  179.  
  180. -- Menubar configuration
  181. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  182. -- }}}
  183.  
  184. -- {{{ Wibox
  185. -- Create a textclock widget
  186. markup = lain.util.markup
  187.  
  188. -- Textclock
  189. clockicon = wibox.widget.imagebox(beautiful.widget_clock)
  190. mytextclock = awful.widget.textclock(markup("#f0dfaf", "| ") .. markup("#ffffff", "%A %d %B ") .. markup("#f0dfaf", "|") .. markup("#ffffff", " %H:%M "))
  191.  
  192. -- XMMS2 Now playing
  193. --xmms2 = wibox.widget.textbox()
  194. --xmms2:set_align("left")
  195. --function xmms2_s(widget)
  196. -- local status = io.popen('xmms2 current'):read("*all")
  197. -- -- local status = io.popen('deadbeef --nowplaying "°|%e-%l|°|%a - %t|°"'):read("*all")
  198. -- local color = "#f0dfaf"
  199. -- xmms2:set_markup("<span color=\"" .. color .. "\">" .. status .. "</span>")
  200. --end
  201. --xmms2_s(xmms2)
  202. --mytimer = timer({ timeout = 1 })
  203. --mytimer:connect_signal("timeout", function () xmms2_s(xmms2) end)
  204. --mytimer:start()
  205.  
  206. -- CPU
  207. cpuicon = wibox.widget.imagebox()
  208. cpuicon:set_image(beautiful.widget_cpu)
  209. cpuwidget = lain.widgets.cpu({
  210. settings = function()
  211. widget:set_markup(markup("#ffffff", cpu_now.usage .. "% "))
  212. end
  213. })
  214.  
  215. -- Net
  216. netdownicon = wibox.widget.imagebox(beautiful.widget_netdown)
  217. --netdownicon.align = "middle"
  218. netdowninfo = wibox.widget.textbox()
  219. netupicon = wibox.widget.imagebox(beautiful.widget_netup)
  220. --netupicon.align = "middle"
  221. netupinfo = lain.widgets.net({
  222. settings = function()
  223.  
  224. widget:set_markup(markup("#e54c62", net_now.sent .. " "))
  225. netdowninfo:set_markup(markup("#87af5f", net_now.received .. " "))
  226. end
  227. })
  228.  
  229. -- Uptime
  230. uptimewidget = wibox.widget.textbox()
  231. vicious.register(uptimewidget, vicious.widgets.uptime,
  232. function (widget, args)
  233. return string.format(markup ("#ffffff", "Uptime:%2dd %02d:%02d "), args[1], args[2], args[3])
  234. end, 61)
  235.  
  236.  
  237. -- MEM
  238. memicon = wibox.widget.imagebox(beautiful.widget_mem)
  239. memwidget = lain.widgets.mem({
  240. settings = function()
  241. widget:set_markup(markup("#ffffff", mem_now.used .. "M "))
  242. end
  243. })
  244.  
  245.  
  246. -- OS Widget
  247. oswidget = wibox.widget.textbox()
  248. vicious.register(oswidget, vicious.widgets.os, (markup("#f0dfaf", "Sysinfo:") ..markup("#5f5740", " $2")))
  249.  
  250. -- USER Widget
  251. userwidget = wibox.widget.textbox()
  252. vicious.register(userwidget, vicious.widgets.os, (markup("#f0dfaf", "Username:") ..markup("#5f5740", " $3")))
  253.  
  254. -- Host Widget
  255. hostwidget = wibox.widget.textbox()
  256. vicious.register(hostwidget, vicious.widgets.os, (markup("#f0dfaf", "Hostname:") ..markup("#5f5740", " $4")))
  257.  
  258. -- File System
  259. fswidget = wibox.widget.textbox()
  260. vicious.register(fswidget, vicious.widgets.fs, (markup("#f0dfaf", "File System:") ..markup("#e54c62", " ${/ used_gb} GB") ..markup("#f0dfaf", " of") ..markup("#87af5f", " ${/ size_gb} GB")))
  261.  
  262. -- Disk I/O
  263. diowidget = wibox.widget.textbox()
  264. vicious.register(diowidget, vicious.widgets.dio, (markup("#f0dfaf", "Disk I/O:") ..markup("#87af5f", " Read: ${sda read_mb} MB") ..markup("#f0dfaf", " /") ..markup("#e54c62", " Write: ${sda write_mb} MB")))
  265.  
  266. -- Spacer
  267. spacer = wibox.widget.textbox(" ")
  268. spacer2 = wibox.widget.textbox(markup ("#f0dfaf", " | "))
  269.  
  270. -- }}}
  271.  
  272. -- Create a wibox for each screen and add it
  273. mywibox = {}
  274. mybottomwibox = {}
  275. mypromptbox = {}
  276. mylayoutbox = {}
  277. mytaglist = {}
  278. mytaglist.buttons = awful.util.table.join(
  279. awful.button({ }, 1, awful.tag.viewonly),
  280. awful.button({ modkey }, 1, awful.client.movetotag),
  281. awful.button({ }, 3, awful.tag.viewtoggle),
  282. awful.button({ modkey }, 3, awful.client.toggletag),
  283. awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  284. awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  285. )
  286. mytasklist = {}
  287. mytasklist.buttons = awful.util.table.join(
  288. awful.button({ }, 1, function (c)
  289. if c == client.focus then
  290. c.minimized = true
  291. else
  292. -- Without this, the following
  293. -- :isvisible() makes no sense
  294. c.minimized = false
  295. if not c:isvisible() then
  296. awful.tag.viewonly(c:tags()[1])
  297. end
  298. -- This will also un-minimize
  299. -- the client, if needed
  300. client.focus = c
  301. c:raise()
  302. end
  303. end),
  304. awful.button({ }, 3, function ()
  305. if instance then
  306. instance:hide()
  307. instance = nil
  308. else
  309. instance = awful.menu.clients({
  310. theme = { width = 250 }
  311. })
  312. end
  313. end),
  314. awful.button({ }, 4, function ()
  315. awful.client.focus.byidx(1)
  316. if client.focus then client.focus:raise() end
  317. end),
  318. awful.button({ }, 5, function ()
  319. awful.client.focus.byidx(-1)
  320. if client.focus then client.focus:raise() end
  321. end))
  322.  
  323. for s = 1, screen.count() do
  324. -- Create a promptbox for each screen
  325. mypromptbox[s] = awful.widget.prompt()
  326. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  327. -- We need one layoutbox per screen.
  328. mylayoutbox[s] = awful.widget.layoutbox(s)
  329. mylayoutbox[s]:buttons(awful.util.table.join(
  330. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  331. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  332. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  333. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  334. -- Create a taglist widget
  335. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  336.  
  337. -- Create a tasklist widget
  338. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  339.  
  340. -- Create the wibox
  341. mywibox[s] = awful.wibox({ position = "top", screen = s })
  342.  
  343. -- Widgets that are aligned to the left
  344. local left_layout = wibox.layout.fixed.horizontal()
  345. left_layout:add(mylauncher)
  346. left_layout:add(mytaglist[s])
  347. left_layout:add(spacer2)
  348. left_layout:add(mypromptbox[s])
  349.  
  350. -- Widgets that are aligned to the right
  351. local right_layout = wibox.layout.fixed.horizontal()
  352. right_layout:add(spacer2)
  353. if s == 1 then right_layout:add(wibox.widget.systray()) end
  354. right_layout:add(spacer2)
  355. right_layout:add(mylayoutbox[s])
  356.  
  357. -- Now bring it all together (with the tasklist in the middle)
  358. local layout = wibox.layout.align.horizontal()
  359. layout:set_left(left_layout)
  360. layout:set_middle(mytasklist[s])
  361. layout:set_right(right_layout)
  362.  
  363. mywibox[s]:set_widget(layout)
  364.  
  365. -- Create the bottom wibox
  366. mybottomwibox[s] = awful.wibox({ position = "bottom", screen = s, border_width = 0, height = 20 })
  367. --mybottomwibox[s].visible = false
  368.  
  369. -- Widgets that are aligned to the bottom left
  370. bottom_left_layout = wibox.layout.fixed.horizontal()
  371. bottom_left_layout:add(userwidget)
  372. bottom_left_layout:add(spacer2)
  373. bottom_left_layout:add(hostwidget)
  374. bottom_left_layout:add(spacer2)
  375. bottom_left_layout:add(oswidget)
  376. bottom_left_layout:add(spacer2)
  377. bottom_left_layout:add(fswidget)
  378. bottom_left_layout:add(spacer2)
  379. bottom_left_layout:add(diowidget)
  380. -- Widgets that are aligned to the bottom right
  381. bottom_right_layout = wibox.layout.fixed.horizontal()
  382. bottom_right_layout:add(spacer2)
  383. bottom_right_layout:add(netdownicon)
  384. bottom_right_layout:add(netdowninfo)
  385. bottom_right_layout:add(netupicon)
  386. bottom_right_layout:add(netupinfo)
  387. bottom_right_layout:add(memicon)
  388. bottom_right_layout:add(memwidget)
  389. bottom_right_layout:add(cpuicon)
  390. bottom_right_layout:add(cpuwidget)
  391. bottom_right_layout:add(clockicon)
  392. bottom_right_layout:add(uptimewidget)
  393. bottom_right_layout:add(mytextclock)
  394.  
  395. -- Now bring it all together (with the tasklist in the middle)
  396. bottom_layout = wibox.layout.align.horizontal()
  397. bottom_layout:set_left(bottom_left_layout)
  398. --bottom_layout:set_middle(mytasklist[s])
  399. bottom_layout:set_right(bottom_right_layout)
  400. mybottomwibox[s]:set_widget(bottom_layout)
  401.  
  402. end
  403. -- }}}
  404.  
  405. -- {{{ Mouse bindings
  406. root.buttons(awful.util.table.join(
  407. awful.button({ }, 3, function () mymainmenu:toggle() end),
  408. awful.button({ }, 4, awful.tag.viewnext),
  409. awful.button({ }, 5, awful.tag.viewprev)
  410. ))
  411. -- }}}
  412.  
  413. -- {{{ Key bindings
  414. globalkeys = awful.util.table.join(
  415. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  416. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  417. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  418.  
  419. awful.key({ modkey, }, "j",
  420. function ()
  421. awful.client.focus.byidx( 1)
  422. if client.focus then client.focus:raise() end
  423. end),
  424. awful.key({ modkey, }, "k",
  425. function ()
  426. awful.client.focus.byidx(-1)
  427. if client.focus then client.focus:raise() end
  428. end),
  429. awful.key({ modkey, "Control" }, "space", function () mymainmenu:show() end),
  430.  
  431. -- Layout manipulation
  432. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  433. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  434. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  435. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  436. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  437. awful.key({ modkey, }, "Tab",
  438. function ()
  439. awful.client.focus.history.previous()
  440. if client.focus then
  441. client.focus:raise()
  442. end
  443. end),
  444.  
  445. -- Standard program
  446. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  447. awful.key({ modkey, "Control" }, "r", awesome.restart),
  448. awful.key({ modkey, }, "q", awesome.quit),
  449.  
  450. awful.key({ modkey, "Control" }, "l", function () awful.tag.incmwfact( 0.05) end),
  451. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  452. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  453. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  454. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  455. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  456. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  457. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  458.  
  459. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  460.  
  461. -- My Key bindings
  462. awful.key({ modkey, }, "t", function () awful.util.spawn(terminal) end),
  463. awful.key({ modkey, }, "f", function () awful.util.spawn(filemgr) end),
  464. awful.key({ modkey, }, "i", function () awful.util.spawn(weechat) end),
  465. awful.key({ modkey, }, "e", function () awful.util.spawn(geany) end),
  466. awful.key({ modkey, }, "g", function () awful.util.spawn(gimp) end),
  467. awful.key({ modkey, }, "w", function () awful.util.spawn(firefox) end),
  468. awful.key({ modkey, }, "l", function () awful.util.spawn(lxappearance) end),
  469. awful.key({ modkey, }, "n", function () awful.util.spawn(nitrogen) end),
  470. awful.key({ modkey, }, "a", function () awful.util.spawn(lxmusic) end),
  471. awful.key({ modkey, }, "o", function () awful.util.spawn(openshot) end),
  472. awful.key({ modkey, }, "s", function () awful.util.spawn(steam) end),
  473. -- Prompt
  474. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  475.  
  476. awful.key({ modkey }, "x",
  477. function ()
  478. awful.prompt.run({ prompt = "Run Lua code: " },
  479. mypromptbox[mouse.screen].widget,
  480. awful.util.eval, nil,
  481. awful.util.getdir("cache") .. "/history_eval")
  482. end),
  483. -- Menubar
  484. awful.key({ modkey }, "p", function() menubar.show() end)
  485. )
  486.  
  487. clientkeys = awful.util.table.join(
  488. awful.key({ modkey, }, "z", function (c) c.fullscreen = not c.fullscreen end),
  489. awful.key({ modkey, }, "c", function (c) c:kill() end),
  490. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  491. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  492. awful.key({ modkey, "Control" }, "o", awful.client.movetoscreen ),
  493. awful.key({ modkey, "Control" }, "t", function (c) c.ontop = not c.ontop end),
  494. awful.key({ modkey, "Control" }, "n",
  495. function (c)
  496. -- The client currently has the input focus, so it cannot be
  497. -- minimized, since minimized clients can't have the focus.
  498. c.minimized = true
  499. end),
  500. awful.key({ modkey, }, "m",
  501. function (c)
  502. c.maximized_horizontal = not c.maximized_horizontal
  503. c.maximized_vertical = not c.maximized_vertical
  504. end)
  505. )
  506.  
  507. -- Bind all key numbers to tags.
  508. -- Be careful: we use keycodes to make it works on any keyboard layout.
  509. -- This should map on the top row of your keyboard, usually 1 to 9.
  510. for i = 1, 9 do
  511. globalkeys = awful.util.table.join(globalkeys,
  512. -- View tag only.
  513. awful.key({ modkey }, "#" .. i + 9,
  514. function ()
  515. local screen = mouse.screen
  516. local tag = awful.tag.gettags(screen)[i]
  517. if tag then
  518. awful.tag.viewonly(tag)
  519. end
  520. end),
  521. -- Toggle tag.
  522. awful.key({ modkey, "Control" }, "#" .. i + 9,
  523. function ()
  524. local screen = mouse.screen
  525. local tag = awful.tag.gettags(screen)[i]
  526. if tag then
  527. awful.tag.viewtoggle(tag)
  528. end
  529. end),
  530. -- Move client to tag.
  531. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  532. function ()
  533. if client.focus then
  534. local tag = awful.tag.gettags(client.focus.screen)[i]
  535. if tag then
  536. awful.client.movetotag(tag)
  537. end
  538. end
  539. end),
  540. -- Toggle tag.
  541. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  542. function ()
  543. if client.focus then
  544. local tag = awful.tag.gettags(client.focus.screen)[i]
  545. if tag then
  546. awful.client.toggletag(tag)
  547. end
  548. end
  549. end))
  550. end
  551.  
  552. clientbuttons = awful.util.table.join(
  553. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  554. awful.button({ modkey }, 1, awful.mouse.client.move),
  555. awful.button({ modkey }, 3, awful.mouse.client.resize))
  556.  
  557. -- Set keys
  558. root.keys(globalkeys)
  559. -- }}}
  560.  
  561. -- {{{ Rules
  562. -- Rules to apply to new clients (through the "manage" signal).
  563. awful.rules.rules = {
  564. -- All clients will match this rule.
  565. { rule = { },
  566. properties = { border_width = beautiful.border_width,
  567. border_color = beautiful.border_normal,
  568. focus = awful.client.focus.filter,
  569. raise = true,
  570. keys = clientkeys,
  571. buttons = clientbuttons } },
  572. { rule = { class = "MPlayer" },
  573. properties = { floating = true } },
  574. { rule = { class = "pinentry" },
  575. properties = { floating = true } },
  576. { rule = { class = "gimp" },
  577. properties = { floating = true } },
  578. -- Set Firefox to always map on tags number 2 of screen 1.
  579. -- { rule = { class = "Firefox" },
  580. -- properties = { tag = tags[1][2] } },
  581. }
  582. -- }}}
  583.  
  584. -- {{{ Signals
  585. -- Signal function to execute when a new client appears.
  586. client.connect_signal("manage", function (c, startup)
  587. -- Enable sloppy focus
  588. c:connect_signal("mouse::enter", function(c)
  589. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  590. and awful.client.focus.filter(c) then
  591. client.focus = c
  592. end
  593. end)
  594.  
  595. if not startup then
  596. -- Set the windows at the slave,
  597. -- i.e. put it at the end of others instead of setting it master.
  598. -- awful.client.setslave(c)
  599.  
  600. -- Put windows in a smart way, only if they does not set an initial position.
  601. if not c.size_hints.user_position and not c.size_hints.program_position then
  602. awful.placement.no_overlap(c)
  603. awful.placement.no_offscreen(c)
  604. end
  605. end
  606.  
  607. local titlebars_enabled = true
  608. if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  609. -- buttons for the titlebar
  610. local buttons = awful.util.table.join(
  611. awful.button({ }, 1, function()
  612. client.focus = c
  613. c:raise()
  614. awful.mouse.client.move(c)
  615. end),
  616. awful.button({ }, 3, function()
  617. client.focus = c
  618. c:raise()
  619. awful.mouse.client.resize(c)
  620. end)
  621. )
  622.  
  623. -- Widgets that are aligned to the left
  624. local left_layout = wibox.layout.fixed.horizontal()
  625. left_layout:add(awful.titlebar.widget.closebutton(c))
  626. left_layout:add(awful.titlebar.widget.maximizedbutton(c))
  627.  
  628. -- Widgets that are aligned to the right
  629. local right_layout = wibox.layout.fixed.horizontal()
  630. right_layout:add(awful.titlebar.widget.floatingbutton(c))
  631. right_layout:add(awful.titlebar.widget.minimizebutton(c))
  632.  
  633. -- The title goes in the middle
  634. local middle_layout = wibox.layout.flex.horizontal()
  635. local title = awful.titlebar.widget.titlewidget(c)
  636. title:set_align("center")
  637. middle_layout:add(title)
  638. middle_layout:buttons(buttons)
  639.  
  640. -- Now bring it all together
  641. local layout = wibox.layout.align.horizontal()
  642. layout:set_left(left_layout)
  643. layout:set_right(right_layout)
  644. layout:set_middle(middle_layout)
  645.  
  646. awful.titlebar(c):set_widget(layout)
  647. end
  648. end)
  649.  
  650. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  651. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  652. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment