Advertisement
Guest User

конфиг AWESOME

a guest
Nov 28th, 2011
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 31.38 KB | None | 0 0
  1. --------------------------------
  2. --        awesome.lua         --
  3. -- КОНФИГ AWESOME (by SQR218) --
  4. --  загружается через rc.lua  --
  5. --------------------------------
  6.  
  7. --{{{Подгрузка необходимых библиотек
  8. require("awful")
  9. require("awful.autofocus")
  10. require("awful.rules") -- awful, необходимый минимум
  11. require("beautiful") -- Темы
  12. require("naughty") -- Уведомления
  13. require("rodentbane") -- эмулятор мышки (можно убрать)
  14. --Подгрузка необходимых библиотек}}}
  15.  
  16.  
  17. --{{{Русская локаль
  18. os.setlocale('ru_RU.UTF-8') --}}}
  19.  
  20.  
  21. --{{{ Переменные (для использования в конфиге)
  22. awehome = awful.util.getdir("config") .. "/"
  23. homedir = os.getenv("HOME")
  24. username = os.getenv("USER")
  25. terminal = "urxvt"
  26. editor = os.getenv("EDITOR") or "vi"
  27. editor_cmd = terminal .. " -e " .. editor
  28. browser = "uzbl-browser"
  29. modkey = "Mod4" -- Клавиша модификатор, применяемая почти во всех хоткеях
  30. myip = "http://example.com" -- Мой IP-адрес
  31. wallpaperdir = homedir.."/pic/wallpapers" -- В этот каталог положить все "обои"
  32. alsachan = 'Master' -- Канал ALSA для отображения/регулирования громкости
  33. netint = 'eth0' -- Сетевой интерфейс
  34. -- Показывать место на этих дисках (точки монтирования).
  35. -- Второй параметр - как отображать
  36. fss = {
  37.     {"/home", "h"},
  38.     {"/media/music", "m"},
  39.     {"/media/torrent", "t"},
  40.     {"/", "/"}
  41. }
  42. -- Переменные (для использования в конфиге)}}}
  43.  
  44.  
  45. --{{{Таймеры
  46. mytimer3 = timer({ timeout = 3 })
  47. mytimer2 = timer({ timeout = 2 })
  48. mytimer1800 = timer({ timeout = 1800 })
  49. mytimer600 = timer({ timeout = 600 })
  50. --Таймеры}}}
  51.  
  52.  
  53. --{{{Функция смены обоев
  54. function wpchange()
  55.     awful.util.spawn("awsetbg -r " .. wallpaperdir)
  56. end
  57. -- Менять обои каждые 1800 секунд
  58. mytimer1800:add_signal("timeout", function() wpchange() end)
  59. --Функция смены обоев}}}
  60.  
  61.  
  62. --{{{тема
  63. beautiful.init(awehome .. "qliphoth/theme.lua") --}}}
  64.  
  65.  
  66. --{{{layouts
  67. layouts = {
  68.             awful.layout.suit.floating, --1
  69.             awful.layout.suit.tile, --2
  70.             awful.layout.suit.max, --3
  71.             awful.layout.suit.max.fullscreen, --4
  72.           }
  73. --layouts}}}
  74.  
  75.  
  76. --{{{Тэги
  77. tags = {}
  78. tags[1] = awful.tag({ "c", "b", "o", "m", "g", "t" }, 1, layouts[3])
  79. awful.layout.set(layouts[2], tags[1][5])
  80. --Тэги}}}
  81.  
  82.  
  83. --{{{Уведомления
  84. naughty.config.default_preset.position         = "bottom_right"
  85. naughty.config.default_preset.margin           = 4
  86. naughty.config.default_preset.gap              = 1
  87. naughty.config.default_preset.border_width     = 1
  88. --Уведомления}}}
  89.  
  90.  
  91. --{{{МЕНЮ
  92. mymainmenu = awful.menu({ items = {
  93.                                     { "terminal", terminal },
  94.                                     { "restart", awesome.restart },
  95.                                     { "quit", awesome.quit },
  96.                                   }
  97.                         })
  98. --МЕНЮ}}}
  99.  
  100.  
  101. --{{{ВИДЖЕТЫ
  102.  
  103. --{{{Лаунчер (главное меню)
  104. --mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), menu = mymainmenu }) --}}}
  105.  
  106. --{{{Трэй
  107. mysystray = widget({ type = "systray" })--}}}
  108.  
  109. --{{{Splitter (разделитель)
  110. sp = widget({ type = "textbox" })
  111. sp.text = " | "
  112. --Splitter (разделитель)}}}
  113.  
  114. --{{{Память
  115. memic  = widget({ type = "imagebox", align = "right" })
  116. memic.image  = image( beautiful.memory_icon )
  117. memwidget = widget({ type = "textbox" })
  118. function memInfo()
  119.     local free = 0
  120.     local total = 0
  121.     for line in io.lines("/proc/meminfo") do
  122.         for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+") do
  123.             if     k == "MemTotal"  then total = v
  124.             elseif k == "MemFree" or k == "Buffers" or k == "Cached"  then free = v+free
  125.             end
  126.         end
  127.     end
  128.     memwidget.text = " " .. 100-math.floor(free / total * 100) .. "%"
  129. end
  130. memInfo()
  131. mytimer3:add_signal("timeout", function() memInfo() end)
  132. memic:buttons(awful.util.table.join(
  133.     awful.button({ }, 1, function() awful.util.spawn(terminal.." -e htop") end)
  134. ))
  135. --Память}}}
  136.  
  137. --{{{Процессор
  138. cpuic  = widget({ type = "imagebox", align = "right" })
  139. cpuic.image  = image( beautiful.cpu_icon )
  140. cpuwidget = widget({ type = "textbox" })
  141. function cpuInfo()
  142.    for line in io.lines("/proc/stat") do
  143.        local cpu, newjiffies = string.match(line, "(cpu)\ +(%d+)")
  144.        if cpu and newjiffies then
  145.            if not jiffies then
  146.                jiffies = newjiffies
  147.            end
  148.            cpuwidget.text = string.format(" %02d%%", (newjiffies-jiffies)/4)
  149.            jiffies = newjiffies
  150.        end
  151.    end
  152.    end
  153. mytimer2:add_signal("timeout", function() cpuInfo() end)
  154. cpuic:buttons(awful.util.table.join(
  155.     awful.button({ }, 1, function() awful.util.spawn(terminal.." -e htop") end)
  156. ))
  157. --Процессор}}}
  158.  
  159. --{{{Громкость
  160. volic  = widget({ type = "imagebox", align = "right" })
  161. volic.image  = image( beautiful.volume_icon )
  162. volwidget = widget({ type = "textbox" })
  163. function volInfo()
  164.     local f = io.popen(string.format("amixer get '%s'",alsachan)) -- ALSA
  165.     --local f = io.popen("ossmix vmix0-outvol") -- OSS
  166.     local mixer = f:read("*all")
  167.     f:close()
  168.     local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
  169.     --local volu = string.match(mixer, "Value of mixer control.*%s(.*)..*%d+.*")
  170.     volu = tonumber(volu) --*4 --for OSS
  171.     if volu < 40 then volic.image  = image( beautiful.vollow_icon ) end
  172.     if volu > 39 and volu < 65 then volic.image  = image( beautiful.volmed_icon ) end
  173.     if volu > 64 then volic.image  = image( beautiful.volhigh_icon ) end
  174.     if not mute and not volu or mute == "off" then volic.image  = image( beautiful.mute_icon ) end
  175.     volwidget.text = volu .. "%"
  176. end
  177. mytimer2:add_signal("timeout", function() volInfo() end)
  178. volic:buttons(awful.util.table.join(
  179.     awful.button({ }, 1, function() awful.util.spawn(string.format("amixer -q set '%s' toggle",alsachan)) volInfo() end),
  180.     awful.button({ }, 3, function() awful.util.spawn(terminal .. " -e alsamixer") end),
  181.     awful.button({ }, 4, function() awful.util.spawn(string.format("amixer set '%s' 2dB+",alsachan)) volInfo() end),
  182.     awful.button({ }, 5, function() awful.util.spawn(string.format("amixer set '%s' 2dB-",alsachan)) volInfo() end)
  183.     --awful.button({ }, 4, function() awful.util.spawn("ossmix -d0 vmix0-outvol -- +1") volInfo() end),
  184.     --awful.button({ }, 5, function() awful.util.spawn("ossmix -d0 vmix0-outvol -- -1") volInfo() end)
  185. ))
  186. volInfo()
  187. --Громкость}}}
  188.  
  189. --{{{Джаббер
  190. chic  = widget({ type = "imagebox", align = "right" })
  191. chic.image  = image( beautiful.chat_icon )
  192. chwidget = widget({ type = "textbox" })
  193. function chInfo()
  194.     local f = io.popen("cat .mcabber/mcabber.state | wc -l")
  195.     local n = f:read("*all")
  196.     f:close()
  197.     if n == "0\n" then
  198.         chwidget.text = " 0"
  199.     else
  200.         chwidget.text = string.format(' <span color="#FF0000">%s</span>',n)
  201.     end
  202. end
  203. chInfo()
  204. mytimer2:add_signal("timeout", function() chInfo() end)
  205. --Джаббер}}}
  206.  
  207. --{{{Место на дисках
  208. fsic  = widget({ type = "imagebox", align = "right" })
  209. fsic.image  = image( beautiful.disk_icon )
  210. fswidget = widget({type = "textbox", name = "fswidget", align = "right" })
  211. ifs = 0
  212. function fsInfo()
  213.    ifs = ifs+1
  214.    if ifs > #fss then ifs = 1 end
  215.    local f = io.popen('df -kP ' .. fss[ifs][1] ..' | grep -e /')
  216.    local u,space,p = string.match(f:read(), "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%")
  217.    f:close()
  218.    space = space / 1048576 -- переводим из байт в гигабайты
  219.    fswidget.text = string.format("%s: %.1fGb", fss[ifs][2], space)
  220. end
  221. fsInfo()
  222. mytimer3:add_signal("timeout", function() fsInfo() end)
  223. fsic:buttons(awful.util.table.join(
  224.     awful.button({ }, 1, function()
  225.         naughty.notify({
  226.             title = "Место на дисках",
  227.             text = awful.util.pread("df -h"),
  228.             timeout = 0, hover_timeout = 0.1
  229.         })
  230.     end)
  231. ))
  232. --Место на дисках}}}
  233.  
  234. --{{{Активность сети
  235. netupic = widget({ type = "imagebox", align = "right" })
  236. netupic.image  = image( beautiful.upload_icon )
  237. netdownic = widget({ type = "imagebox", align = "right" })
  238. netdownic.image  = image(beautiful.download_icon)
  239. netwidget = widget({ type = "textbox" })
  240. function netInfo()
  241.     for line in io.lines("/proc/net/dev") do
  242.       local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
  243.       if name == netint then
  244.         local sysnet = "/sys/class/net/" .. name
  245.         arar = tonumber(sysnet.carrier) or 0
  246.         if recvo == nil then
  247.             recvo = tonumber(string.match(line, ":[%s]*([%d]+)"))
  248.             sendo = tonumber(string.match(line,"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
  249.             rtime = os.time()
  250.         end
  251.         local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
  252.         local send = tonumber(string.match(line,"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
  253.         local interval  = os.time() - rtime >  0 and os.time() - rtime or 1
  254.         rtime = os.time()
  255.         local down = (recv - recvo) / interval / 1024 / 1024
  256.         local up   = (send - sendo) / interval / 1024 / 1024
  257.         netwidget.text = string.format(" %.1f | %.1f ",down,up)
  258.         recvo = recv
  259.         sendo = send
  260.       end
  261.     end
  262. end
  263. netInfo()
  264. mytimer2:add_signal("timeout", function() netInfo() end)
  265. --Активность сети}}}
  266.  
  267. --{{{Почта
  268. mailic = widget({ type = "imagebox", align = "right" })
  269. mailic.image  = image( beautiful.mail_icon )
  270. mailwidget = widget({ type = "textbox" })
  271. function mailInfo()
  272.     mbox = "/var/mail/"..username
  273.     local count = { old = 0, total = 0, new = 0 }
  274.  
  275.     -- Get data from mbox files
  276.     local f = io.open(mbox)
  277.     while true do
  278.         -- Read the mbox line by line, if we are going to read
  279.         -- some *HUGE* folders then switch to reading chunks
  280.         local lines = f:read("*line")
  281.         if not lines then break end
  282.  
  283.         -- Find all messages
  284.         --  * http://www.jwz.org/doc/content-length.html
  285.         local _, from = string.find(lines, "^From[%s]")
  286.         if from ~= nil then count.total = count.total + 1 end
  287.  
  288.         -- Read messages have the Status header
  289.         local _, status = string.find(lines, "^Status:[%s]RO$")
  290.         if status ~= nil then count.old = count.old + 1 end
  291.  
  292.         -- Skip the folder internal data
  293.         local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA")
  294.         if int ~= nil then count.total = count.total - 1 end
  295.     end
  296.     f:close()
  297.  
  298.     -- Substract total from old to get the new count
  299.     count.new = count.total - count.old
  300.     if count.new>0 then
  301.         mailwidget.text = string.format(' <span color="#FF0000">%s</span>',count.new)
  302.     else
  303.         mailwidget.text = " "..count.new
  304.     end
  305.     --return {count.total, count.old, count.new}
  306. end
  307. mailInfo()
  308. mytimer2:add_signal("timeout", function() mailInfo() end)
  309. mailic:buttons(awful.util.table.join(
  310.     awful.button({ }, 1, function() awful.util.spawn(terminal.." -e mutt") end)
  311. ))
  312. --Почта}}}
  313.  
  314. --{{{Часы и календарь
  315. clockic  = widget({ type = "imagebox", align = "right" })
  316. clockic.image  = image( beautiful.time_icon )
  317. mytextclock = awful.widget.textclock({ align = "right"}, " %d %b, %a %H:%M")
  318. local calendar = nil
  319. local offset = 0
  320. function remove_calendar()
  321.     if calendar ~= nil then
  322.         naughty.destroy(calendar)
  323.         calendar = nil
  324.         offset = 0
  325.     end
  326. end
  327. function add_calendar(inc_offset)
  328.     local save_offset = offset
  329.     remove_calendar()
  330.     offset = save_offset + inc_offset
  331.     local datespec = os.date("*t")
  332.     datespec = datespec.year * 12 + datespec.month - 1 + offset
  333.     datespec = (datespec % 12 + 1) .. " " .. math.floor(datespec / 12)
  334.     local cal = awful.util.pread("cal -m " .. datespec)
  335.     cal = string.gsub(cal, "^%s*(.-)%s*$", "%1")
  336.     calendar = naughty.notify({
  337.         title = string.format(os.date("%A, %d.%m.%y")),
  338.         text = string.format("\n" .. cal),
  339.         timeout = 0, hover_timeout = 0.5
  340.     })
  341. end
  342. clockic:buttons(awful.util.table.join(
  343.     awful.button({ }, 1, function() add_calendar(0) end),
  344.     awful.button({ }, 3, remove_calendar),
  345.     awful.button({ }, 4, function() add_calendar(-1) end),
  346.     awful.button({ }, 5, function() add_calendar(1) end)
  347. ))
  348. --Часы и календарь}}}
  349.  
  350. --{{{Now playing (deadbeef)
  351. music = widget({ type = "imagebox", align = "right" })
  352. music.image  = image( beautiful.music_icon )
  353. muswidget = widget({type = "textbox", name = "muswidget", align = "right" })
  354. mytimer2:add_signal("timeout", function()
  355.     local f = io.popen("deadbeef --nowplaying '%a - %t' | "..awehome.."dbunand")
  356.     muswidget.text = " " .. f:read()
  357.     f:close()
  358. end)
  359. music:buttons(awful.util.table.join(
  360.     awful.button({ }, 1, function() awful.util.spawn("deadbeef --toggle-pause") end),
  361.     awful.button({ }, 3, function() awful.util.spawn("deadbeef --stop") end),
  362.     awful.button({ }, 4, function() awful.util.spawn("deadbeef --next") end),
  363.     awful.button({ }, 5, function() awful.util.spawn("deadbeef --prev") end)
  364. ))
  365. --Now playing (deadbeef)}}}
  366.  
  367. --{{{Погода и фаза луны
  368. weaic = widget({ type = "imagebox", align = "right" })
  369. moonic = widget({ type = "imagebox", align = "right" })
  370. weawidget = widget({type = "textbox", name = "weawidget", align = "right" })
  371. function wInfo()
  372.      local f = io.popen(awehome .. 'sqrwe T')
  373.      local i = io.popen(awehome .. 'sqrwe I')
  374.      local m = io.popen(awehome .. 'sqrwe M')
  375.      weaic.image = image ( awehome.."images/weathericons/"..i:read())
  376.      moonic.image = image ( awehome.."images/moonicons/"..m:read())
  377.      weawidget.text = " " ..f:read().."°C"
  378.      f:close()
  379.      i:close()
  380.      m:close()
  381. end
  382. wInfo()
  383. mytimer600:add_signal("timeout", function() wInfo() end)
  384. weaic:buttons(awful.util.table.join(
  385.     awful.button({ }, 1, function() awful.util.spawn(browser .. " http://pogoda.yandex.ru/") end)
  386. ))
  387. moonic:buttons(awful.util.table.join(
  388.     awful.button({ }, 1, function() awful.util.spawn(browser .. " http://www.astrosystem.ru/AstroSystem/Main/Prognoz/MoonTransits") end)
  389. ))
  390. --Погода и фаза луны}}}
  391.  
  392. --{{{Тэги
  393. mytaglist = awful.widget.taglist(1,
  394.     awful.widget.taglist.label.all,
  395.     awful.util.table.join(
  396.         awful.button({ }, 1, awful.tag.viewonly),
  397.         awful.button({ modkey }, 1, awful.client.movetotag),
  398.         awful.button({ }, 3, awful.tag.viewtoggle),
  399.         awful.button({ modkey }, 3, awful.client.toggletag),
  400.         awful.button({ }, 4, awful.tag.viewnext),
  401.         awful.button({ }, 5, awful.tag.viewprev)
  402.     )
  403. )
  404. --Тэги}}}
  405.  
  406. --{{{виджет "панель задач"
  407. mytasklist = {}
  408. mytasklist.buttons = awful.util.table.join(
  409.                      awful.button({ }, 1, function (c)
  410.                                               if not c:isvisible() then
  411.                                                   awful.tag.viewonly(c:tags()[1])
  412.                                               end
  413.                                               client.focus = c
  414.                                               c:raise()
  415.                                           end),
  416.                      awful.button({ }, 3, function ()
  417.                                               if instance then
  418.                                                   instance:hide()
  419.                                                   instance = nil
  420.                                               else
  421.                                                   instance = awful.menu.clients({ width=250 })
  422.                                               end
  423.                                           end),
  424.                      awful.button({ }, 4, function ()
  425.                                               awful.client.focus.byidx(1)
  426.                                               if client.focus then client.focus:raise() end
  427.                                           end),
  428.                      awful.button({ }, 5, function ()
  429.                                               awful.client.focus.byidx(-1)
  430.                                               if client.focus then client.focus:raise() end
  431.                                           end))
  432. mytasklist = awful.widget.tasklist(function(c)
  433.                                               return awful.widget.tasklist.label.currenttags(c, 1)
  434.                                           end, mytasklist.buttons)
  435. --виджет "панель задач"}}}
  436.  
  437. --{{{виджет для ввода
  438. mypromptbox = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })--}}}
  439.  
  440. --{{{Виджет для переключения (отображения) лэйаута
  441. mylayoutbox = awful.widget.layoutbox(1)
  442. mylayoutbox:buttons(awful.util.table.join(
  443.                        awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  444.                        awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  445.                        awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  446.                        awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  447. --Виджет для переключения (отображения) лэйаута}}}
  448.  
  449. --ВИДЖЕТЫ}}}
  450.  
  451.  
  452. --{{{ПАНЕЛИ
  453.  
  454. --{{{нижняя панель
  455. mywibox = awful.wibox({ position = "bottom", screen = 1 })
  456. mywibox.widgets = {
  457.     layout = awful.widget.layout.horizontal.rightleft,
  458.     {
  459.         -- виджеты нижней панели (слева-направо)
  460.         mytaglist,
  461.         mypromptbox, sp,
  462.         moonic, sp,
  463.         weaic, weawidget, sp,
  464.         memic, memwidget, sp,
  465.         cpuic, cpuwidget, sp,
  466.         mailic, mailwidget, sp,
  467.         chic, chwidget, sp,
  468.         volic, volwidget, sp,
  469.         netdownic, netwidget, netupic, sp,
  470.         fsic, fswidget,
  471.         layout = awful.widget.layout.horizontal.leftright,
  472.     },
  473.     {
  474.         -- виджеты нижней панели (справа-налево)
  475.         mysystray,
  476.         mytextclock, clockic, sp,
  477.         muswidget,music,
  478.         layout = awful.widget.layout.horizontal.rightleft,
  479.     },
  480. }
  481. --нижняя панель}}}
  482.  
  483. --{{{верхняя панель
  484. mytb = awful.wibox({ position = "top", screen = 1 })
  485. mytb.widgets = {
  486.     -- виджеты верхней панели (слева-направо)
  487.     mylayoutbox, mytasklist,
  488.     layout = awful.widget.layout.horizontal.leftright,
  489. }
  490. --верхняя панель}}}
  491.  
  492. --ПАНЕЛИ}}}
  493.  
  494.  
  495. --{{{мышка(раб стол)
  496. root.buttons(awful.util.table.join(
  497.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  498.     awful.button({ }, 4, awful.tag.viewnext),
  499.     awful.button({ }, 5, awful.tag.viewprev)
  500. ))
  501. --мышка(раб стол)}}}
  502.  
  503.  
  504. --{{{КЛАВИАТУРА (хоткеи)
  505.  
  506. --{{{global
  507.  
  508. globalkeys = awful.util.table.join(
  509.     --{{{тэги
  510.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  511.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  512.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  513.     --тэги}}}
  514.     --{{{переключение окон
  515.     awful.key({ modkey,           }, "j",
  516.         function ()
  517.             awful.client.focus.byidx( 1)
  518.             if client.focus then client.focus:raise() end
  519.         end),
  520.     awful.key({ modkey,           }, "k",
  521.         function ()
  522.             awful.client.focus.byidx(-1)
  523.             if client.focus then client.focus:raise() end
  524.         end),
  525.     --переключение окон}}}
  526.     --{{{Layout manipulation
  527.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  528.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  529.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  530.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  531.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  532.     awful.key({ modkey,           }, "Tab",
  533.         function ()
  534.             awful.client.focus.history.previous()
  535.             if client.focus then
  536.                 client.focus:raise()
  537.             end
  538.         end),
  539.     --Layout manipulation}}}
  540.     --{{{Запуск программ
  541.     awful.key({ modkey }, "Return", function () awful.util.spawn(terminal) end),
  542.     awful.key({ modkey }, "F1", function () awful.util.spawn(terminal) end),
  543.     awful.key({ modkey }, "F2", function () awful.util.spawn(browser) end),
  544.     awful.key({ modkey }, "F4", function () awful.util.spawn("deadbeef") end),
  545.     awful.key({ modkey }, "F5", function () awful.util.spawn("gimp") end),
  546.     --Запуск программ}}}
  547.     --{{{Громкость
  548.         awful.key({modkey}, "KP_Up", function () awful.util.spawn(string.format("amixer set '%s' 2dB+",alsachan)) volInfo() end),
  549.         awful.key({modkey}, "KP_Down", function () awful.util.spawn(string.format("amixer set '%s' 2dB-",alsachan)) volInfo() end),
  550.         awful.key({modkey}, "KP_Insert", function () awful.util.spawn(string.format("amixer -q set '%s' toggle",alsachan)) volInfo() end),
  551.         --awful.key({modkey}, "KP_Up", function () awful.util.spawn("ossmix -d0 vmix0-outvol -- +1") volInfo() end),
  552.         --awful.key({modkey}, "KP_Down", function () awful.util.spawn("ossmix -d0 vmix0-outvol -- -1") volInfo() end),
  553.     --Громкость}}}
  554.     --{{{Управление муз. плеером
  555.     awful.key({modkey,  }, "KP_Begin", function() awful.util.spawn("deadbeef --toggle-pause") end),
  556.     awful.key({modkey,"Shift"  }, "KP_Begin", function() awful.util.spawn("deadbeef --play") end),
  557.     awful.key({modkey, }, "KP_Delete", function() awful.util.spawn("deadbeef --stop") end),
  558.     awful.key({modkey, }, "KP_Left", function() awful.util.spawn("deadbeef --prev") end),
  559.     awful.key({modkey, }, "KP_Right", function() awful.util.spawn("deadbeef --next") end),
  560.     awful.key({modkey,"Control"  }, "KP_Begin", function()
  561.         awful.util.spawn("sh -c \"deadbeef --nowplaying '/me слушает %a, песню «%t» с альбома «%b» %y года' | xclip \"")
  562.     end),
  563.     --     awful.key({modkey, }, "XF86AudioPlay", function () awful.util.spawn(terminal .. " -e mocp") end),
  564.     --     awful.key({"" }, "XF86AudioPlay", function () awful.util.spawn("mocp -G") end),
  565.     --     awful.key({"" }, "XF86AudioStop", function () awful.util.spawn("mocp -s") end),
  566.     --     awful.key({"" }, "XF86AudioPrev", function () awful.util.spawn("mocp -r") end),
  567.     --     awful.key({"" }, "XF86AudioNext", function () awful.util.spawn("mocp -f") end),
  568.     --Управление муз. плеером}}}
  569.     --{{{Управление Awesome
  570.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  571.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  572.     --Управление Awesome}}}
  573.     --{{{Расширять/сужать окошки
  574.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  575.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  576.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  577.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  578.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  579.     awful.key({ modkey, "Contro" }, "l",     function () awful.tag.incncol(-1)         end),
  580.     --Расширять/сужать окошки}}}
  581.     --{{{Переключение Layout'а
  582.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  583.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  584.     --Переключение Layout'а}}}
  585.     --{{{Prompt
  586.     awful.key({ modkey },            "r",     function () mypromptbox:run() end),
  587.     awful.key({ modkey }, "x",
  588.               function ()
  589.                   awful.prompt.run({ prompt = "Run Lua code: " },
  590.                   mypromptbox.widget,
  591.                   awful.util.eval, nil,
  592.                   awful.util.getdir("cache") .. "/history_eval")
  593.               end),
  594.     --Prompt}}}
  595.     --{{{разное
  596.     awful.key({ modkey,           }, "q", function () rodentbane.start() end), --эмулятор мышки
  597.     awful.key({ modkey,           }, "b", function () wpchange() end), --обои менять
  598.     awful.key({ modkey, "Control", "Mod1"}, "l", function () awful.util.spawn("xscreensaver-command -lock") end), --лочить экран
  599.     --разное}}}
  600.     --{{{Скриншот
  601.     awful.key({}, "Print", function()
  602.         awful.util.spawn("\
  603.            scrot '%Y%m%d-%H%M%S-$wx$h.png' -e 'mv $f /srv/http/screen/ &&\
  604.            echo "..myip.."/screen/$f - скриншот, $$[$s/1024]Kb, $wx$h |\
  605.            xclip && notify-send Скриншот $f'\
  606.        ")
  607.     end),
  608.     awful.key({modkey }, "Print", function ()
  609.         awful.util.spawn(awehome.."makemyshot")
  610.     end)
  611.     --Скриншот}}}
  612. )
  613. --global}}}
  614.  
  615. --{{{client
  616. clientkeys = awful.util.table.join(
  617.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  618.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  619.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  620.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  621.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  622.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  623.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  624.     awful.key({ modkey,           }, "m",
  625.         function (c)
  626.             c.maximized_horizontal = not c.maximized_horizontal
  627.             c.maximized_vertical   = not c.maximized_vertical
  628.         end)
  629. )
  630. --client}}}
  631.  
  632. --{{{Тэги
  633. -- Compute the maximum number of digit we need, limited to 9
  634. keynumber = 0
  635. for s = 1, screen.count() do
  636.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  637. end
  638.  
  639. -- Bind all key numbers to tags.
  640. -- Be careful: we use keycodes to make it works on any keyboard layout.
  641. -- This should map on the top row of your keyboard, usually 1 to 9.
  642. for i = 1, keynumber do
  643.     globalkeys = awful.util.table.join(globalkeys,
  644.         awful.key({ modkey }, "#" .. i + 9,
  645.                   function ()
  646.                         local screen = mouse.screen
  647.                         if tags[screen][i] then
  648.                             awful.tag.viewonly(tags[screen][i])
  649.                         end
  650.                   end),
  651.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  652.                   function ()
  653.                       local screen = mouse.screen
  654.                       if tags[screen][i] then
  655.                           awful.tag.viewtoggle(tags[screen][i])
  656.                       end
  657.                   end),
  658.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  659.                   function ()
  660.                       if client.focus and tags[client.focus.screen][i] then
  661.                           awful.client.movetotag(tags[client.focus.screen][i])
  662.                       end
  663.                   end),
  664.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  665.                   function ()
  666.                       if client.focus and tags[client.focus.screen][i] then
  667.                           awful.client.toggletag(tags[client.focus.screen][i])
  668.                       end
  669.                   end))
  670. end
  671. --Тэги}}}
  672.  
  673. --{{{Мышка
  674. clientbuttons = awful.util.table.join(
  675.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  676.     awful.button({ modkey }, 1, awful.mouse.client.move),
  677.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  678. --Мышка}}}
  679.  
  680. --{{{Set keys
  681. root.keys(globalkeys)--}}}
  682.  
  683. --КЛАВИАТУРА (хоткеи)}}}
  684.  
  685.  
  686. --{{{ПРАВИЛА ДЛЯ ОКОН
  687. awful.rules.rules = {
  688.     -- Правило для всех окон (далее можно переопределить для конкретных)
  689.     { rule = { },
  690.       properties = { border_width = beautiful.border_width,
  691.                      border_color = beautiful.border_normal,
  692.                      focus = true,
  693.                      keys = clientkeys,
  694.                      buttons = clientbuttons,
  695.                      tag = tags[1][3] } }, -- по умолчанию открывать все окна не 3-м тэге
  696.     -- Правила для разных приложений
  697.     { rule = { class = "MPlayer" },  properties = { floating = true } },
  698.     { rule = { class = "Uzbl-core" }, properties = { tag = tags[1][2] } },
  699.     { rule = { class = "Firefox" }, properties = { tag = tags[1][2] } },
  700.     { rule = { class = "URxvt" }, properties = { tag = tags[1][1] } },
  701.     { rule = { class = "Deadbeef" }, properties = { tag = tags[1][4] } },
  702.     { rule = { class = "Deluge" }, properties = { tag = tags[1][4] } },
  703.     { rule = { class = "Gimp" }, properties = { tag = tags[1][5] } },
  704.     { rule = { role = "gimp-toolbox" }, properties = { floating = false } }, -- окошко инструментов гимпа встаёт в тайлинг
  705. }
  706. --ПРАВИЛА ДЛЯ ОКОН}}}
  707.  
  708.  
  709. --{{{Signals
  710. --ТУТ ЛУЧШЕ ВСЁ ОСТАВИТЬ КАК ЕСТЬ
  711. -- Signal function to execute when a new client appears.
  712. client.add_signal("manage", function (c, startup)
  713.  
  714.     if not startup then
  715.         -- Set the windows at the slave,
  716.         -- i.e. put it at the end of others instead of setting it master.
  717.         -- awful.client.setslave(c)
  718.  
  719.         -- Put windows in a smart way, only if they does not set an initial position.
  720.         if not c.size_hints.user_position and not c.size_hints.program_position then
  721.             awful.placement.no_overlap(c)
  722.             awful.placement.no_offscreen(c)
  723.         end
  724.     end
  725.  
  726.     -- Эта строчка, чтобы между терминалами не было пространства
  727.     c.size_hints_honor = false
  728.  
  729. end)
  730.  
  731. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  732. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  733. --Signals}}}
  734.  
  735.  
  736. --{{{Выполняем при старте Awesome
  737.  
  738. --{{{Стартуем таймеры
  739. mytimer3:start()
  740. mytimer2:start()
  741. mytimer1800:start()
  742. mytimer600:start()
  743. --Стартуем таймеры}}}
  744.  
  745. --{{{Ставим случайные обои
  746. wpchange() --}}}
  747.  
  748. --{{{Автозапуск программ
  749. -- Не используется. Всё запускается из .xinitrc
  750. -- ПРИ НЕОБХОДИМОСТИ - РАСКОММЕНТИРОВАТЬ
  751. --autorunApps = {
  752. --  "killall unclutter",
  753. --  "unclutter -idle 3",
  754. --  "firefox",
  755. --  "deadbeef",
  756. --}
  757. --for app = 1, #autorunApps do
  758. --   awful.util.spawn(autorunApps[app])
  759. --end
  760. --АВТОЗАПУСК}}}
  761.  
  762. --Выполняем при старте Awesome}}}
  763.  
  764. -- vim: fdm=marker:
  765.  
  766.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement