Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- {{{ Библиотеки
- local awful = require("awful")
- local gears = require("gears")
- awful.rules = require("awful.rules")
- require("awful.autofocus")
- local wibox = require("wibox")
- local beautiful = require("beautiful")
- local naughty = require("naughty")
- local drop = require("scratchdrop")
- local lain = require("lain")
- local helpers = require("lain.helpers")
- -- local imglib = require("imlib2")
- -- }}}
- -- {{{ Вывод ошибок
- if awesome.startup_errors then
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Ошибка при запуске",
- text = awesome.startup_errors })
- end
- do
- local in_error = false
- awesome.connect_signal("debug::error", function (err)
- if in_error then return end
- in_error = true
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Произошла ошибка",
- text = err })
- in_error = false
- end)
- end
- -- }}}
- -- {{{ Автостарт при запуске
- function run_once(cmd)
- findme = cmd
- firstspace = cmd:find(" ")
- if firstspace then
- findme = cmd:sub(0, firstspace-1)
- end
- awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
- end
- run_once("sudo netctl start Maks")
- run_once("pulseaudio --start")
- run_once("compton")
- run_once("unclutter -root")
- run_once("nautilus -n")
- run_once("xset dpms 0 0 0")
- run_once("xset s off")
- -- }}}
- -- {{{ Переменные
- beautiful.init(os.getenv("HOME") .. "/.config/awesome/themes/powerarrow-darker/theme.lua")
- modkey = "Mod4"
- altkey = "Mod1"
- terminal = "gnome-terminal"
- editor = os.getenv("EDITOR") or "sudo gedit"
- editor_cmd = terminal .. " -e " .. editor
- local layouts =
- {
- awful.layout.suit.floating, --1
- awful.layout.suit.tile, --2
- awful.layout.suit.tile.left, --3
- awful.layout.suit.tile.bottom, --4
- awful.layout.suit.tile.top, --5
- awful.layout.suit.fair, --6
- awful.layout.suit.fair.horizontal, --7
- awful.layout.suit.spiral, --8
- awful.layout.suit.spiral.dwindle, --9
- }
- -- }}}
- -- {{{ Теги
- tags = {
- names = { " Ø ", " ^.^ ", " >_ ", " ± ", " * " },
- layout = { layouts[1], layouts[1], layouts[7], layouts[3], layouts[1] }
- }
- for s = 1, screen.count() do
- tags[s] = awful.tag(tags.names, s, tags.layout)
- end
- -- }}}
- -- {{{ Заставка рабочего стола
- if beautiful.wallpaper then
- for s = 1, screen.count() do
- gears.wallpaper.maximized(beautiful.wallpaper, s, true)
- end
- end
- -- }}}
- -- {{{ Меню
- mymainmenu = awful.menu.new({ items = require("menugen").build_menu()})
- mypowermenu = awful.menu.new({ items = {{"Системный монитор", "gnome-system-monitor"}, {"Сделать скриншот", "deepin-screenshot"}, {}, {"Рестарт Awesome", awesome.restart}, {}, {"Заблокировать", "xtrlock"}, {"Выйти", awesome.quit}, {}, {"Перезагрузить", "sudo shutdown -r now"}, {"Выключить", "sudo shutdown -h now"}}})
- mywifimenu = awful.menu.new({ items = {{"Открыть менеджер", terminal .. " -e 'sudo wifi-menu'"}, {}, {"Запустить Xampp", terminal .. " -e 'sudo /opt/lampp/lampp restart'"}, {"Остановить Xampp", terminal .. " -e 'sudo /opt/lampp/lampp stop'"}}})
- myvolumemenu = awful.menu.new({ items = {{"Микшер громкости", "pavucontrol"}, {}, {"Эквалайзер", terminal .. " -e 'vis'"}}})
- -- Контекстное меню окна
- function context_menu(c)
- tag_menu = { }
- for i,t in pairs(tags.names) do
- if not tags[c.screen][i].selected then
- table.insert(tag_menu, { tostring(t), function() awful.client.movetotag(tags[c.screen][i]) end } )
- end
- end
- taskmenu = awful.menu.new({ items = { { "Переместить", tag_menu }, {},
- { "Закрыть", function() c:kill() end }}})
- taskmenu:show()
- return taskmenu
- end
- -- }}}
- -- {{{ Wibox
- markup = lain.util.markup
- separators = lain.util.separators
- -- Часы
- clockicon = wibox.widget.imagebox(beautiful.widget_clock)
- --mytextclock = awful.widget.textclock(" %a %d %b %H:%M")
- mytextclock = lain.widgets.abase({
- timeout = 60,
- cmd = "date +'%a %d %b %R'",
- settings = function()
- widget:set_text(" " .. output)
- end
- })
- -- Громкость Pulseaudio
- volicon = wibox.widget.imagebox(beautiful.widget_vol)
- volumewidget = lain.widgets.pulseaudio({
- settings = function()
- if volume_now.status == "off" then
- volicon:set_image(beautiful.widget_vol_mute)
- elseif tonumber(volume_now.left) == 0 then
- volicon:set_image(beautiful.widget_vol_no)
- elseif tonumber(volume_now.left) <= 50 then
- volicon:set_image(beautiful.widget_vol_low)
- else
- volicon:set_image(beautiful.widget_vol)
- end
- widget:set_text(" " .. volume_now.left .. "% ")
- end
- })
- volumewidget:buttons(awful.util.table.join(awful.button({ }, 1, function () myvolumemenu:toggle() end)))
- volicon:buttons(awful.util.table.join(awful.button({ }, 1, function () myvolumemenu:toggle() end)))
- -- Память
- memicon = wibox.widget.imagebox(beautiful.widget_mem)
- memwidget = lain.widgets.mem({
- settings = function()
- widget:set_text(" " .. mem_now.used .. "мб ")
- end
- })
- -- Процессор
- cpuicon = wibox.widget.imagebox(beautiful.widget_cpu)
- cpuwidget = lain.widgets.cpu({
- settings = function()
- widget:set_text(" " .. cpu_now.usage .. "% ")
- end
- })
- -- Раскладка клавиатуры
- kbdcfg = {}
- kbdcfg.cmd = "setxkbmap"
- kbdcfg.layout = { { "us", "", "en" }, { "ru,us" , "", "ru" } }
- kbdcfg.current = 1
- kbdcfg.widget = wibox.widget.textbox()
- kbdcfg.widget:set_text(" " .. kbdcfg.layout[kbdcfg.current][3] .. " ")
- kbdcfg.switch = function ()
- kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
- local t = kbdcfg.layout[kbdcfg.current]
- kbdcfg.widget:set_text(" " .. t[3] .. " ")
- os.execute( kbdcfg.cmd .. " " .. t[1] .. " " .. t[2] )
- end
- kbdcfg.widget:buttons(
- awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch() end))
- )
- -- / fs
- fsicon = wibox.widget.imagebox(beautiful.widget_hdd)
- fswidget = lain.widgets.fs({
- settings = function()
- widget:set_text(" " .. fs_now.used .. "% ")
- end
- })
- fswidget:buttons(awful.util.table.join(awful.button({ }, 1, function () mymainmenu:toggle() fswidget.hide() end)))
- fsicon:buttons(awful.util.table.join(awful.button({ }, 1, function () mymainmenu:toggle() end)))
- -- Меню выключения
- powicon = wibox.widget.imagebox(beautiful.widget_ac)
- powicon:buttons(awful.util.table.join(awful.button({ }, 1, function () mypowermenu:toggle() end)))
- -- Сеть
- neticon = wibox.widget.imagebox(beautiful.widget_net)
- netwidget = lain.widgets.net({
- settings = function()
- widget:set_markup(markup("#7AC82E", " " .. net_now.received)
- .. " " ..
- markup("#46A8C3", " " .. net_now.sent .. " "))
- end
- })
- netwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () mywifimenu:toggle() end)))
- neticon:buttons(awful.util.table.join(awful.button({ }, 1, function () mywifimenu:toggle() end)))
- -- Разделитель
- spr = wibox.widget.textbox(' ')
- arrl = wibox.widget.imagebox()
- arrl:set_image(beautiful.arrl)
- arrl_dl = separators.arrow_left(beautiful.bg_focus, "alpha")
- arrl_ld = separators.arrow_left("alpha", beautiful.bg_focus)
- lain.widgets.calendar:attach(mytextclock)
- -- Создать wibox
- mywibox = {}
- mypromptbox = {}
- mylayoutbox = {}
- mytaglist = {}
- mytaglist.buttons = awful.util.table.join(
- awful.button({ }, 1, awful.tag.viewonly),
- awful.button({ modkey }, 1, awful.client.movetotag),
- awful.button({ }, 3, awful.tag.viewtoggle),
- awful.button({ modkey }, 3, awful.client.toggletag)
- )
- mytasklist = {}
- mytasklist.buttons = awful.util.table.join(
- awful.button({ }, 1, function (c)
- if c == client.focus then
- c.minimized = true
- else
- c.minimized = false
- if not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
- end
- client.focus = c
- c:raise()
- end
- end),
- awful.button({ }, 3, function (c)
- if instance then
- instance:hide()
- instance = nil
- else
- instance = context_menu(c)
- end
- end ))
- for s = 1, screen.count() do
- mypromptbox[s] = awful.widget.prompt()
- mylayoutbox[s] = awful.widget.layoutbox(s)
- mylayoutbox[s]:buttons(awful.util.table.join(
- awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
- awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
- awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
- mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
- mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
- -- mytasklist[s]:add_signal("mouse::enter", function() mytasklist[s].show() end)
- -- mytasklist[s]:add_signal("mouse::leave", function() mytasklist[s].hide() end)
- mywibox[s] = awful.wibox({ position = "top", ontop=true, screen = s, height = 18, bg =
- beautiful.bg_normal})
- -- Виджеты слева сверху
- local left_layout = wibox.layout.fixed.horizontal()
- left_layout:add(spr)
- left_layout:add(mypromptbox[s])
- -- Виджеты справа сверху
- local right_layout_toggle = true
- local function right_layout_add (...)
- local arg = {...}
- if right_layout_toggle then
- right_layout:add(arrl_ld)
- for i, n in pairs(arg) do
- right_layout:add(wibox.widget.background(n ,beautiful.bg_focus))
- end
- else
- right_layout:add(arrl_dl)
- for i, n in pairs(arg) do
- right_layout:add(n)
- end
- end
- right_layout_toggle = not right_layout_toggle
- end
- right_layout = wibox.layout.fixed.horizontal()
- if s == 1 then
- local systray = wibox.widget.systray()
- local systray_margin = wibox.layout.margin()
- systray_margin:set_margins(2)
- systray_margin:set_widget(systray)
- right_layout:add(systray_margin)
- end
- right_layout_add(mytaglist[s])
- right_layout_add(kbdcfg.widget)
- right_layout_add(memicon, memwidget)
- right_layout_add(cpuicon, cpuwidget)
- right_layout_add(fsicon, fswidget)
- right_layout_add(neticon, netwidget)
- right_layout_add(volicon, volumewidget)
- right_layout_add(mytextclock, spr)
- right_layout_add(powicon)
- right_layout_add(mylayoutbox[s])
- -- Сборка вместе
- local layout = wibox.layout.align.horizontal()
- layout:set_left(left_layout)
- layout:set_middle(mytasklist[s])
- layout:set_right(right_layout)
- mywibox[s]:set_widget(layout)
- end
- -- }}}
- -- {{{ Сочетания мыши
- root.buttons(awful.util.table.join())
- -- }}}
- -- {{{ Сочетания клавиш клавиатуры
- globalkeys = awful.util.table.join(
- -- скриншот
- awful.key({ }, "Print", function () run_once("deepin-screenshot") end),
- -- смена тегов
- awful.key({ modkey }, "Left", awful.tag.viewprev ),
- awful.key({ modkey }, "Right", awful.tag.viewnext ),
- -- Громкость Pulseaudio
- awful.key({ altkey }, "Up",
- function ()
- os.execute("pactl set-sink-volume 0 +5%")
- os.execute("pactl set-sink-volume 1 +5%")
- os.execute("pactl set-sink-volume 2 +5%")
- volumewidget.update()
- end),
- awful.key({ altkey }, "Down",
- function ()
- os.execute("pactl set-sink-volume 0 -5%")
- os.execute("pactl set-sink-volume 1 -5%")
- os.execute("pactl set-sink-volume 2 -5%")
- volumewidget.update()
- end),
- awful.key({ altkey }, "Left",
- function ()
- os.execute("pactl set-sink-volume 0 0%")
- os.execute("pactl set-sink-volume 1 0%")
- os.execute("pactl set-sink-volume 2 0%")
- volumewidget.update()
- end),
- awful.key({ altkey }, "Right",
- function ()
- os.execute("pactl set-sink-volume 0 100%")
- os.execute("pactl set-sink-volume 1 100%")
- os.execute("pactl set-sink-volume 2 100%")
- volumewidget.update()
- end),
- -- Показать/скрыть Wibox
- awful.key({ modkey }, "b", function ()
- mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
- end),
- -- Запуск программ
- awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
- awful.key({ modkey, }, "Delete", function () awful.util.spawn('nautilus') end),
- awful.key({ modkey, }, "End", function () awful.util.spawn('sudo nautilus') end),
- awful.key({ modkey, }, "Insert", function () awful.util.spawn(editor) end),
- awful.key({ modkey, "Control" }, "r", awesome.restart),
- awful.key({ modkey, "Shift" }, "q", awesome.quit),
- -- Блокировка
- awful.key({ modkey, }, "l", function () awful.util.spawn("xtrlock") end),
- -- Терминал как часть таскбара
- awful.key({ modkey, }, "Shift_R", function () drop(terminal) end),
- -- Смена раскладки
- awful.key({ "Mod1" }, "Shift_L", function () kbdcfg.switch() end),
- -- Копировать
- awful.key({ modkey }, "c", function () os.execute("xsel -p -o | xsel -i -b") end),
- -- Консоль
- awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
- awful.key({ modkey }, "x",
- function ()
- awful.prompt.run({ prompt = "Выполнить Lua-скрипт: " },
- mypromptbox[mouse.screen].widget,
- awful.util.eval, nil,
- awful.util.getdir("cache") .. "/history_eval")
- end)
- )
- clientkeys = awful.util.table.join(
- awful.key({ modkey }, "F7", function(c) c.maximized_horizontal = not c.maximized_horizontal end),
- awful.key({ modkey }, "F8", function(c) c.maximized_vertical = not c.maximized_vertical end),
- awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
- awful.key({ modkey, }, "q", function (c) c:kill() end),
- awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
- awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
- awful.key({ modkey, "Control" }, "Delete", function () awful.util.spawn('gnome-system-monitor') end),
- awful.key({ modkey, }, "o", awful.client.movetoscreen ),
- awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
- awful.key({ modkey, }, "n",
- function (c)
- c.minimized = true
- end),
- awful.key({ modkey, }, "m",
- function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end)
- )
- clientbuttons = awful.util.table.join(
- awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
- awful.button({ modkey }, 1, awful.mouse.client.move),
- awful.button({ modkey }, 3, awful.mouse.client.resize))
- root.keys(globalkeys)
- -- }}}
- -- {{{ Правила для окон
- awful.rules.rules = {
- { rule = { },
- properties = { border_width = beautiful.border_width,
- border_color = beautiful.border_normal,
- focus = awful.client.focus.filter,
- keys = clientkeys,
- buttons = clientbuttons,
- size_hints_honor = false,
- switchtotag = true } },
- { rule = { class = "Nautilus",
- instance = "desktop_window" },
- properties = { maximized_vertical = true,
- maximized_horizontal = true,
- sticky = true } },
- { rule = { instance = "nautilus" },
- properties = { maximized_vertical = false,
- maximized_horizontal = false,
- sticky = false } },
- { rule = { instance = "chrome"},
- properties = { tag = tags[1][1] } },
- { rule = { instance = "Telegram"},
- properties = { tag = tags[1][2] } },
- { rule = { instance = "skype"},
- properties = { tag = tags[1][2] } },
- { rule = { instance = "gimp"},
- properties = { tag = tags[1][5] } },
- { rule = { instance = "gnome-system-monitor"},
- properties = { floating = true } },
- { rule = { instance = "pavucontrol"},
- properties = { floating = true } },
- { rule = { instance = "gedit"},
- properties = { tag = tags[1][4] } }
- }
- -- }}}
- -- {{{ Сигналы
- -- сигнальная функция для вызова при появлении новых окон
- local sloppyfocus_last = {c=nil}
- client.connect_signal("manage", function (c, startup)
- client.connect_signal("mouse::enter", function(c)
- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
- and awful.client.focus.filter(c) then
- if c ~= sloppyfocus_last.c then
- client.focus = c
- sloppyfocus_last.c = c
- end
- end
- end)
- if not startup then
- if not c.size_hints.user_position and not c.size_hints.program_position then
- awful.placement.centered(c)
- awful.placement.no_offscreen(c)
- end
- end
- local titlebars_enabled = false
- if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
- local buttons = awful.util.table.join(
- awful.button({ }, 1, function()
- client.focus = c
- c:raise()
- awful.mouse.client.move(c)
- end),
- awful.button({ }, 3, function()
- client.focus = c
- c:raise()
- awful.mouse.client.resize(c)
- end)
- )
- --
- local right_layout = wibox.layout.fixed.horizontal()
- right_layout:add(awful.titlebar.widget.floatingbutton(c))
- right_layout:add(awful.titlebar.widget.maximizedbutton(c))
- right_layout:add(awful.titlebar.widget.stickybutton(c))
- right_layout:add(awful.titlebar.widget.ontopbutton(c))
- right_layout:add(awful.titlebar.widget.closebutton(c))
- local middle_layout = wibox.layout.flex.horizontal()
- local title = awful.titlebar.widget.titlewidget(c)
- title:set_align("center")
- middle_layout:add(title)
- middle_layout:buttons(buttons)
- local layout = wibox.layout.align.horizontal()
- layout:set_right(right_layout)
- layout:set_middle(middle_layout)
- awful.titlebar(c,{size=16}):set_widget(layout)
- end
- end)
- floatgeoms = {}
- tag.connect_signal("property::layout", function(t)
- for k, c in ipairs(t:clients()) do
- if ((awful.layout.get(mouse.screen) == awful.layout.suit.floating) or (awful.client.floating.get(c) == true)) then
- c:geometry(floatgeoms[c.window])
- end
- end
- end)
- client.connect_signal("property::geometry", function(c)
- if ((awful.layout.get(mouse.screen) == awful.layout.suit.floating) or (awful.client.floating.get(c) == true)) then
- floatgeoms[c.window] = c:geometry()
- end
- end)
- client.connect_signal("unmanage", function(c) floatgeoms[c.window] = nil end)
- client.connect_signal("manage", function(c)
- if ((awful.layout.get(mouse.screen) == awful.layout.suit.floating) or (awful.client.floating.get(c) == true)) then
- floatgeoms[c.window] = c:geometry()
- end
- end)
- client.connect_signal("focus",
- function(c)
- if c.maximized_horizontal == true and c.maximized_vertical == true then
- c.border_color = beautiful.border_normal
- else
- c.border_color = beautiful.border_normal
- end
- end)
- client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
- -- }}}
- -- {{{
- for s = 1, screen.count() do screen[s]:connect_signal("arrange", function ()
- local clients = awful.client.visible(s)
- local layout = awful.layout.getname(awful.layout.get(s))
- if #clients > 0 then
- for _, c in pairs(clients) do
- if awful.client.floating.get(c) or layout == "floating" then
- c.border_width = beautiful.border_width
- elseif #clients == 1 or layout == "max" then
- c.border_width = 0
- else
- c.border_width = beautiful.border_width
- end
- end
- end
- end)
- end
- -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement