Advertisement
bvn13

Untitled

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