Advertisement
Guest User

Untitled

a guest
Jan 7th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.83 KB | None | 0 0
  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. require("blingbling")
  7. -- Widget and layout library
  8. local wibox = require("wibox")
  9. -- Theme handling library
  10. local beautiful = require("beautiful")
  11. -- Notification library
  12. local menubar = require("menubar")
  13. --Alt-Tab
  14. local alttab = require("alttab")
  15.  
  16. os.setlocale(os.getenv("LANG"))
  17.  
  18. -- Load Debian menu entries
  19. require("debian.menu")
  20.  
  21. -- {{{ Variable definitions
  22. -- Themes define colours, icons, font and wallpapers.
  23. beautiful.init("/home/nika/.config/awesome/themes/zenburn/theme.lua")
  24.  
  25. -- This is used later as the default terminal and editor to run.
  26. terminal = "x-terminal-emulator"
  27. editor = os.getenv("EDITOR") or "editor"
  28. editor_cmd = terminal .. " -e " .. editor
  29.  
  30. -- Default modkey.
  31. -- Usually, Mod4 is the key with a logo between Control and Alt.
  32. -- If you do not like this or do not have such a key,
  33. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  34. -- However, you can use another modifier like Mod1, but it may interact with others.
  35. modkey = "Mod4"
  36.  
  37. -- Table of layouts to cover with awful.layout.inc, order matters.
  38. local layouts =
  39. {
  40. awful.layout.suit.floating,
  41. awful.layout.suit.tile.left,
  42. awful.layout.suit.tile.bottom,
  43. awful.layout.suit.max.fullscreen
  44. }
  45. -- }}}
  46.  
  47. -- {{{ Wallpaper
  48. if beautiful.wallpaper then
  49. for s = 1, screen.count() do
  50. gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  51. end
  52. end
  53. -- }}}
  54.  
  55. -- {{{ Tags
  56. -- Define a tag table which hold all screen tags.
  57. tags = {names = { "1", "2", "3", "4", "5", "6" },
  58. layout = { layouts[4], layouts[2], layouts[2], layouts[2], layouts[2], layouts[2]}}
  59. for s = 1, screen.count() do
  60. -- Each screen has its own tag table.
  61. tags[s] = awful.tag(tags.names, s, tags.layout)
  62. end
  63. -- }}}
  64.  
  65. -- {{{ Menu
  66. -- Create a laucher widget and a main menu
  67. myawesomemenu = {
  68. { "manual", terminal .. " -e man awesome" },
  69. { "edit config", editor_cmd .. " " .. awesome.conffile },
  70. { "restart", awesome.restart },
  71. { "quit", awesome.quit }
  72. }
  73.  
  74. mymainmenu = awful.menu({ items = { --{ "awesome", myawesomemenu, beautiful.awesome_icon },
  75. { "Выключение", 'sudo halt -p' },
  76. { "Перезагрузка", 'sudo reboot' },
  77. { "Гибернация", 'sudo pm-hibernate' },
  78. { "Сон", 'sudo pm-suspend' },
  79. { "Рестарт", awesome.restart },
  80. { "Выйти", awesome.quit }
  81. --{ "Debian", debian.menu.Debian_menu.Debian },
  82. --{ "open terminal", terminal }
  83. }
  84. })
  85.  
  86. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  87. menu = mymainmenu })
  88.  
  89. -- Menubar configuration
  90. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  91. -- }}}
  92.  
  93. -- {{{ Wibox
  94. -- Create a textclock widget
  95. mytextclock = awful.widget.textclock()
  96.  
  97. -- Create a wibox for each screen and add it
  98. mywibox = {}
  99. mypromptbox = {}
  100. mylayoutbox = {}
  101. mytaglist = {}
  102. mytaglist.buttons = awful.util.table.join(
  103. awful.button({ }, 1, awful.tag.viewonly),
  104. awful.button({ modkey }, 1, awful.client.movetotag),
  105. awful.button({ }, 3, awful.tag.viewtoggle),
  106. awful.button({ modkey }, 3, awful.client.toggletag),
  107. awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  108. awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  109. )
  110. mytasklist = {}
  111. mytasklist.buttons = awful.util.table.join(
  112. awful.button({ }, 1, function (c)
  113. if c == client.focus then
  114. c.minimized = true
  115. else
  116. -- Without this, the following
  117. -- :isvisible() makes no sense
  118. c.minimized = false
  119. if not c:isvisible() then
  120. awful.tag.viewonly(c:tags()[1])
  121. end
  122. -- This will also un-minimize
  123. -- the client, if needed
  124. client.focus = c
  125. c:raise()
  126. end
  127. end),
  128. awful.button({ }, 3, function ()
  129. if instance then
  130. instance:hide()
  131. instance = nil
  132. else
  133. instance = awful.menu.clients({
  134. theme = { width = 250 }
  135. })
  136. end
  137. end),
  138. awful.button({ }, 4, function ()
  139. awful.client.focus.byidx(1)
  140. if client.focus then client.focus:raise() end
  141. end),
  142. awful.button({ }, 5, function ()
  143. awful.client.focus.byidx(-1)
  144. if client.focus then client.focus:raise() end
  145. end))
  146.  
  147. for s = 1, screen.count() do
  148. -- Create a promptbox for each screen
  149. mypromptbox[s] = awful.widget.prompt()
  150. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  151. -- We need one layoutbox per screen.
  152. mylayoutbox[s] = awful.widget.layoutbox(s)
  153. mylayoutbox[s]:buttons(awful.util.table.join(
  154. awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  155. awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  156. awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  157. awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  158. -- Create a taglist widget
  159. mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  160.  
  161. -- Create a tasklist widget
  162. mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  163.  
  164. -- Create the wibox
  165. mywibox[s] = awful.wibox({ position = "top", screen = s })
  166.  
  167. -- Widgets that are aligned to the left
  168. local left_layout = wibox.layout.fixed.horizontal()
  169. --left_layout:add(mylauncher)
  170. left_layout:add(mytaglist[s])
  171. left_layout:add(mypromptbox[s])
  172.  
  173. -- Widgets that are aligned to the right
  174. local right_layout = wibox.layout.fixed.horizontal()
  175. if s == 1 then right_layout:add(wibox.widget.systray()) end
  176. right_layout:add(mytextclock)
  177. right_layout:add(mylayoutbox[s])
  178.  
  179. -- Now bring it all together (with the tasklist in the middle)
  180. local layout = wibox.layout.align.horizontal()
  181. layout:set_left(left_layout)
  182. layout:set_middle(mytasklist[s])
  183. layout:set_right(right_layout)
  184.  
  185. mywibox[s]:set_widget(layout)
  186. end
  187. -- }}}
  188.  
  189. -- {{{ Mouse bindings
  190. root.buttons(awful.util.table.join(
  191. awful.button({ }, 3, function () mymainmenu:toggle() end),
  192. awful.button({ }, 4, awful.tag.viewnext),
  193. awful.button({ }, 5, awful.tag.viewprev)
  194. ))
  195. -- }}}
  196.  
  197. -- {{{ Key bindings
  198. globalkeys = awful.util.table.join(
  199. awful.key({ modkey, }, "Left", awful.tag.viewprev ),
  200. awful.key({ modkey, }, "Right", awful.tag.viewnext ),
  201. awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  202.  
  203. awful.key({ modkey, }, "j",
  204. function ()
  205. awful.client.focus.byidx( 1)
  206. if client.focus then client.focus:raise() end
  207. end),
  208. awful.key({ modkey, }, "k",
  209. function ()
  210. awful.client.focus.byidx(-1)
  211. if client.focus then client.focus:raise() end
  212. end),
  213. awful.key({ modkey, }, "w", function () mymainmenu:show() end),
  214.  
  215. -- Layout manipulation
  216. awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
  217. awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
  218. awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  219. awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  220. awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
  221. awful.key({ modkey, }, "Tab",
  222. function ()
  223. awful.client.focus.history.previous()
  224. if client.focus then
  225. client.focus:raise()
  226. end
  227. end),
  228.  
  229. --Alt-Tab
  230. awful.key({ "Mod1", }, "Tab",
  231. function ()
  232. alttab.switch(1, "Alt_L", "Tab", "ISO_Left_Tab")
  233. end
  234. ),
  235.  
  236. awful.key({ "Mod1", "Shift" }, "Tab",
  237. function ()
  238. alttab.switch(-1, "Alt_L", "Tab", "ISO_Left_Tab")
  239. end
  240. ),
  241.  
  242. -- Standard program
  243. awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  244. awful.key({ modkey, "Control" }, "r", awesome.restart),
  245. awful.key({ modkey, "Shift" }, "q", awesome.quit),
  246.  
  247. awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
  248. awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  249. awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
  250. awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
  251. awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
  252. awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
  253. awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
  254. awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
  255.  
  256. awful.key({ modkey, "Control" }, "n", awful.client.restore),
  257.  
  258. -- Prompt
  259. awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  260.  
  261. awful.key({ modkey }, "x",
  262. function ()
  263. awful.prompt.run({ prompt = "Run Lua code: " },
  264. mypromptbox[mouse.screen].widget,
  265. awful.util.eval, nil,
  266. awful.util.getdir("cache") .. "/history_eval")
  267. end),
  268. -- Menubar
  269. awful.key({ modkey }, "p", function() menubar.show() end)
  270. )
  271.  
  272. clientkeys = awful.util.table.join(
  273. awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
  274. awful.key({ modkey, }, "q", function (c) c:kill() end),
  275. awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
  276. awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  277. awful.key({ modkey, }, "o", awful.client.movetoscreen ),
  278. awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
  279. awful.key({ modkey, }, "n",
  280. function (c)
  281. -- The client currently has the input focus, so it cannot be
  282. -- minimized, since minimized clients can't have the focus.
  283. c.minimized = true
  284. end),
  285. awful.key({ modkey, }, "m",
  286. function (c)
  287. c.maximized_horizontal = not c.maximized_horizontal
  288. c.maximized_vertical = not c.maximized_vertical
  289. end)
  290. )
  291.  
  292. -- Bind all key numbers to tags.
  293. -- Be careful: we use keycodes to make it works on any keyboard layout.
  294. -- This should map on the top row of your keyboard, usually 1 to 9.
  295. for i = 1, 9 do
  296. globalkeys = awful.util.table.join(globalkeys,
  297. -- View tag only.
  298. awful.key({ modkey }, "#" .. i + 9,
  299. function ()
  300. local screen = mouse.screen
  301. local tag = awful.tag.gettags(screen)[i]
  302. if tag then
  303. awful.tag.viewonly(tag)
  304. end
  305. end),
  306. -- Toggle tag.
  307. awful.key({ modkey, "Control" }, "#" .. i + 9,
  308. function ()
  309. local screen = mouse.screen
  310. local tag = awful.tag.gettags(screen)[i]
  311. if tag then
  312. awful.tag.viewtoggle(tag)
  313. end
  314. end),
  315. -- Move client to tag.
  316. awful.key({ modkey, "Shift" }, "#" .. i + 9,
  317. function ()
  318. if client.focus then
  319. local tag = awful.tag.gettags(client.focus.screen)[i]
  320. if tag then
  321. awful.client.movetotag(tag)
  322. end
  323. end
  324. end),
  325. -- Toggle tag.
  326. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  327. function ()
  328. if client.focus then
  329. local tag = awful.tag.gettags(client.focus.screen)[i]
  330. if tag then
  331. awful.client.toggletag(tag)
  332. end
  333. end
  334. end))
  335. end
  336.  
  337. clientbuttons = awful.util.table.join(
  338. awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  339. awful.button({ modkey }, 1, awful.mouse.client.move),
  340. awful.button({ modkey }, 3, awful.mouse.client.resize))
  341.  
  342. -- Set keys
  343. root.keys(globalkeys)
  344. -- }}}
  345.  
  346. -- {{{ Rules
  347. -- Rules to apply to new clients (through the "manage" signal).
  348. awful.rules.rules = {
  349. -- All clients will match this rule.
  350. { rule = { },
  351. properties = { size_hints_honor = false,
  352. border_width = beautiful.border_width,
  353. border_color = beautiful.border_normal,
  354. focus = awful.client.focus.filter,
  355. raise = true,
  356. keys = clientkeys,
  357. buttons = clientbuttons } },
  358. { rule = { class = "Vlc" },
  359. properties = { floating = true } },
  360. { rule = { class = "pinentry" },
  361. properties = { floating = true } },
  362. { rule = { class = "gimp" },
  363. properties = { floating = true } },
  364. -- Set Firefox to always map on tags number 1 of screen 1.
  365. { rule = { class = "Firefox" },
  366. properties = { tag = tags[1][1] } },
  367. -- Правила для календарика
  368. { rule = { class = "Gsimplecal" },
  369. properties = { floating = true, geometry = {x = 874, y = 23}, border_width = 0 } },
  370. { rule = { class = "Kupfer.py" },
  371. properties = { floating = true, border_width = 0 } },
  372. { rule = { class = "Xfce4-notifyd" },
  373. properties = { floating = true, border_width = 0 } },
  374. }
  375. -- }}}
  376.  
  377. -- {{{ Signals
  378. -- Signal function to execute when a new client appears.
  379. client.connect_signal("manage", function (c, startup)
  380. -- Enable sloppy focus
  381. c:connect_signal("mouse::enter", function(c)
  382. if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  383. and awful.client.focus.filter(c) then
  384. client.focus = c
  385. end
  386. end)
  387.  
  388. if not startup then
  389. -- Set the windows at the slave,
  390. -- i.e. put it at the end of others instead of setting it master.
  391. -- awful.client.setslave(c)
  392.  
  393. -- Put windows in a smart way, only if they does not set an initial position.
  394. if not c.size_hints.user_position and not c.size_hints.program_position then
  395. awful.placement.no_overlap(c)
  396. awful.placement.no_offscreen(c)
  397. end
  398. end
  399.  
  400. local titlebars_enabled = false
  401. if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  402. -- buttons for the titlebar
  403. local buttons = awful.util.table.join(
  404. awful.button({ }, 1, function()
  405. client.focus = c
  406. c:raise()
  407. awful.mouse.client.move(c)
  408. end),
  409. awful.button({ }, 3, function()
  410. client.focus = c
  411. c:raise()
  412. awful.mouse.client.resize(c)
  413. end)
  414. )
  415.  
  416. -- Widgets that are aligned to the left
  417. local left_layout = wibox.layout.fixed.horizontal()
  418. left_layout:add(awful.titlebar.widget.iconwidget(c))
  419. left_layout:buttons(buttons)
  420.  
  421. -- Widgets that are aligned to the right
  422. local right_layout = wibox.layout.fixed.horizontal()
  423. right_layout:add(awful.titlebar.widget.floatingbutton(c))
  424. right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  425. right_layout:add(awful.titlebar.widget.stickybutton(c))
  426. right_layout:add(awful.titlebar.widget.ontopbutton(c))
  427. right_layout:add(awful.titlebar.widget.closebutton(c))
  428.  
  429. -- The title goes in the middle
  430. local middle_layout = wibox.layout.flex.horizontal()
  431. local title = awful.titlebar.widget.titlewidget(c)
  432. title:set_align("center")
  433. middle_layout:add(title)
  434. middle_layout:buttons(buttons)
  435.  
  436. -- Now bring it all together
  437. local layout = wibox.layout.align.horizontal()
  438. layout:set_left(left_layout)
  439. layout:set_right(right_layout)
  440. layout:set_middle(middle_layout)
  441.  
  442. awful.titlebar(c):set_widget(layout)
  443. end
  444. end)
  445.  
  446. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  447. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  448. -- }}}
  449.  
  450. -- Календарь
  451. mytextclock:buttons(awful.util.table.join(
  452. awful.button({ }, 1,
  453. function()
  454. awful.util.spawn("gsimplecal")
  455. end)
  456. ))
  457.  
  458.  
  459.  
  460. -- Автостарт
  461. --function run_once(cmd)
  462. --findme = cmd
  463. --firstspace = cmd:find(" ")
  464. --if firstspace then
  465. --findme = cmd:sub(0, firstspace-1)
  466. --end
  467. --awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
  468. --end
  469.  
  470. --run_once("xfce4-volumed")
  471. --run_once("kupfer")
  472. --run_once("nm-applet")
  473. --run_once("xfce4-power-manager")
  474. --run_once("clipit")
  475. --run_once("compton")
  476. --run_once("volumeicon")
  477. --run_once("fbxkb")
  478. --run_once("dropbox")
  479. --run_once("light-locker")
  480. --run_once("dropbox start")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement