grey_blue_rc.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. awful.rules = require("awful.rules")
  5. require("awful.autofocus")
  6. -- Widget and layout library
  7. local wibox = require("wibox")
  8. -- Theme handling library
  9. local beautiful = require("beautiful")
  10. -- Notification library
  11. local naughty = require("naughty")
  12. local menubar = require("menubar")
  13. -- {{{ Error handling
  14. -- Check if awesome encountered an error during startup and fell back to
  15. -- another config (This code will only ever execute for the fallback config)
  16. if awesome.startup_errors then
  17. naughty.notify({ preset = naughty.config.presets.critical,
  18. title = "Oops, there were errors during startup!",
  19. text = awesome.startup_errors })
  20. end
  21. -- Handle runtime errors after startup
  22. do
  23. local in_error = false
  24. awesome.connect_signal("debug::error", function (err)
  25. -- Make sure we don't go into an endless error loop
  26. if in_error then return end
  27. in_error = true
  28. naughty.notify({ preset = naughty.config.presets.critical,
  29. title = "Oops, an error happened!",
  30. text = err })
  31. in_error = false
  32. end)
  33. end
  34. -- }}}
  35. -- {{{ Variable definitions
  36. -- Themes define colours, icons, font and wallpapers.
  37. beautiful.init("/home/cedlemo/Projets/Lua/blingbling/config_example/grey_blue/theme.lua")
  38. -- This is used later as the default terminal and editor to run.
  39. terminal = "tortosa"
  40. editor = os.getenv("EDITOR") or "nano"
  41. editor_cmd = terminal .. " -e " .. editor
  42. -- Default modkey.
  43. -- Usually, Mod4 is the key with a logo between Control and Alt.
  44. -- If you do not like this or do not have such a key,
  45. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  46. -- However, you can use another modifier like Mod1, but it may interact with others.
  47. modkey = "Mod4"
  48. -- Table of layouts to cover with awful.layout.inc, order matters.
  49. local layouts =
  50. {
  51. awful.layout.suit.floating,
  52. awful.layout.suit.tile,
  53. awful.layout.suit.tile.left,
  54. awful.layout.suit.tile.bottom,
  55. awful.layout.suit.tile.top,
  56. awful.layout.suit.fair,
  57. awful.layout.suit.fair.horizontal,
  58. awful.layout.suit.spiral,
  59. awful.layout.suit.spiral.dwindle,
  60. awful.layout.suit.max,
  61. awful.layout.suit.max.fullscreen,
  62. awful.layout.suit.magnifier
  63. }
  64. -- }}}
  65. -- {{{ Wallpaper
  66. for s = 1, screen.count() do
  67. gears.wallpaper.maximized("/home/cedlemo/Projets/Lua/blingbling/config_example/tiles_grey.png", s, true)
  68. end
  69. -- }}}
  70. -- {{{ Tags
  71. -- Define a tag table which hold all screen tags.
  72. tags = {}
  73. for s = 1, screen.count() do
  74. -- Each screen has its own tag table.
  75. tags[s] = awful.tag({ "Web", "Dev", 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  76. end
  77. -- }}}
  78. -- {{{ Menu
  79. -- Create a laucher widget and a main menu
  80. myawesomemenu = {
  81. { "manual", terminal .. " -e man awesome" },
  82. { "edit config", editor_cmd .. " " .. awesome.conffile },
  83. { "restart", awesome.restart },
  84. { "quit", awesome.quit }
  85. }
  86. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  87. { "open terminal", terminal }
  88. }
  89. })
  90. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  91. menu = mymainmenu })
  92. -- Menubar configuration
  93. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  94. -- }}}
  95. -- {{{ Wibox
  96. local vicious = require('vicious')
  97. vicious.cache(vicious.widgets.cpu)
  98. vicious.cache(vicious.widgets.fs)
  99. local blingbling = require('blingbling')
  100. -- Create a textclock widget
  101. mytextclock = awful.widget.textclock()
  102. mytextclock:set_font("Cantarell Bold 10")
  103. mytextclock:set_align("center")
  104. local calendar = blingbling.calendar(mytextclock)
  105. --calendar:set_link_to_external_calendar(true)
  106. -- Create a wibox for each screen and add it
  107. local tag_indicator= blingbling.text_box({ text = awful.tag.selected(mouse.screen).name,
  108. width=40, rounded_size=0.3,
  109. background_color="#33333333",
  110. text_background_color="#00000000",
  111. text_color=beautiful.bg_focus,
  112. h_margin=4,-- v_margin=2,
  113. font="Cantarell", font_size=11 })
  114. mywibox = {}
  115. --mypromptbox = {}
  116. --mylayoutbox = {}
  117. mytasklist = {}
  118. mytasklist.buttons = awful.util.table.join(
  119. awful.button({ }, 1, function (c)
  120. if c == client.focus then
  121. c.minimized = true
  122. else
  123. c.minimized = false
  124. if not c:isvisible() then
  125. awful.tag.viewonly(c:tags()[1])
  126. end
  127. client.focus = c
  128. c:raise()
  129. end
  130. end),
  131. awful.button({ }, 3, function ()
  132. if instance then
  133. instance:hide()
  134. instance = nil
  135. else
  136. instance = awful.menu.clients({
  137. theme = { width = 250 }
  138. })
  139. end
  140. end),
  141. awful.button({ }, 4, function ()
  142. awful.client.focus.byidx(1)
  143. if client.focus then client.focus:raise() end
  144. end),
  145. awful.button({ }, 5, function ()
  146. awful.client.focus.byidx(-1)
  147. if client.focus then client.focus:raise() end
  148. end))
  149. for s = 1, screen.count() do
  150. screen[s]:connect_signal("tag::history::update", function()
  151. tag_indicator:set_text( awful.tag.selected(s).name )
  152. tagslist[s]:show()
  153. end)
  154. -- Create a promptbox for each screen
  155. --mypromptbox[s] = awful.widget.prompt()
  156. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  157. -- We need one layoutbox per screen.
  158. -- mylayoutbox[s] = awful.widget.layoutbox(s)
  159. -- mylayoutbox[s]:buttons(awful.util.table.join(
  160. -- awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  161. -- awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  162. -- awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  163. -- awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  164. -- Create a taglist widget
  165. -- Create a tasklist widget
  166. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.focused, mytasklist.buttons,nil,blingbling.helpers.icons_only_tasklist, wibox.layout.fixed.horizontal())
  167. -- Create the wibox
  168. mywibox[s] = awful.wibox({ position = "top", screen = s })
  169. -- Widgets that are aligned to the left
  170. local left_layout = wibox.layout.fixed.horizontal()
  171. left_layout:add(tag_indicator)
  172. left_layout:add(mytasklist[s])
  173. local right_layout = wibox.layout.fixed.horizontal()
  174. if s == 1 then right_layout:add(wibox.widget.systray()) end
  175. local layout = wibox.layout.align.horizontal()
  176. layout:set_left(left_layout)
  177. layout:set_middle(calendar)
  178. layout:set_right(right_layout)
  179. mywibox[s]:set_widget(layout)
  180. end
  181. -- }}}
  182. local function layout_wibox()
  183. --local current_screen = mouse.screen
  184. --local screen_geometry = screen[current_screen].workarea
  185. local layoutbox = {}
  186. local box ={}
  187. for s = 1, screen.count() do
  188. layoutbox[s] = awful.widget.layoutbox(s)
  189. layoutbox[s]:buttons(awful.util.table.join(
  190. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  191. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  192. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  193. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  194. local margin = wibox.layout.margin(layoutbox[s], 4, 4, 4, 4)
  195. --local w,h = margin:fit(screen_geometry.width,screen_geometry.height)
  196. box[s] = blingbling.transient({height=50 , width=50, ontop=true })
  197. box[s]:center_right()
  198. local tags = awful.tag.gettags(s)
  199. for _,t in ipairs(tags) do
  200. t:connect_signal("property::layout", function()
  201. box[s]:show()
  202. end)
  203. end
  204. box[s]:set_widget(margin)
  205. end
  206. return box
  207. end
  208. local function prompt_wibox()
  209. local prompt={}
  210. local prompt_wibox={}
  211. local current_screen = mouse.screen
  212. local screen_geometry = screen[current_screen].workarea
  213. for s = 1, screen.count() do
  214. prompt[s] = awful.widget.prompt()
  215. local margin = wibox.layout.margin(prompt[s], 4, 4, 4, 4)
  216. prompt_wibox[s]=blingbling.transient({height=50 , width=200, ontop=true })
  217. prompt_wibox[s]:set_widget(margin)
  218. prompt_wibox[s]:center_left()
  219. end
  220. prompt_wibox.prompt=prompt
  221. return prompt_wibox
  222. end
  223. local function tagslist_wibox()
  224. local current_screen = mouse.screen
  225. local screen_geometry = screen[current_screen].workarea
  226. local mytaglist = {}
  227. local box={}
  228. mytaglist.buttons = awful.util.table.join(
  229. awful.button({ }, 1, awful.tag.viewonly),
  230. awful.button({ modkey }, 1, awful.client.movetotag),
  231. awful.button({ }, 3, awful.tag.viewtoggle),
  232. awful.button({ modkey }, 3, awful.client.toggletag),
  233. awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  234. awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  235. )
  236. for s = 1, screen.count() do
  237. mytaglist[s]=blingbling.tagslist(s, awful.widget.taglist.filter.all, mytaglist.buttons )
  238. local margin = wibox.layout.margin(mytaglist[s], 4, 4, 4, 4)
  239. local w,h = margin:fit(screen_geometry.width,screen_geometry.height)
  240. box[s] = blingbling.transient({height=h , width=w, ontop=true })
  241. box[s]:center()
  242. box[s]:set_widget(margin)
  243. end
  244. return box
  245. end
  246. tagslist = tagslist_wibox()
  247. layoutlist = layout_wibox()
  248. promptlist = prompt_wibox()
  249. -- {{{ Mouse bindings
  250. root.buttons(awful.util.table.join(
  251. awful.button({ }, 3, function () mymainmenu:toggle() end),
  252. awful.button({ }, 4, awful.tag.viewnext),
  253. awful.button({ }, 5, awful.tag.viewprev)
  254. ))
  255. -- }}}
  256. -- {{{ Key bindings
  257. globalkeys = awful.util.table.join(
  258. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  259. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  260. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  261. awful.key({ modkey, }, "j",
  262. function ()
  263. awful.client.focus.byidx( 1)
  264. if client.focus then client.focus:raise() end
  265. end),
  266. awful.key({ modkey, }, "k",
  267. function ()
  268. awful.client.focus.byidx(-1)
  269. if client.focus then client.focus:raise() end
  270. end),
  271. awful.key({ modkey, }, "w", function () mymainmenu:show() end),
  272. -- Layout manipulation
  273. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  274. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  275. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  276. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  277. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  278. awful.key({ modkey, }, "Tab",
  279. function ()
  280. awful.client.focus.history.previous()
  281. if client.focus then
  282. client.focus:raise()
  283. end
  284. end),
  285. -- Standard program
  286. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  287. awful.key({ modkey, "Control" }, "r", awesome.restart),
  288. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  289. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  290. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  291. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  292. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  293. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  294. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  295. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  296. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  297. awful.key({ modkey, }, "d", function ()
  298. tagslist[mouse.screen].visible = not tagslist[mouse.screen].visible
  299. layoutlist[mouse.screen].visible = not layoutlist[mouse.screen].visible
  300. end),
  301. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  302. -- Prompt
  303. awful.key({ modkey }, "r", function ()
  304. if promptlist[mouse.screen].visible == false then
  305. promptlist[mouse.screen].visible=true
  306. awful.prompt.run({prompt = promptlist.prompt[mouse.screen].prompt },
  307. promptlist.prompt[mouse.screen].widget,
  308. function (...)
  309. local result = awful.util.spawn(...)
  310. if type(result) == "string" then
  311. blingbling.helpers.dbg({result})
  312. end
  313. end,
  314. awful.completion.shell,
  315. awful.util.getdir("cache") .. "/history",
  316. 50,
  317. function()
  318. promptlist[mouse.screen].visible = false
  319. end
  320. )
  321. else
  322. promptlist[mouse.screen].visible=false
  323. end
  324. end),
  325. -- Menubar
  326. awful.key({ modkey }, "p", function() menubar.show() end)
  327. )
  328. clientkeys = awful.util.table.join(
  329. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  330. awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
  331. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  332. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  333. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  334. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  335. awful.key({ modkey, }, "n",
  336. function (c)
  337. -- The client currently has the input focus, so it cannot be
  338. -- minimized, since minimized clients can't have the focus.
  339. c.minimized = true
  340. end),
  341. awful.key({ modkey, }, "m",
  342. function (c)
  343. c.maximized_horizontal = not c.maximized_horizontal
  344. c.maximized_vertical = not c.maximized_vertical
  345. end)
  346. )
  347. -- Bind all key numbers to tags.
  348. -- Be careful: we use keycodes to make it works on any keyboard layout.
  349. -- This should map on the top row of your keyboard, usually 1 to 9.
  350. for i = 1, 9 do
  351. globalkeys = awful.util.table.join(globalkeys,
  352. -- View tag only.
  353. awful.key({ modkey }, "#" .. i + 9,
  354. function ()
  355. local screen = mouse.screen
  356. local tag = awful.tag.gettags(screen)[i]
  357. if tag then
  358. awful.tag.viewonly(tag)
  359. end
  360. end),
  361. -- Toggle tag.
  362. awful.key({ modkey, "Control" }, "#" .. i + 9,
  363. function ()
  364. local screen = mouse.screen
  365. local tag = awful.tag.gettags(screen)[i]
  366. if tag then
  367. awful.tag.viewtoggle(tag)
  368. end
  369. end),
  370. -- Move client to tag.
  371. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  372. function ()
  373. if client.focus then
  374. local tag = awful.tag.gettags(client.focus.screen)[i]
  375. if tag then
  376. awful.client.movetotag(tag)
  377. end
  378. end
  379. end),
  380. -- Toggle tag.
  381. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  382. function ()
  383. if client.focus then
  384. local tag = awful.tag.gettags(client.focus.screen)[i]
  385. if tag then
  386. awful.client.toggletag(tag)
  387. end
  388. end
  389. end))
  390. end
  391. clientbuttons = awful.util.table.join(
  392. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  393. awful.button({ modkey }, 1, awful.mouse.client.move),
  394. awful.button({ modkey }, 3, awful.mouse.client.resize))
  395. -- Set keys
  396. root.keys(globalkeys)
  397. -- }}}
  398. -- {{{ Rules
  399. -- Rules to apply to new clients (through the "manage" signal).
  400. awful.rules.rules = {
  401. -- All clients will match this rule.
  402. { rule = { },
  403. properties = { border_width = beautiful.border_width,
  404. border_color = beautiful.border_normal,
  405. focus = awful.client.focus.filter,
  406. raise = true,
  407. keys = clientkeys,
  408. buttons = clientbuttons } },
  409. { rule = { class = "MPlayer" },
  410. properties = { floating = true } },
  411. { rule = { class = "pinentry" },
  412. properties = { floating = true } },
  413. { rule = { class = "gimp" },
  414. properties = { floating = true } },
  415. -- Set Firefox to always map on tags number 2 of screen 1.
  416. -- { rule = { class = "Firefox" },
  417. -- properties = { tag = tags[1][2] } },
  418. }
  419. -- }}}
  420. -- {{{ Signals
  421. -- Signal function to execute when a new client appears.
  422. client.connect_signal("manage", function (c, startup)
  423. -- Enable sloppy focus
  424. c:connect_signal("mouse::enter", function(c)
  425. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  426. and awful.client.focus.filter(c) then
  427. client.focus = c
  428. end
  429. end)
  430. if not startup then
  431. -- Set the windows at the slave,
  432. -- i.e. put it at the end of others instead of setting it master.
  433. -- awful.client.setslave(c)
  434. -- Put windows in a smart way, only if they does not set an initial position.
  435. if not c.size_hints.user_position and not c.size_hints.program_position then
  436. awful.placement.no_overlap(c)
  437. awful.placement.no_offscreen(c)
  438. end
  439. end
  440. local titlebars_enabled = false
  441. if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  442. -- buttons for the titlebar
  443. local buttons = awful.util.table.join(
  444. awful.button({ }, 1, function()
  445. client.focus = c
  446. c:raise()
  447. awful.mouse.client.move(c)
  448. end),
  449. awful.button({ }, 3, function()
  450. client.focus = c
  451. c:raise()
  452. awful.mouse.client.resize(c)
  453. end)
  454. )
  455. -- Widgets that are aligned to the left
  456. local left_layout = wibox.layout.fixed.horizontal()
  457. left_layout:add(awful.titlebar.widget.iconwidget(c))
  458. left_layout:buttons(buttons)
  459. -- Widgets that are aligned to the right
  460. local right_layout = wibox.layout.fixed.horizontal()
  461. right_layout:add(awful.titlebar.widget.floatingbutton(c))
  462. right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  463. right_layout:add(awful.titlebar.widget.stickybutton(c))
  464. right_layout:add(awful.titlebar.widget.ontopbutton(c))
  465. right_layout:add(awful.titlebar.widget.closebutton(c))
  466. -- The title goes in the middle
  467. local middle_layout = wibox.layout.flex.horizontal()
  468. local title = awful.titlebar.widget.titlewidget(c)
  469. title:set_align("center")
  470. middle_layout:add(title)
  471. middle_layout:buttons(buttons)
  472. -- Now bring it all together
  473. local layout = wibox.layout.align.horizontal()
  474. layout:set_left(left_layout)
  475. layout:set_right(right_layout)
  476. layout:set_middle(middle_layout)
  477. awful.titlebar(c):set_widget(layout)
  478. end
  479. end)
  480. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  481. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  482. -- }}}