Advertisement
bvn13

Untitled

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