Advertisement
bvn13

Untitled

Sep 9th, 2013
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.89 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Theme handling library
  6. require("beautiful")
  7. -- Notification library
  8. require("naughty")
  9. -- Others
  10. require("vicious")
  11. require('couth.couth')
  12. require('couth.alsa')
  13. require("blingbling")
  14. require("utility")
  15.  
  16. --{{---| Java GUI's fix |---------------------------------------------------------------------------
  17.  
  18. awful.util.spawn_with_shell("wmname LG3D")
  19.  
  20.  
  21. -- {{{ Error handling
  22. -- Check if awesome encountered an error during startup and fell back to
  23. -- another config (This code will only ever execute for the fallback config)
  24. if awesome.startup_errors then
  25. naughty.notify({ preset = naughty.config.presets.critical,
  26. title = "Oops, there were errors during startup!",
  27. text = awesome.startup_errors })
  28. end
  29.  
  30. -- Handle runtime errors after startup
  31. do
  32. local in_error = false
  33. awesome.add_signal("debug::error", function (err)
  34. -- Make sure we don't go into an endless error loop
  35. if in_error then return end
  36. in_error = true
  37.  
  38. naughty.notify({ preset = naughty.config.presets.critical,
  39. title = "Oops, an error happened!",
  40. text = err })
  41. in_error = false
  42. end)
  43. end
  44. -- }}}
  45.  
  46. -- {{{ Settings
  47. config_dir = ("/home/bvn13/.config/awesome/")
  48. themes_dir = (config_dir .. "/themes")
  49. beautiful.init(themes_dir .. "/powerarrow-dark/theme.lua")
  50. -- }}} Settings
  51.  
  52. -- {{{ Variable definitions
  53. -- Themes define colours, icons, and wallpapers
  54. -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  55.  
  56. -- This is used later as the default terminal and editor to run.
  57. terminal = "sakura"
  58. editor = os.getenv("EDITOR") or "vim"
  59. editor_cmd = terminal .. " -e " .. editor
  60. musicplrayer = "lilyterm -T Music -g 130x34-320+16 -e mocp"
  61. browser = "google-chrome"
  62. fm = "spacefm"
  63.  
  64.  
  65.  
  66. -- Default modkey.
  67. -- Usually, Mod4 is the key with a logo between Control and Alt.
  68. -- If you do not like this or do not have such a key,
  69. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  70. -- However, you can use another modifier like Mod1, but it may interact with others.
  71. modkey = "Mod4"
  72.  
  73. -- Table of layouts to cover with awful.layout.inc, order matters.
  74. layouts =
  75. {
  76. awful.layout.suit.floating,
  77. awful.layout.suit.tile,
  78. awful.layout.suit.tile.left,
  79. awful.layout.suit.tile.bottom,
  80. awful.layout.suit.tile.top,
  81. -- awful.layout.suit.fair,
  82. -- awful.layout.suit.fair.horizontal,
  83. -- awful.layout.suit.spiral,
  84. -- awful.layout.suit.spiral.dwindle,
  85. awful.layout.suit.max,
  86. -- awful.layout.suit.max.fullscreen,
  87. -- awful.layout.suit.magnifier
  88. }
  89. -- }}}
  90.  
  91. -- {{{ Tags
  92. -- Define a tag table which hold all screen tags.
  93. tags = {
  94. names = { "~", "⠐", "⠡", "⠪", "⠵", "⠻", "⠿", "α", "β", "γ", "δ", "T" },
  95. layouts = { layouts[2], layouts[6], layouts[6], layouts[2], layouts[2], layouts[3], layouts[6], layouts[1], layouts[1], layouts[1], layouts[6], layouts[1] }
  96. }
  97. for s = 1, screen.count() do
  98. -- Each screen has its own tag table.
  99. -- tags[s] = awful.tag({ "~", "⠐", "⠡", "⠪", "⠵", "⠻", "⠿", "α", "β", "γ", "δ", "T" }, s, layouts[1])
  100. tags[s] = awful.tag(tags.names, s, tags.layouts)
  101. awful.tag.setncol(2, tags[s][4])
  102. awful.tag.setproperty(tags[s][4], "mwfact", 0.20)
  103. end
  104. -- }}}
  105.  
  106. -- {{{ Menu
  107. -- Create a laucher widget and a main menu
  108. myawesomemenu = {
  109. { "manual", terminal .. " -e man awesome" },
  110. { "edit config", editor_cmd .. " " .. awesome.conffile },
  111. { "restart", awesome.restart },
  112. { "quit", awesome.quit }
  113. }
  114.  
  115. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  116. { "open terminal", terminal }
  117. }
  118. })
  119.  
  120. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  121. menu = mymainmenu })
  122. -- }}}
  123.  
  124. -- {{{ Wibox
  125. -- Create a textclock widget
  126. mytextclock = awful.widget.textclock({ align = "right" })
  127.  
  128. -- Create a systray
  129. mysystray = widget({ type = "systray" })
  130.  
  131. -- {{{ Keyboard layouts
  132. -- Create widget
  133. kbdwidget = widget({type = "textbox", name = "kbdwidget"})
  134. kbdwidget.border_color = beautiful.fg_normal
  135. kbdwidget.text = "Eng"
  136.  
  137. -- Listen DBUS
  138. dbus.request_name("session", "ru.gentoo.kbdd")
  139. dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
  140. dbus.add_signal("ru.gentoo.kbdd", function(...)
  141. local data = {...}
  142. local layout = data[2]
  143. lts = {[0] = "Eng", [1] = "Рус"}
  144. kbdwidget.text = " "..lts[layout].." "
  145. end
  146. )
  147.  
  148. -- }}} Keyboard layoutds
  149.  
  150.  
  151. -- Create a wibox for each screen and add it
  152. mywibox = {}
  153. mypromptbox = {}
  154. mylayoutbox = {}
  155. mytaglist = {}
  156. mytaglist.buttons = awful.util.table.join(
  157. awful.button({ }, 1, awful.tag.viewonly),
  158. awful.button({ modkey }, 1, awful.client.movetotag),
  159. awful.button({ }, 3, awful.tag.viewtoggle),
  160. awful.button({ modkey }, 3, awful.client.toggletag),
  161. awful.button({ }, 4, awful.tag.viewnext),
  162. awful.button({ }, 5, awful.tag.viewprev)
  163. )
  164. mytasklist = {}
  165. mytasklist.buttons = awful.util.table.join(
  166. awful.button({ }, 1, function (c)
  167. if c == client.focus then
  168. c.minimized = true
  169. else
  170. if not c:isvisible() then
  171. awful.tag.viewonly(c:tags()[1])
  172. end
  173. -- This will also un-minimize
  174. -- the client, if needed
  175. client.focus = c
  176. c:raise()
  177. end
  178. end),
  179. awful.button({ }, 3, function ()
  180. if instance then
  181. instance:hide()
  182. instance = nil
  183. else
  184. instance = awful.menu.clients({ width=250 })
  185. end
  186. end),
  187. awful.button({ }, 4, function ()
  188. awful.client.focus.byidx(1)
  189. if client.focus then client.focus:raise() end
  190. end),
  191. awful.button({ }, 5, function ()
  192. awful.client.focus.byidx(-1)
  193. if client.focus then client.focus:raise() end
  194. end))
  195.  
  196. for s = 1, screen.count() do
  197. -- Create a promptbox for each screen
  198. mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  199. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  200. -- We need one layoutbox per screen.
  201. mylayoutbox[s] = awful.widget.layoutbox(s)
  202. mylayoutbox[s]:buttons(awful.util.table.join(
  203. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  204. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  205. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  206. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  207. -- Create a taglist widget
  208. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  209.  
  210. -- Create a tasklist widget
  211. mytasklist[s] = awful.widget.tasklist(function(c)
  212. return awful.widget.tasklist.label.currenttags(c, s)
  213. end, mytasklist.buttons)
  214.  
  215. -- Create the wibox
  216. mywibox[s] = awful.wibox({ position = "top", screen = s })
  217. -- Add widgets to the wibox - order matters
  218. mywibox[s].widgets = {
  219. {
  220. mylauncher,
  221. mytaglist[s],
  222. mypromptbox[s],
  223. layout = awful.widget.layout.horizontal.leftright
  224. },
  225. mylayoutbox[s],
  226. kbwidget,
  227. mytextclock,
  228. s == 1 and mysystray or nil,
  229. mytasklist[s],
  230. layout = awful.widget.layout.horizontal.rightleft
  231. }
  232. end
  233. -- }}}
  234.  
  235. -- {{{ Mouse bindings
  236. root.buttons(awful.util.table.join(
  237. awful.button({ }, 3, function () mymainmenu:toggle() end),
  238. awful.button({ }, 4, awful.tag.viewnext),
  239. awful.button({ }, 5, awful.tag.viewprev)
  240. ))
  241. -- }}}
  242.  
  243. -- {{{ Key bindings
  244. globalkeys = awful.util.table.join(
  245. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  246. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  247. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  248.  
  249. awful.key({ modkey, }, "j",
  250. function ()
  251. awful.client.focus.byidx( 1)
  252. if client.focus then client.focus:raise() end
  253. end),
  254. awful.key({ modkey, }, "k",
  255. function ()
  256. awful.client.focus.byidx(-1)
  257. if client.focus then client.focus:raise() end
  258. end),
  259. awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
  260.  
  261. -- Layout manipulation
  262. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  263. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  264. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  265. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  266. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  267. awful.key({ modkey, }, "Tab",
  268. function ()
  269. awful.client.focus.history.previous()
  270. if client.focus then
  271. client.focus:raise()
  272. end
  273. end),
  274.  
  275. -- Standard program
  276. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  277. awful.key({ modkey, "Control" }, "r", awesome.restart),
  278. awful.key({ modkey, "Control" }, "q", awesome.quit),
  279.  
  280. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  281. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  282. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  283. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  284. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  285. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  286. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  287. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  288.  
  289. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  290.  
  291. -- Prompt
  292. awful.key({ modkey }, "d", function () mypromptbox[mouse.screen]:run() end),
  293.  
  294. awful.key({ modkey }, "x",
  295. function ()
  296. awful.prompt.run({ prompt = "Run Lua code: " },
  297. mypromptbox[mouse.screen].widget,
  298. awful.util.eval, nil,
  299. awful.util.getdir("cache") .. "/history_eval")
  300. end)
  301. )
  302.  
  303. clientkeys = awful.util.table.join(
  304. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  305. awful.key({ modkey, "Shift" }, "q", function (c) c:kill() end),
  306. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  307. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  308. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  309. awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
  310. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  311. awful.key({ modkey, }, "n",
  312. function (c)
  313. -- The client currently has the input focus, so it cannot be
  314. -- minimized, since minimized clients can't have the focus.
  315. c.minimized = true
  316. end),
  317. awful.key({ modkey, }, "m",
  318. function (c)
  319. c.maximized_horizontal = not c.maximized_horizontal
  320. c.maximized_vertical = not c.maximized_vertical
  321. end)
  322. )
  323.  
  324. -- Compute the maximum number of digit we need, limited to 9
  325. keynumber = 0
  326. for s = 1, screen.count() do
  327. keynumber = math.min(9, math.max(#tags[s], keynumber));
  328. end
  329.  
  330. -- Bind all key numbers to tags.
  331. -- Be careful: we use keycodes to make it works on any keyboard layout.
  332. -- This should map on the top row of your keyboard, usually 1 to 9.
  333. -- + tag of tilda
  334. globalkeys = awful.util.table.join(globalkeys,
  335. awful.key({ modkey }, "#49",
  336. function ()
  337. local screen = mouse.screen
  338. if tags[screen][1] then
  339. awful.tag.viewonly(tags[screen][1])
  340. end
  341. end),
  342. awful.key({ modkey, "Control" }, "#49",
  343. function ()
  344. local screen = mouse.screen
  345. if tags[screen][1] then
  346. awful.tag.viewtoggle(tags[screen][1])
  347. end
  348. end),
  349. awful.key({ modkey, "Shift" }, "#49",
  350. function ()
  351. if client.focus and tags[client.focus.screen][1] then
  352. awful.client.movetotag(tags[client.focus.screen][1])
  353. end
  354. end),
  355. awful.key({ modkey, "Control", "Shift" }, "#49",
  356. function ()
  357. if client.focus and tags[client.focus.screen][1] then
  358. awful.client.toggletag(tags[client.focus.screen][1])
  359. end
  360. end))
  361.  
  362. -- - tag of tilda
  363. for i = 1, keynumber do
  364. globalkeys = awful.util.table.join(globalkeys,
  365. awful.key({ modkey }, "#" .. i + 9,
  366. function ()
  367. local screen = mouse.screen
  368. if tags[screen][i+1] then
  369. awful.tag.viewonly(tags[screen][i+1])
  370. end
  371. end),
  372. awful.key({ modkey, "Control" }, "#" .. i + 9,
  373. function ()
  374. local screen = mouse.screen
  375. if tags[screen][i+1] then
  376. awful.tag.viewtoggle(tags[screen][i+1])
  377. end
  378. end),
  379. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  380. function ()
  381. if client.focus and tags[client.focus.screen][i+1] then
  382. awful.client.movetotag(tags[client.focus.screen][i+1])
  383. end
  384. end),
  385. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  386. function ()
  387. if client.focus and tags[client.focus.screen][i+1] then
  388. awful.client.toggletag(tags[client.focus.screen][i+1])
  389. end
  390. end))
  391. end
  392.  
  393. clientbuttons = awful.util.table.join(
  394. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  395. awful.button({ modkey }, 1, awful.mouse.client.move),
  396. awful.button({ modkey }, 3, awful.mouse.client.resize))
  397.  
  398. -- Set keys
  399. root.keys(globalkeys)
  400. -- }}}
  401.  
  402. -- {{{ Rules
  403. awful.rules.rules = {
  404. -- All clients will match this rule.
  405. { rule = { },
  406. properties = { border_width = beautiful.border_width,
  407. border_color = beautiful.border_normal,
  408. focus = true,
  409. keys = clientkeys,
  410. buttons = clientbuttons } },
  411. { rule = { class = "MPlayer" },
  412. properties = { floating = true } },
  413. { rule = { class = "pinentry" },
  414. properties = { floating = true } },
  415. { rule = { class = "gimp" },
  416. properties = { floating = true } },
  417. -- Set Firefox to always map on tags number 2 of screen 1.
  418. { rule = { class = "Firefox" },
  419. properties = { tag = tags[1][3] } },
  420. { rule = { class = "Vlc" },
  421. properties = { tag = tags[1][8] } },
  422. { rule = { class = "Smplayer" },
  423. properties = { tag = tags[1][8] } },
  424. { rule = { class = "Google-chrome" },
  425. properties = { tag = tags[1][3] } },
  426. { rule = { class = "Sakura" },
  427. properties = { tag = tags[1][1] } },
  428. { rule = { class = "Thunderbird" },
  429. properties = { tag = tags[1][7] } },
  430. { rule = { class = "Vacuum" },
  431. properties = { tag = tags[1][4] } },
  432. { rule = { class = "Pidgin", role = "buddy_list" },
  433. properties = { tag = tags[1][5] } },
  434. { rule = { class = "Pidgin", role = "conversation"},
  435. properties = { tag = tags[1][5]}, callback = awful.client.setslave },
  436. { rule = { class = "Skype" },
  437. properties = { tag = tags[1][6] } },
  438. { rule = { class = "VirtualBox" },
  439. properties = { tag = tags[1][9] } },
  440. { rule = { class = "Wine", instance = "TeamViewer.exe" },
  441. properties = { tag = tags[1][12], floating = true } },
  442. { rule = { class = "Qtcreator" },
  443. properties = { tag = tags[1][2] } },
  444.  
  445. }
  446. -- }}}
  447.  
  448. -- {{{ Signals
  449. -- Signal function to execute when a new client appears.
  450. client.add_signal("manage", function (c, startup)
  451. -- Add a titlebar
  452. -- awful.titlebar.add(c, { modkey = modkey })
  453.  
  454. -- Enable sloppy focus
  455. c:add_signal("mouse::enter", function(c)
  456. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  457. and awful.client.focus.filter(c) then
  458. client.focus = c
  459. end
  460. end)
  461.  
  462. if not startup then
  463. -- Set the windows at the slave,
  464. -- i.e. put it at the end of others instead of setting it master.
  465. -- awful.client.setslave(c)
  466.  
  467. -- Put windows in a smart way, only if they does not set an initial position.
  468. if not c.size_hints.user_position and not c.size_hints.program_position then
  469. awful.placement.no_overlap(c)
  470. awful.placement.no_offscreen(c)
  471. end
  472. end
  473. end)
  474.  
  475. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  476. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  477. -- }}}
  478.  
  479. -- {{{ Autorun
  480. autorun = true
  481.  
  482. autorunApps = --Приложения, которым нужен перезапуск при перезапуске AwesomeWM
  483. {
  484. }
  485.  
  486. runOnceApps = --Приложения, при перезапуске которых появляется нежелательная вторая копия
  487. {
  488. }
  489.  
  490. if autorun then
  491. for app = 1, #autorunApps do
  492. awful.util.spawn(autorunApps[app])
  493. end
  494. for app = 1, #runOnceApps do
  495. utility.run_once(runOnceApps[app])
  496. end
  497. end
  498.  
  499. --{{---| run_once |---------------------------------------------------------------------------------
  500.  
  501. function run_once(prg)
  502. awful.util.spawn_with_shell("pgrep -u $USER -x " .. prg .. " || (" .. prg .. ")") end
  503.  
  504. --{{---| run_once with args |-----------------------------------------------------------------------
  505.  
  506. function run_oncewa(prg) if not prg then do return nil end end
  507. awful.util.spawn_with_shell('ps ux | grep -v grep | grep -F ' .. prg .. ' || ' .. prg .. ' &') end
  508.  
  509. -- }}} Autorum
  510. -- "ietxkbmap -layout 'us,ru' -variant ',winkeys,winkeys' -option grp:caps_toggle -option grp_led:caps -option terminate:ctrl_alt_bksp"
  511.  
  512. -- {{{ Keyboard layouts
  513. os.execute("setxkbmap -layout 'us,ru' -variant 'winkeys' -option 'grp:caps_toggle,grp_led:caps,compose:ralt' &")
  514. run_once("kbdd")
  515. -- }}} Keyboard layouts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement