Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gears = require("gears")
- local awful = require("awful")
- awful.rules = require("awful.rules")
- require("awful.autofocus")
- local wibox = require("wibox")
- local beautiful = require("beautiful")
- local naughty = require("naughty")
- local vicious = require("vicious")
- -- Цвета виджетов
- main_color = "#afdd00"
- sub_color = "#E6AD04"
- -- Кое-какие бинды
- terminal = "urxvtc"
- editor = "vim"
- editor_cmd = terminal .. " -x " .. editor
- awesome_dir = "/home/ilya/.config/awesome/"
- modkey = "Mod1"
- -- Включаем тему
- beautiful.init(awesome_dir .. "/themes/inspgreen/theme.lua")
- -- Отключил для dmenu
- --local menubar = require("menubar")
- --menubar.utils.terminal = terminal
- dmenu_run = "dmenu_run -b -nb '"..beautiful.bg_normal.."' -sb '"..beautiful.bg_normal.."' -sf '"..beautiful.fg_focus.."'"
- -- Стол
- if awesome.startup_errors then
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Oops, there were errors during startup!",
- 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 = "Oops, an error happened!",
- text = err })
- in_error = false
- end)
- end
- local layouts =
- {
- awful.layout.suit.floating,
- awful.layout.suit.tile,
- awful.layout.suit.tile.left,
- awful.layout.suit.tile.top,
- awful.layout.suit.max,
- awful.layout.suit.max.fullscreen,
- }
- if beautiful.wallpaper then
- for s = 1, screen.count() do
- gears.wallpaper.maximized(beautiful.wallpaper, s, true)
- end
- end
- tags = {
- names = { "α", "β", "γ", "δ", "ε" },
- layout = { layouts[5], layouts[5], layouts[5], layouts[5], layouts[5], } }
- for s = 1, screen.count() do
- tags[s] = awful.tag(tags.names, s, tags.layout)
- end
- -- Мои виджеты
- --- Пробел
- space = wibox.widget.textbox()
- space:set_text(" ")
- -- Спойлер
- spoiler = wibox.widget.textbox()
- spoiler:set_markup('<span color="'.. sub_color ..'"> | </span>')
- -- Дата
- datewidget = wibox.widget.textbox()
- vicious.register(datewidget, vicious.widgets.date, '<span color="'.. main_color .. '">%R </span>', 60)
- -- Батарея
- batwidget = wibox.widget.textbox()
- vicious.register(batwidget, vicious.widgets.bat, '<span color="'..main_color..'">'..'$2%</span> <span color="'..sub_color..'">'..'$1</span>', 120, "BAT0")
- -- mpd
- mpdwidget = wibox.widget.textbox()
- vicious.register(mpdwidget, vicious.widgets.mpd,
- function (widget, args)
- if args["{state}"] == "Stop" then
- return " - "
- else
- return '<span color="'.. sub_color ..'"> ♫</span> <span color="'.. main_color .. '">' .. args['{Artist}'] .. ' - ' .. args['{Title}'] .. '</span> <span color="'.. sub_color ..'">♫</span>'
- end
- end, 25)
- -- Календарь
- local calendar = nil
- local offset = 0
- function remove_calendar()
- if calendar ~= nil then
- naughty.destroy(calendar)
- calendar = nil
- offset = 0
- end
- end
- function add_calendar(inc_offset)
- local save_offset = offset
- remove_calendar()
- offset = save_offset + inc_offset
- local datespec = os.date("*t")
- datespec = datespec.year * 12 + datespec.month - 1 + offset
- datespec = (datespec % 12 + 1) .. " " .. math.floor(datespec / 12)
- local cal = awful.util.pread("cal -m " .. datespec)
- cal = string.gsub(cal, "^%s*(.-)%s*$", "%1")
- calendar = naughty.notify({
- text = string.format('<span font_desc="%s">%s</span>', "Terminus 8", os.date("%a, %d %B %Y") .. "\n" .. cal),
- timeout = 0, hover_timeout = 0.5,
- width = 160,
- })
- end
- -- Добавляем сигнал
- datewidget:connect_signal("mouse::enter", function()
- add_calendar(0)
- end)
- datewidget:connect_signal("mouse::leave", remove_calendar)
- -- coverart
- local coverart_nf
- function coverart_show()
- coverart_hide()
- local img = awful.util.pread(awesome_dir .. "/scripts/coverart/coverart.sh")
- local txt = awful.util.pread(awesome_dir .. "/scripts/coverart/musicinfo.sh")
- coverart_nf = naughty.notify({icon = img, icon_size = 100, text = txt, position = "top_right"})
- end
- function coverart_hide()
- if coverart_nf ~= nil then
- naughty.destroy(coverart_nf)
- end
- end
- -- coverart и лирика
- mpdwidget:connect_signal("mouse::enter", function()
- coverart_show()
- end)
- mpdwidget:connect_signal("mouse::leave", function()
- coverart_hide()
- end)
- mywibox = {}
- mypromptbox = {}
- 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),
- awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
- awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
- )
- mytasklist = {}
- mytasklist.buttons = awful.util.table.join(
- awful.button({ }, 1, function (c)
- if c == client.focus then
- c.minimized = true
- else
- -- Without this, the following
- -- :isvisible() makes no sense
- c.minimized = false
- if not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
- end
- -- This will also un-minimize
- -- the client, if needed
- client.focus = c
- c:raise()
- end
- end),
- awful.button({ }, 3, function ()
- if instance then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({ width=250 })
- end
- end),
- awful.button({ }, 4, function ()
- awful.client.focus.byidx(1)
- if client.focus then client.focus:raise() end
- end),
- awful.button({ }, 5, function ()
- awful.client.focus.byidx(-1)
- if client.focus then client.focus:raise() end
- end))
- for s = 1, screen.count() do
- -- Create a promptbox for each screen
- mypromptbox[s] = awful.widget.prompt()
- mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
- -- Create a tasklist widget
- mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
- -- Create the wibox
- mywibox[s] = awful.wibox({ position = "top", screen = s })
- -- Widgets that are aligned to the left
- local left_layout = wibox.layout.fixed.horizontal()
- left_layout:add(mytaglist[s])
- left_layout:add(mypromptbox[s])
- -- !!!
- left_layout:add(spoiler)
- left_layout:add(batwidget)
- left_layout:add(spoiler)
- -- Widgets that are aligned to the right
- local right_layout = wibox.layout.fixed.horizontal()
- right_layout:add(mpdwidget)
- right_layout:add(spoiler)
- if s == 1 then right_layout:add(wibox.widget.systray()) end
- right_layout:add(spoiler)
- right_layout:add(datewidget)
- -- Now bring it all together (with the tasklist in the middle)
- 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
- -- }}}
- -- {{{ Mouse bindings
- root.buttons(awful.util.table.join(
- -- awful.button({ }, 3, function () mymainmenu:toggle() end),
- awful.button({ }, 4, awful.tag.viewnext),
- awful.button({ }, 5, awful.tag.viewprev)
- ))
- -- }}}
- -- {{{ Key bindings
- globalkeys = awful.util.table.join(
- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
- awful.key({ modkey, }, "Escape", awful.tag.history.restore),
- awful.key({ modkey, }, "j",
- function ()
- awful.client.focus.byidx( 1)
- if client.focus then client.focus:raise() end
- end),
- awful.key({ modkey, }, "k",
- function ()
- awful.client.focus.byidx(-1)
- if client.focus then client.focus:raise() end
- end),
- awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
- awful.key({ modkey, "Shift"}, "k", function () awful.client.swap.byidx( -1) end),
- awful.key({ modkey}, "j", function () awful.screen.focus_relative( 1) end),
- awful.key({ modkey}, "k", function () awful.screen.focus_relative(-1) end),
- awful.key({ modkey}, "u", awful.client.urgent.jumpto),
- awful.key({ modkey}, "Tab",
- function ()
- awful.client.focus.history.previous()
- if client.focus then
- client.focus:raise()
- end
- end),
- awful.key({ modkey, "Control" }, "Return", function () awful.util.spawn(terminal) end),
- awful.key({ modkey, "Control" }, "r", awesome.restart),
- -- Перезагрузка и выключение
- awful.key({ "Shift", "Control" }, "h", function () awful.util.spawn("user-halt") end),
- awful.key({ "Shift", "Control" }, "r", function () awful.util.spawn("user-reboot") end),
- -- Хоткеи на приложения
- awful.key({ modkey, "Control" }, "o", function () awful.util.spawn("firefox-bin") end),
- awful.key({ modkey, "Control" }, "j", function () awful.util.spawn("gajim") end),
- awful.key({ modkey, "Control" }, "t", function () awful.util.spawn("transmission-gtk") end),
- awful.key({ modkey, "Control" }, "k", function () awful.util.spawn("thunar") end),
- awful.key({ modkey, "Control" }, "p", function () awful.util.spawn("slimlock") end),
- awful.key({ modkey, "Control" }, "s", function () awful.util.spawn("skype") end),
- awful.key({ modkey, "Control" }, "m", function () awful.util.spawn("urxvtc -e ncmpcpp") end),
- awful.key({ modkey, "Control" }, "b", function () awful.util.spawn("fbreader") end),
- awful.key({ modkey, "Control" }, "v", function () awful.util.spawn("smplayer") end),
- awful.key({ modkey, "Control" }, "e", function () awful.util.spawn("geany") end),
- awful.key({ modkey, "Control" }, "l", function () awful.util.spawn("libreoffice") end),
- awful.key({ modkey, "Control" }, "g", function () awful.util.spawn("gimp") end),
- -- Спец. Кнопки
- awful.key({ }, "XF86AudioMute", function () awful.util.spawn("amixer -c 2 set Speaker toggle") end),
- awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer -c 2 set Speaker 2+ unmute") end),
- awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn("amixer -c 2 set Speaker 2-") end),
- -- Управление mpd
- awful.key({ modkey, }, "b", function () awful.util.spawn("mpc prev") end),
- awful.key({ modkey, }, "p", function () awful.util.spawn("mpc toggle") end),
- awful.key({ modkey, }, "n", function () awful.util.spawn("mpc next") end),
- awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
- awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
- awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
- awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
- awful.key({ modkey, }, "l", function () awful.tag.incncol(-1) end),
- awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
- awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
- -- Больно тормозной, переключу на dmenu
- -- awful.key({ modkey }, "r", function() menubar.show() end)
- awful.key({ modkey }, "r", function() awful.util.spawn(dmenu_run) end)
- )
- clientkeys = awful.util.table.join(
- awful.key({ "Control" }, "f", function (c) c.max = not c.fullscreen end),
- awful.key({ modkey, "Control" }, "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, }, "t", function (c) c.ontop = not c.ontop end),
- awful.key({ modkey, }, "m",
- function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end)
- )
- -- Compute the maximum number of digit we need, limited to 9
- keynumber = 0
- for s = 1, screen.count() do
- keynumber = math.min(9, math.max(#tags[s], keynumber))
- end
- -- Bind all key numbers to tags.
- -- Be careful: we use keycodes to make it works on any keyboard layout.
- -- This should map on the top row of your keyboard, usually 1 to 9.
- for i = 1, keynumber do
- globalkeys = awful.util.table.join(globalkeys,
- awful.key({ modkey }, "#" .. i + 9,
- function ()
- local screen = mouse.screen
- if tags[screen][i] then
- awful.tag.viewonly(tags[screen][i])
- end
- end),
- awful.key({ modkey, "Control" }, "#" .. i + 9,
- function ()
- local screen = mouse.screen
- if tags[screen][i] then
- awful.tag.viewtoggle(tags[screen][i])
- end
- end),
- awful.key({ modkey, "Shift" }, "#" .. i + 9,
- function ()
- if client.focus and tags[client.focus.screen][i] then
- awful.client.movetotag(tags[client.focus.screen][i])
- end
- end),
- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
- function ()
- if client.focus and tags[client.focus.screen][i] then
- awful.client.toggletag(tags[client.focus.screen][i])
- end
- end))
- 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))
- -- Set keys
- root.keys(globalkeys)
- -- }}}
- -- {{{ Rules
- awful.rules.rules = {
- -- All clients will match this rule.
- { rule = { },
- properties = { border_width = beautiful.border_width,
- border_color = beautiful.border_normal,
- focus = awful.client.focus.filter,
- -- Без отступов
- size_hints_honor = false,
- keys = clientkeys,
- buttons = clientbuttons } },
- { rule = { class = "Firefox" },
- properties = { tag = tags[1][1] } },
- { rule = { class = "Skype" },
- properties = { tag = tags[1][3] } },
- { rule = { class = "Xfdesktop" }, callback = function(c) c:tags({
- tags[1][1], tags[1][2],tags[1][3],tags[1][4],tags[1][5]}) end},
- }
- -- {{{ Signals
- -- Signal function to execute when a new client appears.
- client.connect_signal("manage", function (c, startup)
- -- Enable sloppy focus
- c:connect_signal("mouse::enter", function(c)
- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
- and awful.client.focus.filter(c) then
- client.focus = c
- end
- end)
- if not startup then
- -- Set the windows at the slave,
- -- i.e. put it at the end of others instead of setting it master.
- -- awful.client.setslave(c)
- -- Put windows in a smart way, only if they does not set an initial position.
- if not c.size_hints.user_position and not c.size_hints.program_position then
- awful.placement.no_overlap(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 left_layout = wibox.layout.fixed.horizontal()
- left_layout:add(awful.titlebar.widget.iconwidget(c))
- 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 title = awful.titlebar.widget.titlewidget(c)
- title: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 layout = wibox.layout.align.horizontal()
- layout:set_left(left_layout)
- layout:set_right(right_layout)
- layout:set_middle(title)
- awful.titlebar(c):set_widget(layout)
- end
- end)
- -- Без рамок для полноэкранных окон
- client.connect_signal("focus",
- function(c)
- if c.maximized_horizontal == true and c.maximized_vertical == true then
- c.border_width = "0"
- c.border_color = beautiful.border_focus
- else
- c.border_width = beautiful.border_width
- c.border_color = beautiful.border_focus
- end
- end)
- client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
- -- Скрипт для автостарта приложений
- awful.util.spawn_with_shell(awesome_dir .. "/scripts/autostart.sh")
Advertisement
Add Comment
Please, Sign In to add comment