Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Modules
- local gears = require("gears")
- local naughty = require("naughty")
- local wibox = require("wibox")
- local beautiful = require("beautiful")
- local lain = require("lain")
- local vicious = require("vicious")
- local menubar = require("menubar")
- local volume = require("volume")
- local awful = require("awful")
- awful.rules = require("awful.rules")
- awful.autofocus = require("awful.autofocus")
- -- Variables
- home_path = os.getenv('HOME') .. '/'
- terminal = "x-terminal-emulator"
- menubar.utils.terminal = terminal -- Set the terminal for applications that require it
- editor = "geany"
- modkey = "Mod4"
- modkey_alt = "Mod1"
- -- Appearance
- beautiful.init(awful.util.getdir("config") .. "/themes/default/theme.lua")
- if beautiful.wallpaper then
- for s = 1, screen.count() do
- gears.wallpaper.maximized(beautiful.wallpaper, s, true)
- end
- end
- -- Returns true if all pairs in table1 are present in table2 (for use by "Run of raise")
- function match (table1, table2)
- for k, v in pairs(table1) do
- if table2[k] ~= v and not table2[k]:find(v) then
- return false
- end
- end
- return true
- end
- -- "Run or raise" function
- function run_or_raise(cmd, properties)
- local clients = client.get()
- local focused = awful.client.next(0)
- local findex = 0
- local matched_clients = {}
- local n = 0
- for i, c in pairs(clients) do
- -- make an array of matched clients
- if match(properties, c) then
- n = n + 1
- matched_clients[n] = c
- if c == focused then
- findex = n
- end
- end
- end
- if n > 0 then
- local c = matched_clients[1]
- -- if the focused window matched switch focus to next in list
- if 0 < findex and findex < n then
- c = matched_clients[findex+1]
- end
- local ctags = c:tags()
- if #ctags == 0 then
- -- ctags is empty, show client on current tag
- local curtag = awful.tag.selected()
- awful.client.movetotag(curtag, c)
- else
- -- Otherwise, pop to first tag client is visible on
- awful.tag.viewonly(ctags[1])
- end
- -- And then focus the client
- client.focus = c
- c:raise()
- return
- end
- awful.util.spawn(cmd)
- end
- -- "Run once" function
- function run_once(prg,arg_string,pname,screen) -- Run PRG once with command-line ARGuments, expecting PNAME as process name on SCREEN
- if not prg then
- do return nil end
- end
- if not pname then
- pname = prg
- end
- if not arg_string then
- awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
- else
- awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
- end
- end
- -- Handle runtime errors after startup
- do
- local in_error = false
- awesome.connect_signal("debug::error", function (err)
- -- Make sure we don't go into an endless error loop
- 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
- -- Autostart
- awful.util.spawn_with_shell('setxkbmap -layout "us,ru" setxkbmap -option "grp:caps_toggle,grp_led:scroll,compose:ralt"')
- run_once("kbdd")
- run_once("xsettingsd")
- run_once("mpd")
- run_once("nm-applet")
- run_once("clipit")
- run_once("transmission-gtk","-m")
- run_once("/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1")
- -- Key bindings
- -- Global
- globalkeys = awful.util.table.join(
- -- Manipulating layouts
- awful.key({ modkey, }, "Left", awful.tag.viewprev),
- awful.key({ modkey, }, "Right", awful.tag.viewnext),
- 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_alt, }, "Tab",
- 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_alt, "Shift" }, "Tab", function () awful.client.swap.byidx(1) end),
- awful.key({ modkey, }, "`", function () awful.client.urgent.jumpto() end),
- awful.key({ modkey, }, "Tab",
- function ()
- awful.client.focus.history.previous()
- if client.focus then
- client.focus:raise()
- end
- end),
- -- Standard program
- awful.key({ modkey, "Shift" }, "r", awesome.restart),
- 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, }, "space", function () awful.layout.inc( 1) end),
- awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end),
- awful.key({ modkey, }, "Escape", awful.tag.history.restore),
- -- Launchers
- awful.key({ modkey, }, "p", function() menubar.show() end),
- awful.key({ modkey, }, "w", function () run_or_raise("x-www-browser", { class = "Iceweasel" }) end),
- awful.key({ modkey, }, "e", function () run_or_raise("icedove", { class = "Icedove" }) end),
- awful.key({ modkey, }, "o", function () awful.util.spawn("dm-tool lock") end),
- awful.key({ modkey, }, "Return", function () awful.util.spawn("x-terminal-emulator") end),
- awful.key({ modkey, }, "F1", function () awful.util.spawn("x-terminal-emulator") end),
- awful.key({ modkey, }, "f", function () awful.util.spawn("thunar") end),
- awful.key({ modkey, }, "q", function () awful.util.spawn("tkscreen") end),
- awful.key({ modkey, }, "a", function () run_or_raise("x-terminal-emulator -T ncmpcpp -e ncmpcpp", { name = "ncmpcpp" }) end),
- awful.key({ modkey, }, "F2", function () run_or_raise("x-terminal-emulator -T htop -e sudo htop", { name = "htop" }) end),
- -- Multimedia
- awful.key({}, "XF86Calculator", function () awful.util.spawn ("qalculate") end),
- awful.key({}, "XF86AudioPlay", function () awful.util.spawn("mpc toggle") end),
- awful.key({}, "XF86AudioNext", function () awful.util.spawn("mpc next") end),
- awful.key({}, "XF86AudioPrev", function () awful.util.spawn("mpc prev") end),
- awful.key({}, "XF86AudioStop", function () awful.util.spawn("mpc stop") end),
- awful.key({}, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer set Master 4%+ on") end),
- awful.key({}, "XF86AudioLowerVolume", function () awful.util.spawn("amixer set Master 4%- on") end),
- awful.key({}, "XF86AudioMute", function () awful.util.spawn("amixer set Master toggle") end)
- )
- clientkeys = awful.util.table.join(
- awful.key({ modkey_alt, }, "F1", function (c) c.fullscreen = not c.fullscreen end),
- awful.key({ modkey_alt, }, "F2",
- function (c)
- c:raise()
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end),
- awful.key({ modkey_alt, }, "F3", awful.client.floating.toggle),
- awful.key({ modkey_alt, }, "F4", function (c) c:kill() end),
- awful.key({ modkey_alt, }, "F5", function (c) c:swap(awful.client.getmaster()) end),
- awful.key({ modkey_alt, }, "F6", function (c) c.ontop = not c.ontop 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)
- ))
- 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))
- -- Table of layouts
- awful.layout.layouts = {
- awful.layout.suit.floating,
- lain.layout.centerfair, -- будет использоваться для тегов, где обычно то, чему не нужен фуллскрин
- awful.layout.suit.fair, -- будет использоваться для всех остальных тегов
- 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
- tags = {
- names = { "www", "music", "mail", 4, 5, 6, 7, 8, 9 },
- layout = { awful.layout.layouts[4], awful.layout.layouts[4], awful.layout.layouts[4], awful.layout.layouts[2], awful.layout.layouts[2],
- awful.layout.layouts[2], awful.layout.layouts[3], awful.layout.layouts[3], awful.layout.layouts[3]
- }}
- for s = 1, screen.count() do
- tags[s] = awful.tag(tags.names, s, tags.layout)
- end
- -- Rules
- awful.rules.rules = {
- { rule = { },
- properties = { border_width = beautiful.border_width,
- border_color = beautiful.border_normal,
- focus = awful.client.focus.filter,
- keys = clientkeys,
- size_hints_honor = false,
- buttons = clientbuttons } },
- { rule = { instance = "pidgin" },
- properties = { floating = true }
- },
- { rule = { instance = "Pidgin" },
- properties = { floating = true }
- },
- { rule = { class = "qemu-system-x86_64" },
- properties = { floating = true }
- },
- { rule = { name = "File Operation Progress" },
- properties = { floating = true }
- },
- { rule = { instance = "qalculate" },
- properties = { floating = true }
- }
- }
- -- Launcher widget and main menu
- myawesomemenu = {
- { "edit config", editor .. " " .. awesome.conffile },
- { "restart", awesome.restart },
- }
- mysessionmenu = {
- { "lock session", "dm-tool lock" },
- { "quit session", awesome.quit },
- { "switch user", "dm-tool switch-to-greeter" },
- { "suspend", "systemctl suspend" },
- { "reboot", "systemctl reboot" },
- { "shutdown", "systemctl poweroff" }
- }
- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "session", mysessionmenu } }
- })
- mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
- menu = mymainmenu })
- -- Wibox
- -- Create a textclock widget
- mytextclock = awful.widget.textclock()
- -- Create a wibox for each screen and add it
- mywibox = {}
- mypromptbox = {}
- mylayoutbox = {}
- mytaglist = {}
- mytaglist.buttons = awful.util.table.join(
- awful.button({ }, 1, awful.tag.viewonly), -- Go to tag
- awful.button({ modkey }, 1, awful.client.movetotag), -- Move focused window to tag
- awful.button({ }, 3, awful.tag.viewtoggle), -- Append tag's windows to current tag
- awful.button({ modkey }, 3, awful.client.toggletag), -- Display focused window on tag
- awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end), -- Scroll through tags
- awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) -- Scroll through tags
- )
- mytasklist = {}
- mytasklist.buttons = awful.util.table.join(
- awful.button({ }, 1, function (c)
- if c == client.focus then -- If in focus, then minimize
- c.minimized = true
- else
- c.minimized = false -- Else, go to window's tag, unminize and give focus
- if not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
- end
- client.focus = c
- c:raise()
- end
- end),
- awful.button({ }, 3, function ()
- if instance then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({
- theme = { width = 250 }
- })
- end
- end),
- awful.button({ }, 4, function () -- Scroll focus through windows
- awful.client.focus.byidx(1)
- if client.focus then client.focus:raise() end
- end),
- awful.button({ }, 5, function () -- Scroll focus through windows
- 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()
- -- 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( 1) end), -- Scroll through layouts
- awful.button({ }, 3, function () awful.layout.inc(-1) end),
- awful.button({ }, 4, function () awful.layout.inc( 1) end),
- awful.button({ }, 5, function () awful.layout.inc(-1) end)))
- -- Create a taglist widget
- 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(mylauncher)
- left_layout:add(mytaglist[s])
- left_layout:add(mypromptbox[s])
- -- Widgets that are aligned to the right
- local right_layout = wibox.layout.fixed.horizontal()
- if s == 1 then right_layout:add(wibox.widget.systray()) end
- right_layout:add(volume_widget)
- right_layout:add(mytextclock)
- right_layout:add(mylayoutbox[s])
- -- 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
- -- Key bindings for tags manipulating
- for i = 1, 9 do
- globalkeys = awful.util.table.join(globalkeys,
- awful.key({ modkey }, "#" .. i + 9,
- function ()
- local screen = mouse.screen
- local tag = awful.tag.gettags(screen)[i]
- if tag then
- awful.tag.viewonly(tag)
- end
- end),
- awful.key({ modkey, "Control" }, "#" .. i + 9, -- ИЗМЕНИТЬ
- function ()
- local screen = mouse.screen
- local tag = awful.tag.gettags(screen)[i]
- if tag then
- awful.tag.viewtoggle(tag)
- end
- end),
- awful.key({ modkey, "Shift" }, "#" .. i + 9,
- function ()
- if client.focus then
- local tag = awful.tag.gettags(client.focus.screen)[i]
- if tag then
- awful.client.movetotag(tag)
- end
- end
- end),
- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, -- ИЗМЕНИТЬ
- function ()
- if client.focus then
- local tag = awful.tag.gettags(client.focus.screen)[i]
- if tag then
- awful.client.toggletag(tag)
- end
- end
- end))
- end
- -- Set keys
- root.keys(globalkeys)
- -- Signals
- -- Signal function to execute when a new client appears.
- client.connect_signal("manage", function (c)
- if not awesome.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
- elseif not c.size_hints.user_position and not c.size_hints.program_position then
- -- Prevent clients from being unreachable after screen count change
- awful.placement.no_offscreen(c)
- end
- local titlebars_enabled = false
- if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
- -- buttons for the titlebar
- 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)
- )
- -- Widgets that are aligned to the left
- local left_layout = wibox.layout.fixed.horizontal()
- left_layout:add(awful.titlebar.widget.iconwidget(c))
- left_layout:buttons(buttons)
- -- Widgets that are aligned to the right
- 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))
- -- The title goes in the middle
- 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)
- -- Now bring it all together
- local layout = wibox.layout.align.horizontal()
- layout:set_left(left_layout)
- layout:set_right(right_layout)
- layout:set_middle(middle_layout)
- awful.titlebar(c):set_widget(layout)
- end
- end)
- -- Enable sloppy focus
- client.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)
- client.connect_signal("focus", function(c) -- Jump to focused client
- c.border_color = beautiful.border_focus
- awful.client.jumpto(c)
- end)
- client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement