Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Для работы нужны:
- --
- -- скрипт calendar2
- -- тема dust
- -- программа slock
- -- программа kbdd
- -- библиотека vicious
- -- библиотека blingbling (из оверлея stuff)
- -- Стандартные библиотеки awesome
- require("awful")
- require("awful.autofocus")
- require("awful.rules")
- require("beautiful")
- require("naughty")
- -- Сторонние библиотеки и вложения
- require("calendar2")
- require("vicious")
- require("blingbling")
- -- Ошибка запуска awesome
- 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.add_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
- -- Тема, используемая в awesome
- beautiful.init("/usr/share/awesome/themes/dust/theme.lua")
- -- Редактор/терминал по умолчанию
- terminal = "konsole"
- editor_cmd = "kwrite"
- -- Клавиша-модификатор
- modkey = "Mod4"
- -- Раскладки для окон
- layouts =
- {
- awful.layout.suit.floating,
- awful.layout.suit.tile,
- awful.layout.suit.tile.left,
- awful.layout.suit.tile.bottom,
- awful.layout.suit.tile.top,
- awful.layout.suit.fair,
- awful.layout.suit.fair.horizontal,
- awful.layout.suit.spiral,
- awful.layout.suit.spiral.dwindle,
- awful.layout.suit.max,
- awful.layout.suit.max.fullscreen,
- awful.layout.suit.magnifier
- }
- -- }}}
- -- Привязки тэгов.
- --
- tags = {
- names = { "1:main", "2:devel", "3:editor", "4:files", "5:media", "6:office", "7:term", "8:www","9:misc"},
- layout = { layouts[1], layouts[1], layouts[1], layouts[2], layouts[2],
- layouts[1], layouts[2], layouts[1], layouts[2]
- }}
- for s = 1, screen.count() do
- -- Each screen has its own tag table.
- tags[s] = awful.tag(tags.names, s, tags.layout)
- end
- -- }}}
- -- Меню и его виджет
- myawesomemenu = {
- { "manual", terminal .. " -e man awesome" },
- { "edit config", editor_cmd .. " " .. awesome.conffile },
- { "restart", awesome.restart },
- { "quit", awesome.quit }
- }
- -- Меню отключения
- poweroffmenu = {
- { "reboot", "sudo reboot" },
- { "shutdown", "sudo poweroff" },
- }
- -- Основное меню
- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
- { "Terminal", terminal },
- { "Exit", poweroffmenu }
- }
- })
- mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
- menu = mymainmenu })
- -- Виджет простых текстовых часов
- mytextclock = awful.widget.textclock({ align = "right" }, "<span color='cyan'>%a %d %b, %H:%M</span>")
- calendar2.addCalendarToWidget(mytextclock, "<span color='green'>%s</span>")
- -- Системный трей
- mysystray = widget({ type = "systray" })
- -- 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),
- awful.button({ }, 4, awful.tag.viewnext),
- awful.button({ }, 5, awful.tag.viewprev)
- )
- mytasklist = {}
- mytasklist.buttons = awful.util.table.join(
- awful.button({ }, 1, function (c)
- if c == client.focus then
- c.minimized = true
- else
- 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({ layout = awful.widget.layout.horizontal.leftright })
- -- Create an imagebox widget which will contains an icon indicating which layout we're using.
- -- We need one layoutbox per screen.
- 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.label.all, mytaglist.buttons)
- -- Создание списка задач
- mytasklist[s] = awful.widget.tasklist(function(c)
- return awful.widget.tasklist.label.currenttags(c, s)
- end, mytasklist.buttons)
- -- Создаем наш wibox
- mywibox[s] = awful.wibox({ position = "top", screen = s })
- -- Настроенные виджеты
- -- Индикатор раскладки клавиатуры
- kbdwidget = widget({type = "textbox", name = "kbdwidget"})
- kbdwidget.border_color = beautiful.fg_normal
- kbdwidget.text = " Eng "
- dbus.request_name("session", "ru.gentoo.kbdd")
- dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
- dbus.add_signal("ru.gentoo.kbdd", function(...)
- local data = {...}
- local layout = data[2]
- lts = {[0] = "<span color='lightgreen'>Eng</span>", [1] = "Rus"}
- kbdwidget.text = " "..lts[layout].." "
- end
- )
- -- Регулировка звука
- volume_label = widget ({ type = "textbox" })
- volume_label.text = "♫"
- my_volume=blingbling.volume.new()
- my_volume:set_height(18)
- my_volume:set_v_margin(4)
- my_volume:set_width(20)
- my_volume:update_master()
- my_volume:set_master_control()
- my_volume:set_bar(true)
- my_volume:set_background_graph_color("#444444")--beautiful.bg_focus)
- my_volume:set_graph_color(beautiful.motive)--beautiful.fg_normal)
- -- Индикаторы сети
- netwidget = widget({ type = "textbox" })
- vicious.register(netwidget, vicious.widgets.net, "<span color='green'>up: ${usb0 up_kb}</span> <span color='red'>down: ${usb0 down_kb}</span>", 3)
- -- Загрузка процессора
- cpuwidget = widget({ type = "textbox" })
- vicious.register(cpuwidget, vicious.widgets.cpu, "cpu: $2%")
- -- Разделитель
- sep = widget ({ type = "textbox" })
- sep.text = " "
- -- Добавляем виджеты на wibox
- mywibox[s].widgets = {
- {
- mylauncher,
- mytaglist[s],
- mypromptbox[s],
- layout = awful.widget.layout.horizontal.leftright
- },
- mylayoutbox[s],sep,
- netwidget,sep,
- cpuwidget,sep,
- my_volume.widget,sep,
- volume_label,sep,
- kbdwidget,sep,
- mytextclock,sep,
- s == 1 and mysystray or nil,
- mytasklist[s],
- layout = awful.widget.layout.horizontal.rightleft
- }
- end
- -- }}}
- -- {{{ Привязка клавиш мыши
- 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)
- ))
- -- }}}
- -- {{{ Клавиатурные сочетания
- 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, }, "w", function () mymainmenu:show({keygrabber=true}) 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, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
- awful.key({ modkey, "Control" }, "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),
- -- Standard program
- awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
- awful.key({ modkey, "Control" }, "r", awesome.restart),
- awful.key({ modkey, "Shift" }, "q", awesome.quit),
- 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, "Control" }, "h", function () awful.tag.incncol( 1) end),
- awful.key({ modkey, "Control" }, "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),
- awful.key({ modkey, "Control" }, "n", awful.client.restore),
- -- Строка запуска приложений
- awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
- awful.key({ modkey }, "x",
- function ()
- awful.prompt.run({ prompt = "Run Lua code: " },
- mypromptbox[mouse.screen].widget,
- awful.util.eval, nil,
- awful.util.getdir("cache") .. "/history_eval")
- end),
- -- Скрыть панель по Mod + b
- awful.key({ modkey }, "b",
- function ()
- if mywibox[mouse.screen].screen == nil then
- mywibox[mouse.screen].screen = mouse.screen
- else
- mywibox[mouse.screen].screen = nil
- end
- end),
- -- Блокировка экрана с помощью slock по Mod + y
- awful.key({ modkey }, "y",
- function()
- awful.util.spawn("slock")
- end)
- )
- clientkeys = awful.util.table.join(
- awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
- awful.key({ modkey, "Shift" }, "c", 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, }, "o", awful.client.movetoscreen ),
- awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
- awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
- awful.key({ modkey, }, "n",
- function (c)
- -- The client currently has the input focus, so it cannot be
- -- minimized, since minimized clients can't have the focus.
- 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),
- -- Информация о клиенте Mod + Ctrl + i
- awful.key({ modkey, "Control" }, "i",
- function (c)
- naughty.notify({ text =
- "Class: " .. c.class ..
- "\nInstance: " .. c.instance ..
- "\nName: " .. c.name .. "\n",
- width = 400 })
- 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)
- -- }}}
- -- Растановка приложений по тэгам
- awful.rules.rules = {
- -- All clients will match this rule.
- { rule = { },
- properties = { border_width = beautiful.border_width,
- border_color = beautiful.border_normal,
- focus = true,
- keys = clientkeys,
- buttons = clientbuttons } },
- { rule = { class = "SMPlayer" },
- properties = { floating = true } },
- { rule = { class = "Gimp" },
- properties = { floating = true } },
- { rule = { class = "Konsole" },
- properties = { floating = false } },
- { rule = { class = "Dolphin" },
- properties = { floating = false } },
- { rule = { class = "Chromium" },
- properties = { floating = false } },
- { rule = { class = "jEdit" },
- properties = { floating = false } },
- { rule = { class = "Lxterminal" },
- properties = { floating = false } },
- { rule = { class = "jEdit" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "Dolphin" },
- properties = { tag = tags[1][4] } },
- { rule = { class = "Konsole" },
- properties = { tag = tags[1][7] } },
- { rule = { class = "Chromium" },
- properties = { tag = tags[1][8] } },
- { rule = { class = "Smplayer" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "LibreOffice" },
- properties = { tag = tags[1][6] } },
- { rule = { class = "VLC" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "Kwrite" },
- properties = { tag = tags[1][3] } },
- { rule = { class = "Amarok" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "lxmusic" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "SMPlayer" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "VirtualBox" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "lxterminal" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "Vim" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "FileZilla" },
- properties = { tag = tags[1][8] } },
- { rule = { class = "Gwenview" },
- properties = { tag = tags[1][5] } },
- { rule = { class = "Ark" },
- properties = { tag = tags[1][4] } },
- -- Set Firefox to always map on tags number 2 of screen 1.
- -- { rule = { class = "Firefox" },
- -- properties = { tag = tags[1][2] } },
- }
- -- }}}
- -- {{{ Signals
- -- Signal function to execute when a new client appears.
- client.add_signal("manage", function (c, startup)
- -- Add a titlebar
- -- awful.titlebar.add(c, { modkey = modkey })
- -- Enable sloppy focus
- c:add_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
- end)
- client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
- client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
- -- }}}
- -- Секция автозапуска
- function run_once(prg)
- if not prg then
- do return nil end
- end
- awful.util.spawn_with_shell("x=" .. prg .. "; pgrep -u $USERNAME -x " .. prg .. " || (" .. prg .. ")")
- end
- run_once("kbdd") -- Клавиатурный демон
- run_once(terminal) -- Терминал
- naughty.notify({
- text = "Awesome запущен !!!",
- title = "Уведомление: ",
- fg="#ffggcc",
- bg="#bbggcc",
- screen = 1,
- ontop = false
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement