Advertisement
Guest User

Untitled

a guest
Jun 14th, 2010
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.22 KB | None | 0 0
  1. --require("eminent")
  2. -- Standard awesome library
  3. require("awful")
  4. require("awful.autofocus")
  5. require("awful.rules")
  6. -- Theme handling library
  7. require("beautiful")
  8. -- Notification library
  9. require("naughty")
  10. require("vicious")
  11. require("wicked")
  12. require("revelation")
  13. --require("shifty")
  14. require("obvious.battery")
  15.  
  16.  
  17. -- {{{ Variable definitions
  18. -- Themes define colours, icons, and wallpapers
  19. wallpaper_cmd = { "awsetbg -f /home/p1mps/Pictures/wallpaper/Mario_by_Noodlez222.png"}
  20. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  21.  
  22. -- This is used later as the default terminal and editor to run.
  23. terminal = "urxvt"
  24. editor = "emacs"
  25. editor_cmd = terminal .. " -e " .. editor
  26.  
  27. -- Default modkey.
  28. -- Usually, Mod4 is the key with a logo between Control and Alt.
  29. -- If you do not like this or do not have such a key,
  30. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  31. -- However, you can use another modifier like Mod1, but it may interact with others.
  32. modkey = "Mod4"
  33.  
  34.  
  35.  
  36.  
  37. -- Table of layouts to cover with awful.layout.inc, order matters.
  38. layouts =
  39. {
  40. awful.layout.suit.floating,
  41. awful.layout.suit.tile,
  42. awful.layout.suit.tile.left,
  43. awful.layout.suit.tile.bottom,
  44. awful.layout.suit.tile.top,
  45. awful.layout.suit.fair,
  46. awful.layout.suit.fair.horizontal,
  47. awful.layout.suit.spiral,
  48. awful.layout.suit.spiral.dwindle,
  49. awful.layout.suit.max,
  50. awful.layout.suit.max.fullscreen,
  51. awful.layout.suit.magnifier
  52. }
  53. -- }}}
  54.  
  55. -- {{{ Tags
  56. -- Define a tag table which hold all screen tags.
  57. tags = {}
  58. for s = 1, screen.count() do
  59. -- Each screen has its own tag table.
  60. tags[s] = awful.tag({ "screen","work", "www", "dev", "im","mail", "media","pdf"}, s, layouts[2])
  61. end
  62. -- }}}
  63.  
  64.  
  65.  
  66.  
  67. -- client settings
  68. -- order here matters, early rules will be applied first
  69.  
  70.  
  71. --{{{ SHIFTY: configured tags
  72. --shifty.config.tags = {
  73. --["screen"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = true , solitary = true , position = 1, spawn = terminal } ,
  74. --["mail"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = true , solitary = true , position = 5 ,spawn = mail } ,
  75. --["im"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = false , solitary = true , position = 4 ,spawn = terminal } ,
  76.  
  77.  
  78.  
  79. --["www"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = false , solitary = false , position = 3, spawn = browser } ,
  80. --["work"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = true , solitary = true , position = 2 ,spawn = terminal} ,
  81. --["dev"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = true , solitary = true , position = 6, spawn = terminal } ,
  82. --["media"] = { layout = awful.layout.suit.tile.bottom, mwfact=0.65, persistent= true,exclusive = true , solitary = true , position = 7, spawn = terminal } ,
  83. --}
  84. --}}}
  85.  
  86. --{{{ SHIFTY: application matching rules
  87. -- order here matters, early rules will be applied first
  88. --shifty.config.apps = {
  89. -- { match = { "Pidgin" } , tag = "im" } ,
  90. -- { match = { "Navigator","*Namoroka" } , tag = "www",slave= true},
  91. -- { match = { "Shredder*", "Thunderbird3" , "urxvt -e mutt"} , tag = "mail" } ,
  92. -- { match = { "thunar" } , tag="media" } ,
  93. -- { match = { "OpenOffice.*", "eclipse","Pydev*" } , tag = "work" } ,
  94. --{ match = { terminal } , honorsizehints = false, slave = false } ,
  95. --{ match = { "Mplayer" } , tag ="media"},
  96. --{ match = { "mutt" } , tag ="mail"},
  97. --{ match = { "Google*" } , tag ="www" ,slave=true, float=true},
  98. --{ match = { "emacs*" } , tag ="dev" ,slave=true},
  99. --{ match = { "" }, buttons = {
  100. -- button({ }, 1, function (c) client.focus = c; c:raise() end),
  101. -- button({ modkey }, 1, function (c) awful.mouse.client.move() end),
  102. -- button({ modkey }, 3, awful.mouse.client.resize ), }, },
  103. --
  104. --}
  105. --}}}
  106.  
  107. --{{{ SHIFTY: default tag creation rules
  108. -- parameter description
  109. -- * floatBars : if floating clients should always have a titlebar
  110. -- * guess_name : wether shifty should try and guess tag names when creating new (unconfigured) tags
  111. -- * guess_position: as above, but for position parameter
  112. -- * run : function to exec when shifty creates a new tag
  113. -- * remember_index: ?
  114. -- * all other parameters (e.g. layout, mwfact) follow awesome's tag API
  115. --shifty.config.defaults={
  116. -- layout = awful.layout.suit.tile.bottom,
  117. -- ncol = 1,
  118. -- mwfa-ct = 0.60,
  119. -- floatBars=true,
  120. -- guess_name=true,
  121. -- guess_position=true,
  122. --}
  123. --shifty.init()
  124. ---}}}
  125.  
  126.  
  127.  
  128. --TODO LIST
  129. function get_agenda()
  130. local filedescriptor = io.open("/home/p1mps/lavoro/TODO","r")
  131. local todo = filedescriptor:read("*a")
  132. --print (todo)
  133. filedescriptor:close()
  134. return todo
  135. end
  136.  
  137.  
  138. --TODO LIST
  139. function get_note()
  140. local filedescriptor = io.open("/home/p1mps/lavoro/note","r")
  141. local todo = filedescriptor:read("*a")
  142. --print (todo)
  143. filedescriptor:close()
  144. return todo
  145. end
  146.  
  147. function batteryInfo(adapter)
  148. spacer = " "
  149. local fcur = io.open("/sys/class/power_supply/"..adapter.."/charge_now")
  150. local fcap = io.open("/sys/class/power_supply/"..adapter.."/charge_full")
  151. local fsta = io.open("/sys/class/power_supply/"..adapter.."/status")
  152. local cur = fcur:read()
  153. local cap = fcap:read()
  154. local sta = fsta:read()
  155. local battery = math.floor(cur * 100 / cap)
  156. if tonumber(battery) < 10 then
  157. naughty.notify({ title = "Battery Warning"
  158. , text = "Battery low!"..spacer..battery.."%"..spacer.."left!"
  159. , timeout = 5
  160. , position = "top_right"
  161. , fg = beautiful.fg_focus
  162. , bg = beautiful.bg_focus
  163.  
  164. })
  165.  
  166.  
  167.  
  168. end
  169. end
  170.  
  171.  
  172. -- {{{ Menu
  173. -- Create a laucher widget and a main menu
  174. myawesomemenu = {
  175. { "manual", terminal .. " -e man awesome" },
  176.  
  177. { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  178. { "restart", awesome.restart },
  179. { "quit", awesome.quit }
  180.  
  181.  
  182. }
  183.  
  184. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  185. { "open terminal", terminal }
  186. }
  187. })
  188.  
  189. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  190. menu = mymainmenu })
  191. -- }}}
  192.  
  193. -- {{{ Wibox
  194. -- Create a textclock widget
  195. mytextclock = awful.widget.textclock({ align = "right" })
  196.  
  197. --calendar
  198. local calendar = nil
  199. local offset = 0
  200.  
  201. function remove_calendar()
  202. if calendar ~= nil then
  203. naughty.destroy(calendar)
  204. calendar = nil
  205. offset = 0
  206. end
  207. end
  208.  
  209. function add_calendar(inc_offset)
  210. local save_offset = offset
  211. remove_calendar()
  212. offset = save_offset + inc_offset
  213. local datespec = os.date("*t")
  214. datespec = datespec.year * 12 + datespec.month - 1 + offset
  215. datespec = (datespec % 12 + 1) .. " " .. math.floor(datespec / 12)
  216. local cal = awful.util.pread("cal -m " .. datespec)
  217. cal = string.gsub(cal, "^%s*(.-)%s*$", "%1")
  218. calendar = naughty.notify({
  219. text = string.format('<span font_desc="%s">%s</span>', "terminus", cal),
  220. timeout = 0, hover_timeout = 0.5,
  221. width = 160,
  222. })
  223. end
  224.  
  225. -- change clockbox for your clock widget (e.g. mytextclock)
  226. mytextclock:add_signal("mouse::enter", function()
  227. add_calendar(0)
  228. end)
  229. mytextclock:add_signal("mouse::leave", remove_calendar)
  230.  
  231. mytextclock:buttons({
  232. button({ }, 4, function()
  233. add_calendar(-1)
  234. end),
  235. button({ }, 5, function()
  236. add_calendar(1)
  237. end),
  238. })
  239.  
  240. myorgwidget = widget({type = "textbox"})
  241.  
  242. mynote = widget({type = "textbox"})
  243.  
  244.  
  245. --todo
  246. local todo = nil
  247. local offset = 0
  248.  
  249. function remove_todo()
  250. if todo ~= nil then
  251. naughty.destroy(todo)
  252. calendar = nil
  253. offset = 0
  254. end
  255. end
  256.  
  257. function add_todo(inc_offset)
  258. local save_offset = offset
  259. remove_todo()
  260. offset = save_offset + inc_offset
  261. local cal = get_agenda()
  262. todo = naughty.notify({
  263. text = string.format('<span font_desc="%s">%s</span>', "terminus", cal),
  264. timeout = 0, hover_timeout = 0.5,
  265. width = 160,
  266. })
  267. end
  268.  
  269.  
  270. --todo
  271. local todo = nil
  272. local offset = 0
  273.  
  274. function remove_note()
  275. if todo ~= nil then
  276. naughty.destroy(todo)
  277. calendar = nil
  278. offset = 0
  279. end
  280. end
  281.  
  282. function add_note(inc_offset)
  283. local save_offset = offset
  284. remove_todo()
  285. offset = save_offset + inc_offset
  286. local cal = get_note()
  287. todo = naughty.notify({
  288. text = string.format('<span font_desc="%s">%s</span>', "terminus", cal),
  289. timeout = 0, hover_timeout = 0.5,
  290. width = 200,
  291. })
  292. end
  293.  
  294.  
  295.  
  296.  
  297. -- change clockbox for your clock widget (e.g. mytextclock)
  298. myorgwidget:add_signal("mouse::enter", function()
  299. add_todo(0)
  300. end)
  301. myorgwidget:add_signal("mouse::leave", remove_todo)
  302.  
  303. myorgwidget:buttons({
  304. button({ }, 4, function()
  305. add_todo(-1)
  306. end),
  307. button({ }, 5, function()
  308. add_todo(1)
  309. end),
  310. })
  311.  
  312.  
  313.  
  314.  
  315. -- change clockbox for your clock widget (e.g. mytextclock)
  316. mynote:add_signal("mouse::enter", function()
  317. add_note(0)
  318. end)
  319. mynote:add_signal("mouse::leave", remove_note)
  320.  
  321. mynote:buttons({
  322. button({ }, 4, function()
  323. add_note(-1)
  324. end),
  325. button({ }, 5, function()
  326. add_note(1)
  327. end),
  328. })
  329.  
  330. myorgwidget.text = "<span color='cyan'>TODO </span>"
  331.  
  332. mynote.text = "<span color='violet'>note </span>"
  333.  
  334.  
  335.  
  336. awful.hooks.timer.register(3, function()
  337. batteryInfo("BAT0")
  338. end)
  339.  
  340. fsicon = widget({type ="imagebox"})
  341. fsicon.image = image("/home/p1mps/.config/awesome/icons/disk.png")
  342.  
  343.  
  344. fswidget = widget({type="textbox"})
  345.  
  346. vicious.register(fswidget,vicious.widgets.fs,"<span color='white'> root: ${/ used_p}% </span> ")
  347.  
  348. fs2widget = widget({type="textbox"})
  349.  
  350. vicious.register(fs2widget,vicious.widgets.fs,"<span color='white'> dati: ${/media/dati used_p}% </span> ")
  351.  
  352.  
  353. --wifi
  354. wificon = widget({type ="imagebox"})
  355. wificon.image = image("/home/p1mps/.config/awesome/icons/wifi.png")
  356.  
  357. wifiwidget = widget({type="textbox"})
  358. vicious.register(wifiwidget,vicious.widgets.net,"<span color='white'> down ${wlan0 down_kb} up ${wlan0 up_kb} </span> ")
  359.  
  360.  
  361. --memory
  362. -- Initialize widget
  363. memicon = widget({type ="imagebox"})
  364. memicon.image = image("/home/p1mps/.config/awesome/icons/mem.png")
  365.  
  366.  
  367. memwidget = widget({ type = "textbox" })
  368. -- Register widget
  369. vicious.register(memwidget, vicious.widgets.mem, "<span color='white'> $1% ($2MB/$3MB) </span>", 13)
  370.  
  371.  
  372. --cpu
  373. -- Initialize widget
  374. cpuwidget = awful.widget.graph()
  375. -- Graph properties
  376. cpuwidget:set_width(50)
  377. cpuwidget:set_background_color("#494B4F")
  378. cpuwidget:set_color("#FF5656")
  379. cpuwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
  380. -- Register widget
  381. vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
  382.  
  383.  
  384.  
  385. --MPD
  386. mpdwidget = widget({type="textbox"})
  387. vicious.register(mpdwidget,vicious.widgets.mpd,"Playing: <span color='red'> $1 </span> ")
  388.  
  389.  
  390.  
  391. -- battery
  392.  
  393. baticon = widget({type ="imagebox"})
  394. baticon.image = image("/home/p1mps/.config/awesome/icons/bat.png")
  395.  
  396. batterywidget = widget({type="textbox"})
  397. vicious.register(batterywidget,vicious.widgets.bat,"$1$2%",31,"BAT0")
  398.  
  399.  
  400.  
  401.  
  402. --mail
  403. -- {{{ GMail widget
  404. -- Initialize widget
  405. gmailicon = widget({ type = "imagebox" })
  406. gmailicon.image = image("/home/p1mps/.config/awesome/icons/mail.png")
  407. gmailwidget = widget({ type = "textbox" })
  408. --Register widget
  409. vicious.register(gmailwidget, vicious.widgets.gmail, "<span color='white'> Mail: ${count} | ${subject} </span>", 20)
  410.  
  411. mailicon = widget({ type = "imagebox" })
  412. mailicon.image = image("/home/p1mps/.config/awesome/icons/mail.png")
  413. -- Initialize widget
  414. mailwidget = widget({ type = "textbox" })
  415. -- Register widget
  416. --vicious.register(mailwidget, vicious.widgets.mbox, "$1", 181, {"/home/p1mps/Mail", 15})
  417. -- Register buttons
  418. mailwidget:buttons(awful.util.table.join(
  419. awful.button({ }, 1, function () exec("thunderbird") end)
  420. ))
  421.  
  422.  
  423.  
  424. -- Create a systray
  425. mysystray = widget({ type = "systray" })
  426.  
  427.  
  428.  
  429. -- Create a wibox for each screen and add it
  430. mywibox = {}
  431. mywibox_down = {}
  432.  
  433. mypromptbox = {}
  434. mylayoutbox = {}
  435. mytaglist = {}
  436. mytaglist.buttons = awful.util.table.join(
  437. awful.button({ }, 1, awful.tag.viewonly),
  438. awful.button({ modkey }, 1, awful.client.movetotag),
  439. awful.button({ }, 3, awful.tag.viewtoggle),
  440. awful.button({ modkey }, 3, awful.client.toggletag),
  441. awful.button({ }, 4, awful.tag.viewnext),
  442. awful.button({ }, 5, awful.tag.viewprev)
  443. )
  444. mytasklist = {}
  445. mytasklist.buttons = awful.util.table.join(
  446. awful.button({ }, 1, function (c)
  447. if not c:isvisible() then
  448. awful.tag.viewonly(c:tags()[1])
  449. end
  450. client.focus = c
  451. c:raise()
  452. end),
  453. awful.button({ }, 3, function ()
  454. if instance then
  455. instance:hide()
  456. instance = nil
  457. else
  458. instance = awful.menu.clients({ width=250 })
  459. end
  460. end),
  461. awful.button({ }, 4, function ()
  462. awful.client.focus.byidx(1)
  463. if client.focus then client.focus:raise() end
  464. end),
  465. awful.button({ }, 5, function ()
  466. awful.client.focus.byidx(-1)
  467. if client.focus then client.focus:raise() end
  468. end))
  469.  
  470. for s = 1, screen.count() do
  471. -- Create a promptbox for each screen
  472. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  473. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  474. -- We need one layoutbox per screen.
  475. mylayoutbox[s] = awful.widget.layoutbox(s)
  476. mylayoutbox[s]:buttons(awful.util.table.join(
  477. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  478. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  479. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  480. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  481. -- Create a taglist widget
  482. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  483.  
  484. -- Create a tasklist widget
  485. mytasklist[s] = awful.widget.tasklist(function(c)
  486. return awful.widget.tasklist.label.currenttags(c, s)
  487. end, mytasklist.buttons)
  488.  
  489. -- Create the wibox
  490. mywibox[s] = awful.wibox({ position = "top", screen = s })
  491. mywibox_down[s] = awful.wibox({ position = "bottom", screen = s })
  492.  
  493. -- Add widgets to the wibox - order matters
  494. mywibox[s].widgets = {
  495. {
  496. mylauncher,
  497. mytaglist[s],
  498. mypromptbox[s],
  499. layout = awful.widget.layout.horizontal.leftright
  500. },
  501. mylayoutbox[s],
  502. -- myorgwidget,
  503. mytextclock,
  504. --wifiwidget,
  505. mpdwidget,
  506. --myorgwidget,
  507. mynote,
  508. myorgwidget,
  509.  
  510. s == 1 and mysystray or nil,
  511. mytasklist[s],
  512. layout = awful.widget.layout.horizontal.rightleft
  513. }
  514.  
  515. mywibox_down[s].widgets = {
  516. {
  517. layout = awful.widget.layout.horizontal.leftright
  518.  
  519.  
  520.  
  521. },
  522. -- myorgwidget,
  523. cpuwidget,
  524. gmailwidget,
  525. gmailicon,
  526. spacer,
  527. memwidget,
  528. memicon,
  529. layout = awful.widget.layout.horizontal.rightleft,
  530. wifiwidget,
  531. spacer,
  532.  
  533. wificon,
  534. separator,
  535. fswidget,
  536. spacer,
  537. fs2widget,
  538. spacer,
  539. fsicon,
  540. separator,
  541. baticon,
  542. spacer,
  543. batterywidget,
  544. layout = awful.widget.layout.horizontal.rightleft
  545.  
  546.  
  547. }
  548.  
  549.  
  550.  
  551. end
  552.  
  553. -- }}}
  554.  
  555. -- {{{ Mouse bindings
  556. root.buttons(awful.util.table.join(
  557. awful.button({ }, 3, function () mymainmenu:toggle() end),
  558. awful.button({ }, 4, awful.tag.viewnext),
  559. awful.button({ }, 5, awful.tag.viewprev)
  560. ))
  561. -- }}}
  562. -- {{{ Key bindings
  563. globalkeys = awful.util.table.join(
  564. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  565. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  566. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  567. awful.key({ modkey }, "e", revelation.revelation),
  568. awful.key({ modkey, }, "j",
  569. function ()
  570. awful.client.focus.byidx( 1)
  571. if client.focus then client.focus:raise() end
  572. end),
  573. awful.key({ modkey, }, "k",
  574. function ()
  575. awful.client.focus.byidx(-1)
  576. if client.focus then client.focus:raise() end
  577. end),
  578. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  579.  
  580. -- Layout manipulation
  581. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  582. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  583. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  584. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  585. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  586. awful.key({ modkey, }, "Tab",
  587. function ()
  588. awful.client.focus.history.previous()
  589. if client.focus then
  590. client.focus:raise()
  591. end
  592. end),
  593.  
  594. -- Standard program
  595. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  596. awful.key({ modkey, "Control" }, "r", awesome.restart),
  597. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  598.  
  599. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  600. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  601. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  602. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  603. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  604. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  605. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  606. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  607. awful.key({ }, "XF86AudioPlay", function () awful.util.spawn("mpc toggle") end),
  608. awful.key({ }, "XF86AudioStop", function () awful.util.spawn("mpc stop") end),
  609. awful.key({ }, "XF86AudioNext", function () awful.util.spawn("mpc next") end),
  610. awful.key({ }, "XF86AudioPrev", function () awful.util.spawn("mpc prev") end),
  611. awful.key({ modkey}, "t", function () awful.util.spawn("thunar") end),
  612. awful.key({ modkey}, "g", function () awful.util.spawn("google-chrome") end),
  613. awful.key({ modkey}, "s", function () awful.util.spawn("emacs") end),
  614.  
  615. awful.key({ modkey}, "p", function () awful.util.spawn("pidgin") end),
  616.  
  617.  
  618. -- Prompt
  619. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  620.  
  621. awful.key({ modkey }, "x",
  622. function ()
  623. awful.prompt.run({ prompt = "Run Lua code: " },
  624. mypromptbox[mouse.screen].widget,
  625. awful.util.eval, nil,
  626. awful.util.getdir("cache") .. "/history_eval")
  627. end)
  628. )
  629.  
  630. -- C
  631.  
  632. clientkeys = awful.util.table.join(
  633. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  634. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  635. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  636. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  637. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  638. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  639. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  640. awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
  641. awful.key({ modkey, }, "m",
  642. function (c)
  643. c.maximized_horizontal = not c.maximized_horizontal
  644. c.maximized_vertical = not c.maximized_vertical
  645. end)
  646. )
  647.  
  648. keynumber = 0
  649. for s = 1, screen.count() do
  650. keynumber = math.min(9, math.max(#tags[s], keynumber));
  651. end
  652.  
  653. -- Bind all key numbers to tags.
  654. -- Be careful: we use keycodes to make it works on any keyboard layout.
  655. -- This should map on the top row of your keyboard, usually 1 to 9.
  656.  
  657. -- Bind all key numbers to tags.
  658. -- Be careful: we use keycodes to make it works on any keyboard layout.
  659. -- This should map on the top row of your keyboard, usually 1 to 9.
  660. for i = 1, keynumber do
  661. globalkeys = awful.util.table.join(globalkeys,
  662. awful.key({ modkey }, "#" .. i + 9,
  663. function ()
  664. local screen = mouse.screen
  665. if tags[screen][i] then
  666. awful.tag.viewonly(tags[screen][i])
  667. end
  668. end),
  669. awful.key({ modkey, "Control" }, "#" .. i + 9,
  670. function ()
  671. local screen = mouse.screen
  672. if tags[screen][i] then
  673. awful.tag.viewtoggle(tags[screen][i])
  674. end
  675. end),
  676. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  677. function ()
  678. if client.focus and tags[client.focus.screen][i] then
  679. awful.client.movetotag(tags[client.focus.screen][i])
  680. end
  681. end),
  682. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  683. function ()
  684. if client.focus and tags[client.focus.screen][i] then
  685. awful.client.toggletag(tags[client.focus.screen][i])
  686. end
  687. end))
  688. end
  689.  
  690.  
  691. --for i=1,9 do
  692.  
  693. -- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey }, i,
  694. -- function ()
  695. -- local t = awful.tag.viewonly(shifty.getpos(i))
  696. -- end))
  697. -- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Control" }, i,
  698. -- function ()
  699. -- local t = shifty.getpos(i)
  700. -- t.selected = not t.selected
  701. -- end))
  702. -- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Control", "Shift" }, i,
  703. -- function ()
  704. -- if client.focus then
  705. -- awful.client.toggletag(shifty.getpos(i))
  706. -- end
  707. -- end))
  708. -- move clients to other tags
  709. -- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Shift" }, i,
  710. -- function ()
  711. --if client.focus then
  712. -- local t = shifty.getpos(i)
  713. -- awful.client.movetotag(t)
  714. -- awful.tag.viewonly(t)
  715. -- end
  716. -- end))
  717. --end
  718.  
  719. --for i = 1, keynumber do
  720. -- globalkeys = awful.util.table.join(globalkeys,
  721. -- awful.key({ modkey }, "#" .. i + 9,
  722. -- function ()
  723. -- local screen = mouse.screen
  724. -- if tags[screen][i] then
  725. -- awful.tag.viewonly(tags[screen][i])
  726. -- end
  727. -- end),
  728. -- awful.key({ modkey, "Control" }, "#" .. i + 9,
  729. -- function ()
  730. -- local screen = mouse.screen
  731. -- if tags[screen][i] then
  732. -- awful.tag.viewtoggle(tags[screen][i])
  733. -- end
  734. -- end),
  735. -- awful.key({ modkey, "Shift" }, "#" .. i + 9,
  736. -- function ()
  737. -- if client.focus and tags[client.focus.screen][i] then
  738. -- awful.client.movetotag(tags[client.focus.screen][i])
  739. -- end
  740. -- end),
  741. -- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  742. -- function ()
  743. -- if client.focus and tags[client.focus.screen][i] then
  744. -- awful.client.toggletag(tags[client.focus.screen][i])
  745. -- end
  746. -- end))
  747. --end
  748.  
  749. clientbuttons = awful.util.table.join(
  750. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  751. awful.button({ modkey }, 1, awful.mouse.client.move),
  752. awful.button({ modkey }, 3, awful.mouse.client.resize))
  753.  
  754. -- Set keys
  755. root.keys(globalkeys)
  756. -- Set keys
  757. --shifty.config.globalkeys = globalkeys
  758. --shifty.config.clientkeys = clientkeys
  759. -- }}}
  760. -- {{{ Rules
  761. awful.rules.rules = {
  762. -- All clients will match this rule.
  763. { rule = { },
  764. properties = { border_width = beautiful.border_width,
  765. border_color = beautiful.border_normal,
  766. focus = true,
  767. keys = clientkeys,
  768. buttons = clientbuttons } },
  769. { rule = { class = "MPlayer" },
  770. properties = { floating = true } },
  771. { rule = { class = "pinentry" },
  772. properties = { floating = true } },
  773. { rule = { class = "gimp" },
  774. properties = { floating = true } },
  775. { rule = { class = "Pidgin" },
  776. properties = { floating = true } },
  777.  
  778. -- Set Firefox to always map on tags number 2 of screen 1.
  779. -- { rule = { class = "Firefox" },
  780. -- properties = { tag = tags[1][2] } },
  781. }
  782. -- }}}
  783.  
  784.  
  785. -- {{{ Signals
  786. -- Signal function to execute when a new client appears.
  787. client.add_signal("manage", function (c, startup)
  788. -- Add a titlebar
  789. -- awful.titlebar.add(c, { modkey = modkey })
  790.  
  791. -- Enable sloppy focus
  792. c:add_signal("mouse::enter", function(c)
  793. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  794. and awful.client.focus.filter(c) then
  795. client.focus = c
  796. end
  797. end)
  798.  
  799. if not startup then
  800. -- Search for this line:
  801. -- Then add the following below it:
  802.  
  803. -- Put windows in a smart way, only if they does not set an initial position.
  804. if not c.size_hints.user_position and not c.size_hints.program_position then
  805. awful.placement.no_overlap(c)
  806. awful.placement.no_offscreen(c)
  807. end
  808. end
  809. end)
  810.  
  811. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  812. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  813. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement