Advertisement
Guest User

rc.lua

a guest
Sep 2nd, 2013
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.51 KB | None | 0 0
  1. homedir = "/home/najlus/"
  2.  
  3. local gears = require("gears")
  4. local awful = require("awful")
  5. awful.rules = require("awful.rules")
  6. require("awful.autofocus")
  7. local wibox = require("wibox")
  8. local beautiful = require("beautiful")
  9. local naughty = require("naughty")
  10. local menubar = require("menubar")
  11. local vicious = require("vicious")
  12. local helpers = require("vicious.helpers")
  13. local utility = require("utility")
  14.     local capi      =   {
  15.                             screen = screen
  16.                         }
  17. require("menu")
  18. local vain = require("vain")
  19.  
  20. -- Автозапуск приложений
  21. --autorunApps = {
  22.   --}
  23.  
  24.  
  25. runOnceApps = {
  26.     "xscreensaver -no-splash",
  27.     "numlockx",
  28.     "clipit",
  29.     "yaudtray",
  30.     "dropboxd",
  31.     "qbittorrent",
  32.     "thunderbird",
  33.     "xxkb",
  34.     "/home/najlus/scripts/rus_awesome_fix.sh",
  35.     "mpd .mpdconf",
  36. }
  37.  
  38. utility.autorun(autorunApps, runOnceApps)
  39.  
  40. -- Использовать системную локаль
  41. os.setlocale(os.getenv("LANG"))
  42. -- {{{ Error handling
  43. -- Check if awesome encountered an error during startup and fell back to
  44. -- another config (This code will only ever execute for the fallback config)
  45. if awesome.startup_errors then
  46.     naughty.notify({ preset = naughty.config.presets.critical,
  47.                      title = "Oops, there were errors during startup!",
  48.                      text = awesome.startup_errors })
  49. end
  50.  
  51. -- Handle runtime errors after startup
  52. do
  53.     local in_error = false
  54.     awesome.connect_signal("debug::error", function (err)
  55.         -- Make sure we don't go into an endless error loop
  56.         if in_error then return end
  57.         in_error = true
  58.  
  59.         naughty.notify({ preset = naughty.config.presets.critical,
  60.                          title = "Oops, an error happened!",
  61.                          text = err })
  62.         in_error = false
  63.     end)
  64. end
  65. -- }}}
  66.  
  67. -- {{{ Variable definitions
  68. -- Themes define colours, icons, and wallpapers
  69. beautiful.init(homedir .. ".config/awesome/theme.lua")
  70.  
  71. -- This is used later as the default terminal and editor to run.
  72. terminal = "urxvt"
  73. editor = os.getenv("EDITOR") or "nano"
  74. editor_cmd = terminal .. " -e " .. editor
  75.  
  76. -- Default modkey.
  77. -- Usually, Mod4 is the key with a logo between Control and Alt.
  78. -- If you do not like this or do not have such a key,
  79. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  80. -- However, you can use another modifier like Mod1, but it may interact with others.
  81. modkey = "Mod4"
  82.  
  83. -- Table of layouts to cover with awful.layout.inc, order matters.
  84. local layouts =
  85. {
  86.     awful.layout.suit.floating,
  87.     vain.layout.centerwork,
  88.     --awful.layout.suit.tile.left,
  89.     --awful.layout.suit.tile,
  90.     --awful.layout.suit.tile.bottom,
  91.     --awful.layout.suit.tile.top,
  92.     --awful.layout.suit.fair,
  93.     --awful.layout.suit.fair.horizontal,
  94.     --awful.layout.suit.max,
  95.     --awful.layout.suit.max.fullscreen,
  96.     --awful.layout.suit.magnifier
  97. }
  98. -- }}}
  99. -- {{{ Wallpaper
  100. if beautiful.wallpaper then
  101.     for s = 1, screen.count() do
  102.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  103.     end
  104. end
  105. -- }}}
  106.  
  107. -- {{{ Tags
  108. -- Define a tag table which hold all screen tags.
  109. tags = {
  110.   names  = {"1 Universal", "2 Internet", "3 Multimedia" ,"4 Files",  "5 Terminal", "6 Work",   "7 etc",    "8 bg"},
  111.   layout = { layouts[2],    layouts[2],   layouts[2],     layouts[2], layouts[2],   layouts[2], layouts[1], layouts[2]
  112. }}
  113.  
  114.  
  115.  
  116. for s = 1, screen.count() do
  117.     tags[s] = awful.tag(tags.names, s, tags.layout)
  118. end
  119. awful.tag.setproperty(tags[1][1], "mwfact", 0.65)
  120. awful.tag.setproperty(tags[1][2], "mwfact", 0.65)
  121. awful.tag.setproperty(tags[1][4], "mwfact", 0.65)
  122. -- }}}
  123.  
  124.  
  125. -- {{{ Menu
  126. -- Create a laucher widget and a main menu
  127. --
  128.  
  129. myawesomemenu = {
  130.    { "manual", terminal .. " -e man awesome" },
  131.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  132.    { "restart", awesome.restart },
  133.    { "quit", awesome.quit }
  134. }
  135.  
  136.  
  137. touhoumenu = {
  138.    { "Touhou 6 (Rus)", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/TH06/\" && wine ./th06r.exe") end },
  139.    { "Touhou 10 (Rus)", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 10/\" && wine ./th10r.exe") end },
  140.    { "Touhou 11", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 11 - Subterranean Animism/\" && wine ./th11e.exe") end },
  141.    { "Touhou 12", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 12 - Undefined Fantastic Object/\" && wine ./th12e.exe") end },
  142.    { "Touhou 12.3 (Файтинг)", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 12.3 - Hisoutensoku/\" && wine ./th123e.exe") end },
  143.    { "Touhou 12.8 (Сырна)", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 12.8 - Great Fairy Wars/\" && wine ./th128e.exe") end },
  144.    { "Touhou 13", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Touhou 13 - Ten Desires/\" && wine ./th13e.exe") end },
  145.    { " "},              -- Пустое место
  146.    { "Koumajou Densetsu II Stranger's Requiem", function()  awful.util.spawn_with_shell("cd \"" .. homedir .. "touhou/Koumajou Densetsu II Stranger's Requiem/\" && wine ./koumajou2.exe") end },
  147. }
  148.  
  149. mylauncher = awful.widget.launcher({ menu = mymainmenu })
  150. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.system_icon },
  151.                                     { "Терминал", terminal },
  152.                                     { " "},             -- Пустое место
  153.                                     { "Приложения", xdgmenu, beautiful.system_icon },             -- Пустое место
  154.                                     { "Touhou", touhoumenu, beautiful.system_icon },                -- Пустое место
  155.                                     { " "},             -- Пустое место
  156.                                     { "Регенерация меню", function()  awful.util.spawn_with_shell("xdg_menu --format awesome  >>~/.config/awesome/menu.lua") end, beautiful.reboot_icon},
  157.                                     { " "},             -- Пустое место
  158.                                     { "Выход", awesome.quit, beautiful.logout_icon},
  159.                                     { "Перезагрузка", function()  awful.util.spawn_with_shell("systemctl reboot") end, beautiful.reboot_icon},
  160.                                     { "Выключение", function()  awful.util.spawn_with_shell("systemctl poweroff") end, beautiful.poweroff_icon}
  161.                                   }
  162.                         })
  163.  
  164. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  165.                                      menu = mymainmenu })
  166.  
  167. -- Menubar configuration
  168. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  169. -- }}}
  170.  
  171. -- {{{ Wibox
  172. -- Create a textclock widget
  173. mytextclock = awful.widget.textclock()
  174.  
  175. ------------------------------------------------------------------------------------------------------------------------
  176. -- Мои виджеты
  177. ------------------------------------------------------------------------------------------------------------------------
  178.  
  179.  
  180.  
  181. -- Иконки и сепараторы
  182.  
  183. local sepl = wibox.widget.imagebox()
  184. sepl:set_image(beautiful.separatorl)
  185.  
  186. local perror = wibox.widget.imagebox()
  187. perror:set_image(beautiful.separatorl)
  188.  
  189. local sepc = wibox.widget.imagebox()
  190. sepc:set_image(beautiful.separatorc)
  191.  
  192. local paci = wibox.widget.imagebox()
  193. paci:set_image(beautiful.pacman_icon)
  194.  
  195. local cpulogo = wibox.widget.imagebox()
  196. cpulogo:set_image(beautiful.cpu_icon)
  197.  
  198. local ramlogo = wibox.widget.imagebox()
  199. ramlogo:set_image(beautiful.ram_icon)
  200.  
  201. local wclear = wibox.widget.imagebox()
  202. wclear:set_image(beautiful.clearimg)
  203.  
  204. local wmus = wibox.widget.imagebox()
  205. wmus:set_image(beautiful.musimg)
  206.  
  207. local wpnext = wibox.widget.imagebox()
  208. wpnext:set_image(beautiful.pnext)
  209.  wpnext:buttons(awful.util.table.join(
  210.    awful.button({ }, 1, function () awful.util.spawn_with_shell("mpc next")  end)
  211.  ))
  212.  
  213. local wpprev = wibox.widget.imagebox()
  214. wpprev:set_image(beautiful.pprev)
  215.  wpprev:buttons(awful.util.table.join(
  216.    awful.button({ }, 1, function () awful.util.spawn_with_shell("mpc prev")  end)
  217.  ))
  218.  
  219. local wpstat = wibox.widget.imagebox()
  220. vicious.register(wpstat, vicious.widgets.mpd,
  221.     function (wpstat, args)
  222.         if args["{state}"] == "Stop" then
  223.             return wpstat:set_image(beautiful.pstop)
  224.         elseif args["{state}"] == "Play" then
  225.             return wpstat:set_image(beautiful.pplay)
  226.         elseif args["{state}"] == "Pause" then
  227.             return wpstat:set_image(beautiful.ppaus)
  228.         else
  229.             return wpstat:set_image(beautiful.perror)
  230.         end
  231.     end, 1)
  232.  wpstat:buttons(awful.util.table.join(
  233.    awful.button({ }, 1, function () awful.util.spawn_with_shell("mpc toggle")  end),
  234.    awful.button({ }, 3, function () awful.util.spawn_with_shell("mpc stop")  end)
  235.  ))
  236.  
  237.  
  238.  
  239. -- Initialize widget
  240. mpdwidget = wibox.widget.textbox()
  241. -- Register widget
  242. vicious.register(mpdwidget, vicious.widgets.mpd,
  243.     function (mpdwidget, args)
  244.         if args["{state}"] == "Stop" then
  245.             return " - "
  246.             --wpstat:set_image(beautiful.pstop)
  247.         else
  248.             return args["{Artist}"]..' - '.. args["{Title}"]
  249.             --wpstat:set_image(beautiful.pplay)
  250.         end
  251.     end, 1)
  252.  mpdwidget:buttons(awful.util.table.join(
  253.    awful.button({ }, 1, function () awful.util.spawn_with_shell("urxvt -geometry 96x32 -e ncmpcpp")  end),
  254.    awful.button({ }, 3, function () awful.util.spawn_with_shell("mpc update")  end)
  255.  ))
  256.  
  257.  
  258. -- Использование ОЗУ
  259. -- Текст
  260. memwidgett = wibox.widget.textbox()
  261. vicious.register(memwidgett, vicious.widgets.mem, "<span color=\"" .. beautiful.textcolor .."\">$1% ($2MB)</span>", 10)
  262.  memwidgett:buttons(awful.util.table.join(
  263.    awful.button({ }, 1, function () awful.util.spawn_with_shell("urxvt -geometry 128x48 -e htop --sort-key PERCENT_MEM")  end)
  264.  ))
  265. -- Графика
  266. memwidget = awful.widget.graph()
  267. memwidget:set_width(50)
  268. memwidget:set_background_color( beautiful.bg_normal )
  269. memwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 20,0 }, stops = { {0, "#335566"}, {0.5, "#5599AA"},
  270.                     {1, "#CCEEFF"}}})
  271. vicious.register(memwidget, vicious.widgets.mem, "$1", 10)
  272.  
  273. -- Нагрузка на процессор
  274. -- Текст
  275. cpuwidgett = wibox.widget.textbox()
  276. vicious.register(cpuwidgett, vicious.widgets.cpu, "<span color=\"" .. beautiful.textcolor .."\">$1%</span>", 3)
  277.  cpuwidgett:buttons(awful.util.table.join(
  278.    awful.button({ }, 1, function () awful.util.spawn_with_shell("urxvt -geometry 128x48 -e htop --sort-key PERCENT_CPU")  end)
  279.  ))
  280. -- Графика
  281. cpuwidget = awful.widget.graph()
  282. cpuwidget:set_width(50)
  283. cpuwidget:set_background_color( beautiful.bg_normal)
  284. cpuwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 20,0 }, stops = { {0, "#335566"}, {0.5, "#5599AA"},
  285.                     {1, "#CCEEFF" }}})
  286. vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3.13)
  287.  
  288. -- Температура CPU
  289. thermalwidget = wibox.widget.textbox()
  290. vicious.register(thermalwidget, vicious.widgets.thermal, "<span color=\"" .. beautiful.textcolor .."\">Temp: $1 °C</span>", 20, { "coretemp.0", "core"} )
  291.  
  292.  
  293. -- Обновления pacman
  294. pacwidget = wibox.widget.textbox()
  295. pacwidget_t = awful.tooltip({ objects = { pacwidget},})
  296. vicious.register(pacwidget, vicious.widgets.pkg,
  297.                 function(widget,args)
  298.                     awful.util.spawn_with_shell("sudo yaourt -Sya")
  299.                     local io = { popen = io.popen }
  300.                     local s = io.popen("yaourt -Qua")
  301.                     local str = ''
  302.                     local str_core = ''
  303.                     local str_extra = ''
  304.                     local str_community = ''
  305.                     local str_multilib = ''
  306.                     local str_aur = ''
  307.                     local str_archlinuxfr = ''
  308.  
  309.                     for line in s:lines() do
  310.                         if (string.find (line, "core") ) ~= nil then
  311.                         str_core = "<span color=\"#FF8080\">" .. str_core .. line .. "</span>\n"
  312.                     elseif (string.find (line, "extra") ) ~= nil then
  313.                         str_extra = "<span color=\"#80FF80\">" .. str_extra .. line .. "</span>\n"
  314.                     elseif (string.find (line, "community") ) ~= nil then
  315.                         str_community = "<span color=\"#BB5FF5\">" .. str_community .. line .. "</span>\n"
  316.                     elseif (string.find (line, "multilib") ) ~= nil then
  317.                         str_multilib = "<span color=\"#9BFFFF\">" .. str_multilib .. line .. "</span>\n"
  318.                     elseif (string.find (line, "aur") ) ~= nil then
  319.                         str_aur = "<span color=\"#C0C000\">" .. str_aur .. line .. "</span>\n"
  320.                     elseif (string.find (line, "archlinuxfr") ) ~= nil then
  321.                         str_archlinuxfr = "<span color=\"#FFAAAA\">" .. str_archlinuxfr .. line .. "</span>\n"
  322.                     else
  323.                         str = "<span color=\"" .. beautiful.textcolor .. "\">" .. str .. line .. "</span>\n"
  324.                     end
  325.                     end
  326.                     str = str .. str_core .. str_extra .. str_community .. str_multilib .. str_aur .. str_archlinuxfr
  327.                     pacwidget_t:set_text(str)
  328.                     s:close()
  329.                     return " " .. args[1]
  330.                 end, 300, "Arch")
  331.  pacwidget:buttons(awful.util.table.join(
  332.    awful.button({ }, 1, function () awful.util.spawn_with_shell("urxvt -e yaourt -Syua")  end)
  333.  ))
  334.  
  335. -- Регулятор громкости
  336. volumewidget = wibox.widget.textbox()
  337. vicious.register( volumewidget, vicious.widgets.volume, "<span color=\"" .. beautiful.textcolor .."\">♫ $1%</span>", 1, "Master" )
  338. volumewidget:buttons(awful.util.table.join(
  339.     awful.button({ }, 4, function () awful.util.spawn("amixer -q sset Master 1dB+", false) end),
  340.     awful.button({ }, 5, function () awful.util.spawn("amixer -q sset Master 1dB-", false) end)
  341.  ))
  342.  
  343.  
  344. -- Create a wibox for each screen and add it
  345. mywibox = {}
  346. mypromptbox = {}
  347. mylayoutbox = {}
  348. mytaglist = {}
  349. mytaglist.buttons = awful.util.table.join(
  350.                     awful.button({ }, 1, awful.tag.viewonly),
  351.                     awful.button({ modkey }, 1, awful.client.movetotag),
  352.                     awful.button({ }, 3, awful.tag.viewtoggle),
  353.                     awful.button({ modkey }, 3, awful.client.toggletag),
  354.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  355.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  356.                     )
  357. mytasklist = {}
  358. mytasklist.buttons = awful.util.table.join(
  359.                      awful.button({ }, 1, function (c)
  360.                                               if c == client.focus then
  361.                                                   c.minimized = true
  362.                                               else
  363.                                                   -- Without this, the following
  364.                                                   -- :isvisible() makes no sense
  365.                                                   c.minimized = false
  366.                                                   if not c:isvisible() then
  367.                                                       awful.tag.viewonly(c:tags()[1])
  368.                                                   end
  369.                                                   -- This will also un-minimize
  370.                                                   -- the client, if needed
  371.                                                   client.focus = c
  372.                                                   c:raise()
  373.                                               end
  374.                                           end),
  375.                      awful.button({ }, 3, function ()
  376.                                               if instance then
  377.                                                   instance:hide()
  378.                                                   instance = nil
  379.                                               else
  380.                                                   instance = awful.menu.clients({ width=250 })
  381.                                               end
  382.                                           end),
  383.                      awful.button({ }, 4, function ()
  384.                                               awful.client.focus.byidx(1)
  385.                                               if client.focus then client.focus:raise() end
  386.                                           end),
  387.                      awful.button({ }, 5, function ()
  388.                                               awful.client.focus.byidx(-1)
  389.                                               if client.focus then client.focus:raise() end
  390.                                           end))
  391.  
  392.  
  393. for s = 1, screen.count() do
  394.     -- Create a promptbox for each screen
  395.     mypromptbox[s] = awful.widget.prompt()
  396.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  397.     -- We need one layoutbox per screen.
  398.     mylayoutbox[s] = awful.widget.layoutbox(s)
  399.     mylayoutbox[s]:buttons(awful.util.table.join(
  400.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  401.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  402.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  403.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  404.     -- Create a taglist widget
  405.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  406.  
  407.     -- Create a tasklist widget
  408.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  409.  
  410.     -- Create the wibox
  411.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  412.  
  413.     -- Widgets that are aligned to the left
  414.     local left_layout = wibox.layout.fixed.horizontal()
  415.     left_layout:add(mylauncher)
  416.     left_layout:add(mytaglist[s])
  417.     left_layout:add(mypromptbox[s])
  418.  
  419.     -- Widgets that are aligned to the right
  420.     local right_layout = wibox.layout.fixed.horizontal()
  421.     --------------------------------------------------------------------------
  422.     -- Мои виджеты
  423.     --------------------------------------------------------------------------
  424.     right_layout:add(wclear)
  425.     right_layout:add(wmus)
  426.     right_layout:add(wclear)
  427.     right_layout:add(mpdwidget)
  428.     right_layout:add(sepc)
  429.     right_layout:add(wpstat)
  430.     right_layout:add(wpprev)
  431.     right_layout:add(wpnext)
  432.     right_layout:add(sepc)
  433.     right_layout:add(volumewidget)
  434.     right_layout:add(sepc)
  435.     right_layout:add(sepc)
  436.     right_layout:add(paci)
  437.     right_layout:add(pacwidget)
  438.     right_layout:add(sepc)
  439.     right_layout:add(sepc)
  440.     right_layout:add(ramlogo)
  441.     right_layout:add(wclear)
  442.     right_layout:add(memwidgett)
  443.     right_layout:add(sepc)
  444.     right_layout:add(memwidget)
  445.     right_layout:add(sepc)
  446.     right_layout:add(sepc)
  447.     right_layout:add(cpulogo)
  448.     right_layout:add(wclear)
  449.     right_layout:add(cpuwidgett)
  450.     right_layout:add(sepc)
  451.     right_layout:add(cpuwidget)
  452.     right_layout:add(sepc)
  453.     right_layout:add(thermalwidget)
  454.     right_layout:add(sepc)
  455.     right_layout:add(sepc)
  456.    
  457.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  458.     right_layout:add(mytextclock)
  459.     right_layout:add(mylayoutbox[s])
  460.  
  461.     -- Now bring it all together (with the tasklist in the middle)
  462.     local layout = wibox.layout.align.horizontal()
  463.     layout:set_left(left_layout)
  464.     layout:set_middle(mytasklist[s])
  465.     layout:set_right(right_layout)
  466.  
  467.     mywibox[s]:set_widget(layout)
  468. end
  469. -- }}}
  470.  
  471. -- {{{ Mouse bindings
  472. root.buttons(awful.util.table.join(
  473.     awful.button({ }, 3, function () mymainmenu:toggle() end)
  474.     --awful.button({ }, 4, awful.tag.viewnext),
  475.     --awful.button({ }, 5, awful.tag.viewprev)
  476. ))
  477. -- }}}
  478.  
  479. -- {{{ Key bindings
  480. globalkeys = awful.util.table.join(
  481.  
  482.     awful.key({            }, "XF86AudioPlay", function () awful.util.spawn("mpc toggle") end ),
  483.     awful.key({            }, "XF86AudioStop", function () awful.util.spawn("mpc stop") end ),
  484.     awful.key({            }, "XF86AudioNext", function () awful.util.spawn("mpc next") end ),
  485.     awful.key({            }, "XF86AudioPrev", function () awful.util.spawn("mpc prev") end ),
  486.     awful.key({            }, "XF86AudioRaiseVolume", function () awful.util.spawn("mpc volume +5") end ),
  487.     awful.key({            }, "XF86AudioLowerVolume", function () awful.util.spawn("mpc volume -5") end ),
  488.     --awful.key({            }, "", function () awful.util.spawn("") end ),
  489.  
  490.     -- Мои программы
  491.     awful.key({ modkey,           }, "d", function () awful.util.spawn("doublecmd") end ),
  492.     awful.key({ modkey,           }, "f", function () awful.util.spawn("firefox") end ),
  493.     awful.key({ modkey,           }, "a", function () awful.util.spawn("pcmanfm") end ),
  494.     awful.key({ modkey            }, "q", function () awful.util.spawn('xscreensaver-command -lock') end),
  495.     awful.key({ modkey            }, "c", function () awful.util.spawn('clementine') end),
  496.     awful.key({ modkey            }, "g", function () awful.util.spawn('gvim') end),
  497.     awful.key({ modkey            }, "k", function () awful.util.spawn('keepass2') end),
  498.     awful.key({ modkey            }, "F2", function () awful.util.spawn('gmrun') end),
  499.     awful.key({ modkey            }, "Delete", function () awful.util.spawn('urxvt -e htop') end),
  500.     awful.key({ }, "Print", function () awful.util.spawn("screengrab") end),
  501.  
  502.  
  503.    awful.key({ modkey }, "r", function ()
  504.                                  local promptbox = mypromptbox[mouse.screen]
  505.                                  awful.prompt.run({ prompt = promptbox.prompt,
  506.                                                     bg_cursor = beautiful.textcolor },
  507.                                                   promptbox.widget,
  508.                                                   function (...)
  509.                                                      local result = awful.util.spawn(...)
  510.                                                      if type(result) == "string" then
  511.                                                         promptbox.widget:set_text(result)
  512.                                                      end
  513.                                                   end,
  514.                                                   awful.completion.shell,
  515.                                                   awful.util.getdir("cache") .. "/history")
  516.                               end),
  517.                              
  518.     -- Стандартные Awesome
  519.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  520.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  521.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  522.  
  523.     awful.key({ modkey,           }, "j",
  524.         function ()
  525.             awful.client.focus.byidx( 1)
  526.             if client.focus then client.focus:raise() end
  527.         end),
  528.     awful.key({ modkey,           }, "k",
  529.         function ()
  530.             awful.client.focus.byidx(-1)
  531.             if client.focus then client.focus:raise() end
  532.         end),
  533.     awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  534.  
  535.     -- Layout manipulation
  536.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  537.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  538.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  539.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  540.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  541.     awful.key({ modkey,           }, "Tab",
  542.         function ()
  543.             awful.client.focus.history.previous()
  544.             if client.focus then
  545.                 client.focus:raise()
  546.             end
  547.         end),
  548.  
  549.     -- Standard program
  550.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  551.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  552.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  553.  
  554.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  555.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  556.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  557.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  558.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  559.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  560.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  561.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  562.  
  563.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  564.  
  565.     -- Prompt
  566.     --awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  567.  
  568.     --awful.key({ modkey }, "x",
  569.               --function ()
  570.                   --awful.prompt.run({ prompt = "Run Lua code: " },
  571.                   --mypromptbox[mouse.screen].widget,
  572.                   --awful.util.eval, nil,
  573.                   --awful.util.getdir("cache") .. "/history_eval")
  574.               --end),
  575.     -- Menubar
  576.     awful.key({ modkey }, "p", function() menubar.show() end)
  577. )
  578.  
  579. clientkeys = awful.util.table.join(
  580.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  581.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  582.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  583.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  584.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  585.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  586.     awful.key({ modkey,           }, "n",
  587.    
  588.         function (c)
  589.             -- The client currently has the input focus, so it cannot be
  590.             -- minimized, since minimized clients can't have the focus.
  591.             c.minimized = true
  592.         end),
  593.     awful.key({ modkey,           }, "m",
  594.         function (c)
  595.             c.maximized_horizontal = not c.maximized_horizontal
  596.             c.maximized_vertical   = not c.maximized_vertical
  597.         end)
  598. )
  599.  
  600. -- Bind all key numbers to tags.
  601. -- Be careful: we use keycodes to make it works on any keyboard layout.
  602. -- This should map on the top row of your keyboard, usually 1 to 9.
  603. for i = 1, 9 do
  604.     globalkeys = awful.util.table.join(globalkeys,
  605.         awful.key({ modkey }, "#" .. i + 9,
  606.                   function ()
  607.                         local screen = mouse.screen
  608.                         local tag = awful.tag.gettags(screen)[i]
  609.                         if tag then
  610.                            awful.tag.viewonly(tag)
  611.                         end
  612.                   end),
  613.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  614.                   function ()
  615.                       local screen = mouse.screen
  616.                       local tag = awful.tag.gettags(screen)[i]
  617.                       if tag then
  618.                          awful.tag.viewtoggle(tag)
  619.                       end
  620.                   end),
  621.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  622.                   function ()
  623.                       local tag = awful.tag.gettags(client.focus.screen)[i]
  624.                       if client.focus and tag then
  625.                           awful.client.movetotag(tag)
  626.                      end
  627.                   end),
  628.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  629.                   function ()
  630.                       local tag = awful.tag.gettags(client.focus.screen)[i]
  631.                       if client.focus and tag then
  632.                           awful.client.toggletag(tag)
  633.                       end
  634.                   end))
  635. end
  636.  
  637. clientbuttons = awful.util.table.join(
  638.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  639.     awful.button({ modkey }, 1, awful.mouse.client.move),
  640.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  641.  
  642. -- Set keys
  643. root.keys(globalkeys)
  644. -- }}}
  645.  
  646. -- {{{ Rules
  647. awful.rules.rules = {
  648.     -- All clients will match this rule.
  649.     { rule = { },
  650.       properties = { border_width = beautiful.border_width,
  651.                      border_color = beautiful.border_normal,
  652.                      focus = awful.client.focus.filter,
  653.                      keys = clientkeys,
  654.                      buttons = clientbuttons, } },
  655.  
  656.     { rule = { class    = "Firefox" }, properties          = { tag = tags[1][2], floating = false, switchtotag  = true  }, callback = awful.placement.centered, },
  657.     { rule = { class    = "Opera" }, properties            = { tag = tags[1][2], floating = false, switchtotag  = true  }, callback = awful.placement.centered, },
  658.  
  659.     { rule = { class    = "Smplayer" }, properties         = { tag = tags[1][3], floating = true,  switchtotag  = true  }, callback = awful.placement.centered, },
  660.     { rule = { class    = "Viewnior" }, properties         = { tag = tags[1][3], floating = false, switchtotag = true   } },
  661.  
  662.     { rule = { class    = "Doublecmd" }, properties        = { tag = tags[1][4], floating = false, switchtotag = true   } },
  663.     { rule = { class    = "Pcmanfm" }, properties          = { tag = tags[1][4], floating = false,                      } },
  664.  
  665.     { rule = { name     = "Tor" }, properties              = { tag = tags[1][6], floating = false,                      }, callback = awful.placement.centered, },
  666.  
  667.     { rule = { class    = "Steam" }, properties            = { tag = tags[1][7], floating = true,  switchtotag = true   }, callback = awful.placement.centered, },
  668.     { rule = { class    = "Wine" }, properties             = { tag = tags[1][7],                   switchtotag = true   } },
  669.     { rule = { class    = "Fceux" }, properties            = { tag = tags[1][7], floating = true,  switchtotag = true   }, callback = awful.placement.centered, },
  670.  
  671.     { rule = { name     = "Qbittorrent" }, properties      = { tag = tags[1][8], floating = false,                      } },
  672.     { rule = { class    = "Thunderbird" }, properties      = { tag = tags[1][8], floating = false,                      } },
  673.  
  674.     { rule = { class    = "Plugin-container" }, properties = {                   floating = true,                       }, callback = awful.placement.centered, },
  675.     { rule = { class    = "Screengrab" }, properties       = {                   floating = true,                       }, callback = awful.placement.centered, },
  676.     { rule = { class    = "URxvt" }, properties            = {                   floating = true,                       }, callback = awful.placement.centered, },
  677.     { rule = { class    = "Download" }, properties         = {                   floating = true,                       }, callback = awful.placement.centered, },
  678.     { rule = { instance = "Download" }, properties         = {                   floating = true,                       }, callback = awful.placement.centered, },
  679.     { rule = { instance = "Dialog" }, properties           = {                   floating = true,                       }, callback = awful.placement.centered, },
  680.     { rule = { class    = "Dialog" }, properties           = {                   floating = true,                       }, callback = awful.placement.centered, },
  681.     { rule = { class    = "Xarchiver" }, properties        = {                   floating = true,                       }, callback = awful.placement.centered, },
  682.     { rule = { class    = "Gmrun" }, properties            = {                   floating = true,                       }, callback = awful.placement.centered, },
  683.     { rule = { class    = "MPlayer" }, properties          = {                   floating = true,                       } },
  684.  
  685.     -- Сделать окна плавающими по определённому зкголовку.
  686.     { rule = { name = "Найт" },                        properties = { floating = true, }, callback = awful.placement.centered, },
  687.     { rule = { name = "Подключён" },                   properties = { floating = true, }, callback = awful.placement.centered, },
  688.     { rule = { name = "Замен" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  689.     { rule = { name = "Копир" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  690.     { rule = { name = "Экспорт" },                     properties = { floating = true, }, callback = awful.placement.centered, },
  691.     { rule = { name = "Импорт" },                      properties = { floating = true, }, callback = awful.placement.centered, },
  692.     { rule = { name = "Настро" },                      properties = { floating = true, }, callback = awful.placement.centered, },
  693.     { rule = { name = "Параметр" },                    properties = { floating = true, }, callback = awful.placement.centered, },
  694.     { rule = { name = "Поиск" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  695.     { rule = { name = "Добав" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  696.     { rule = { name = "Печат" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  697.     { rule = { name = "Сохран" },                      properties = { floating = true, }, callback = awful.placement.centered, },
  698.     { rule = { name = "Откры" },                       properties = { floating = true, }, callback = awful.placement.centered, },
  699.     { rule = { name = "Выреза" },                      properties = { floating = true, }, callback = awful.placement.centered, },
  700.     { rule = { name = "Удал" },                        properties = { floating = true, }, callback = awful.placement.centered, },
  701.     { rule = { name = "айл" },                         properties = { floating = true, }, callback = awful.placement.centered, },
  702.     { rule = { name = "Выбрать" },                     properties = { floating = true, }, callback = awful.placement.centered, },
  703.     { rule = { name = "Удал" },                        properties = { floating = true, }, callback = awful.placement.centered, },
  704.     { rule = { name = "Загруз" },                      properties = { floating = true, }, callback = awful.placement.centered, },
  705.     { rule = { name = "Предупреждение" },              properties = { floating = true, }, callback = awful.placement.centered, },
  706.     { rule = { name = "Подтверждение" },               properties = { floating = true, }, callback = awful.placement.centered, },
  707.     { rule = { name = "Создать" },                     properties = { floating = true, }, callback = awful.placement.centered, },
  708.     { rule = { name = "Выбор приложения" },            properties = { floating = true, }, callback = awful.placement.centered, },
  709.     { rule = { name = "Составление правил" },          properties = { floating = true, }, callback = awful.placement.centered, },
  710.     { rule = { name = "Уставновка программы" },        properties = { floating = true, }, callback = awful.placement.centered, },
  711. }
  712. -- }}}
  713.  
  714. client.connect_signal("arrange",
  715.    function(c)
  716.  
  717.    end)
  718.  
  719. -- {{{ Signals
  720. -- Signal function to execute when a new client appears.
  721. client.connect_signal("manage", function (c, startup)
  722.     -- Enable sloppy focus
  723.     c:connect_signal("mouse::enter", function(c)
  724.         --if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  725.             --and awful.client.focus.filter(c) then
  726.             --client.focus = c
  727.         --end
  728.     end)
  729.  
  730.     if not startup then
  731.         -- Set the windows at the slave,
  732.         -- i.e. put it at the end of others instead of setting it master.
  733.         -- awful.client.setslave(c)
  734.  
  735.         -- Put windows in a smart way, only if they does not set an initial position.
  736.         if not c.size_hints.user_position and not c.size_hints.program_position then
  737.             awful.placement.no_overlap(c)
  738.             awful.placement.no_offscreen(c)
  739.         end
  740.     end
  741.  
  742.     local titlebars_enabled = false
  743.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  744.         -- buttons for the titlebar
  745.         local buttons = awful.util.table.join(
  746.                 awful.button({ }, 1, function()
  747.                     client.focus = c
  748.                     c:raise()
  749.                     awful.mouse.client.move(c)
  750.                 end),
  751.                 awful.button({ }, 3, function()
  752.                     client.focus = c
  753.                     c:raise()
  754.                     awful.mouse.client.resize(c)
  755.                 end)
  756.                 )
  757.  
  758.         -- Widgets that are aligned to the left
  759.         local left_layout = wibox.layout.fixed.horizontal()
  760.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  761.         left_layout:buttons(buttons)
  762.  
  763.         -- Widgets that are aligned to the right
  764.         local right_layout = wibox.layout.fixed.horizontal()
  765.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  766.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  767.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  768.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  769.         right_layout:add(awful.titlebar.widget.closebutton(c))
  770.  
  771.         -- The title goes in the middle
  772.         local middle_layout = wibox.layout.flex.horizontal()
  773.         local title = awful.titlebar.widget.titlewidget(c)
  774.         title:set_align("center")
  775.         middle_layout:add(title)
  776.         middle_layout:buttons(buttons)
  777.  
  778.         -- Now bring it all together
  779.         local layout = wibox.layout.align.horizontal()
  780.         layout:set_left(left_layout)
  781.         layout:set_right(right_layout)
  782.         layout:set_middle(middle_layout)
  783.  
  784.         awful.titlebar(c):set_widget(layout)
  785.     end
  786. end)
  787.  
  788. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  789. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  790. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement