Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Standard awesome library
- require("awful")
- require("awful.autofocus")
- require("awful.rules")
- -- Theme handling library
- require("beautiful")
- -- Notification library
- require("naughty")
- require("shifty")
- require("vicious")
- -- {{{ Variable definitions
- -- Themes define colours, icons, and wallpapers
- beautiful.init(awful.util.getdir("config") .. "/theme/theme.lua")
- -- This is used later as the default terminal and editor to run.
- terminal = "urxvt"
- terminal_fixed = terminal .. " -name urxvt_fixed"
- browser = "thunar"
- web = "x-www-browser"
- mail = "icedove"
- editor = os.getenv("EDITOR") or "vim"
- editor_cmd = terminal .. " -e " .. editor
- -- win
- modkey = "Mod4"
- -- alt
- modkey2 = "Mod1"
- -- }}}
- -- {{{ Table of layouts to cover with awful.layout.inc, order matters.
- layouts =
- {
- awful.layout.suit.max,
- awful.layout.suit.tile.left,
- awful.layout.suit.fair.horizontal,
- awful.layout.suit.tile.bottom,
- awful.layout.suit.magnifier,
- -- awful.layout.suit.tile,
- -- awful.layout.suit.tile.top,
- -- awful.layout.suit.fair,
- -- awful.layout.suit.floating,
- -- awful.layout.suit.spiral,
- -- awful.layout.suit.spiral.dwindle,
- -- awful.layout.suit.max.fullscreen,
- }
- -- }}}
- -- {{{ Shifty configuration
- -- tag settings
- shifty.config.tags = {
- ["1.web"] = { position = 1, spawn = web, nopopup = true, layout = awful.layout.suit.max },
- ["2.gajim"] = { position = 2, spawn = "gajim", nopopup = true, mwfact = 0.24, layout = awful.layout.suit.tile.left, },
- ["3.skype"] = { position = 3, spawn = "skype", nopopup = true, mwfact = 0.24, layout = awful.layout.suit.tile.left, },
- ["4.files"] = { position = 4, spawn = browser, layout = awful.layout.suit.max, },
- ["5.mail"] = { position = 5, spawn = mail, nopopup = true, layout = awful.layout.suit.max, },
- ["6.view"] = { position = 6, layout = awful.layout.suit.mx, },
- ["9.term"] = { position = 9, spawn = terminal_fixed, layout = awful.layout.suit.max, },
- ["gimp"] = { position = 10, mwfact = 0.25, layout = awful.layout.suit.tile, },
- ["qemu"] = { position = 96, layout = awful.layout.suit.max, },
- ["burn"] = { position = 97, layout = awful.layout.suit.fair.horizontal, },
- ["downloads"] = { position = 98, layout = awful.layout.suit.fair.horizontal, },
- ["relax-fm"] = { position = 99, layout = awful.layout.suit.fair.horizontal, },
- }
- 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)
- )
- -- client settings (order here matters, early rules will be applied first)
- shifty.config.apps = {
- { match = { "Supertux" }, honorsizehints = false, slave = true, float = true, intrusive = true, },
- { match = { "URxvt" }, honorsizehints = false, slave = true, float = true, intrusive = true, },
- { match = { "Sonata" }, slave = true, float = true, intrusive = true, },
- { match = { "Firefox","Iceweasel", tag = "1.web" },
- { match = { "Gajim.py" }, slave = true, float = true, tag = "2.gajim" },
- { match = { "roster" }, slave = false, float = false },
- { match = { "messages" }, float = false },
- { match = { "Skype" }, slave = true, float = true, tag = "3.skype" },
- { match = { "Skype.*(Beta)" }, slave = false, float = false, },
- { match = { "Skype.*чат" }, float = false, },
- { match = { "Thunar" }, tag = "4.files" },
- { match = { "Thunderbird","Icedove" }, tag = "5.mail" },
- { match = { "Evince", "Geeqie" }, tag = "6.view" },
- { match = { "MPlayer" }, float = true, tag = "6.view" },
- { match = { "urxvt_fixed" }, float = false, intrusive = false, tag = "9.term" },
- { match = { "Gimp.*" }, slave = true, float = true, tag = "gimp" },
- { match = { "gimp%-toolbox" }, slave = false, float = false, },
- { match = { "gimp%-image%-window" }, float = false, },
- { match = { "Xfburn" }, tag = "burn" },
- { match = { "aria2c" }, float = false, intrusive = false, tag = "downloads" },
- { match = { "" }, buttons = clientbuttons },
- }
- -- tag defaults
- shifty.config.defaults = {
- exclusive = true,
- layout = awful.layout.suit.max,
- mwfact = 0.50,
- ncol = 1,
- persist = false,
- }
- shifty.init()
- --- }}}
- -- {{{ Menu
- -- Create a laucher widget and a main menu
- myawesomemenu = {
- { "manual", terminal .. " -e man awesome" },
- { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
- { "restart", awesome.restart },
- { "quit", awesome.quit }
- }
- mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
- { "open terminal", terminal }
- }
- })
- -- }}}
- -- {{{ Wibox
- colorWidgetFg = "#999999"
- -- Divider
- textDivider = widget({ type = "textbox" })
- textDivider.width = 25
- textDivider.align = "center"
- textDivider.text = '<span color="#666666">::</span>'
- --------------------
- ---- TOP PANEL -----
- --------------------
- -- Systray
- --mysystray = widget({ type = "systray" })
- -- Volume
- textVolume = widget({ type = "textbox" })
- textVolume.bg_image = image(awful.util.getdir("config") .. "/icons/vol.png")
- textVolume.bg_align = "left"
- textVolume.align = "right"
- vicious.cache(vicious.widgets.volume)
- vicious.register(textVolume, vicious.widgets.volume,
- function (widget, args)
- if args[2] == "♫" then
- return ' ' .. string.format("%02d", args[1]) .. '<span color="' .. colorWidgetFg .. '">%</span>'
- else
- return ' <span color="' .. theme.bg_urgent .. '">' .. string.format("%02d", args[1]) .. '%</span>'
- end
- end,
- 5, "PCM")
- textVolume:buttons(awful.util.table.join(
- awful.button({ }, 2,
- function ()
- awful.util.spawn("amixer -q sset PCM toggle")
- vicious.force({ textVolume })
- end
- ),
- awful.button({ }, 4,
- function ()
- awful.util.spawn("amixer -q sset PCM 1%+")
- vicious.force({ textVolume })
- end
- ),
- awful.button({ }, 5,
- function ()
- awful.util.spawn("amixer -q sset PCM 1%-")
- vicious.force({ textVolume })
- end
- )
- ))
- -- Keyboard layout
- textKbLayout = widget ({ type = "textbox" })
- textKbLayout.width = 28
- textKbLayout.bg = theme.bg_normal
- dbus.request_name("session", "ru.gentoo.kbdd")
- dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
- textKbLayout.text = ' <span color="#ffffff">' .. 'Eng' .. '</span>'
- dbus.add_signal("ru.gentoo.kbdd",
- function(...)
- local data = {...}
- local layout = data[2]
- lts = {[0] = "Eng", [1] = "Рус"}
- textKbLayout.text = ' <span color="#ffffff">' .. lts[layout] .. '</span>'
- if layout == 0 then
- textKbLayout.bg = theme.bg_normal
- else
- textKbLayout.bg = theme.bg_focus
- end
- end)
- -- Clock
- textClock = widget({ type = "textbox" })
- local function fnClockUpdate()
- textClock.text = '<span color="' .. colorWidgetFg .. '">' .. awful.util.pread('echo -n $(date +"%d [%a]")') .. '</span>' .. ' ' .. awful.util.pread('echo -n $(date +"%H:%M")') .. ' '
- end
- fnClockUpdate()
- textClock_timer = timer({ timeout = 10})
- textClock_timer:add_signal("timeout", function () fnClockUpdate() end)
- textClock_timer:start()
- --------------------
- --- BOTTOM PANEL ---
- --------------------
- -- MPD
- textMPD = widget({ type = "textbox" })
- textMPD.bg_image = image(awful.util.getdir("config") .. "/icons/phones.png")
- textMPD.bg_align = "left"
- textMPD.align = "left"
- textMPD.width = 500
- vicious.register(textMPD, vicious.widgets.mpd,
- function (widget, args)
- stringMPD = awful.util.escape(awful.util.pread('cat /tmp/mpd-status/state'))
- if args["{state}"] == 'Stop' then
- stringMPD = '<span color="' .. colorWidgetFg .. '">' .. stringMPD .. '</span>'
- elseif args["{state}"] == 'Pause' then
- stringMPD = '<span color="' .. colorWidgetFg .. '">' .. stringMPD .. '</span>'
- end
- return ' ' .. stringMPD
- end, 1)
- textMPD:buttons(awful.util.table.join(
- awful.button({ }, 2,
- function ()
- awful.util.spawn("/usr/bin/mpc -q toggle")
- vicious.force({ textMPD })
- end
- ),
- awful.button({ }, 4,
- function ()
- awful.util.spawn("/usr/bin/mpc -q next")
- vicious.force({ textMPD })
- end
- ),
- awful.button({ }, 5,
- function ()
- awful.util.spawn("/usr/bin/mpc -q prev")
- vicious.force({ textMPD })
- end
- )
- ))
- -- CPU
- textCPU = widget({ type = "textbox" })
- textCPU.bg_image = image(awful.util.getdir("config") .. "/icons/cpu.png")
- textCPU.bg_align = "left"
- textCPU.align = "right"
- vicious.register(textCPU, vicious.widgets.cpu,
- function (widget, args)
- return ' ' .. string.format("%02d", args[1]) .. '<span color="' .. colorWidgetFg .. '">%</span>'
- end,
- 2)
- -- Memory
- textMemory = widget({ type = "textbox" })
- textMemory.bg_image = image(awful.util.getdir("config") .. "/icons/mem.png")
- textMemory.bg_align = "left"
- textMemory.align = "right"
- vicious.register(textMemory, vicious.widgets.mem,
- function (widget, args)
- return ' ' .. string.format("%02d", args[1]) .. '<span color="' .. colorWidgetFg .. '">% [' .. args[2] .. 'M]</span>'
- end,
- 2)
- -- Disk
- textDisk = widget({ type = "textbox" })
- textDisk.bg_image = image(awful.util.getdir("config") .. "/icons/disk.png")
- textDisk.bg_align = "left"
- textDisk.align = "right"
- vicious.register(textDisk, vicious.widgets.fs, ' <span color="' .. colorWidgetFg .. '">root:</span>${/ used_p}<span color="' .. colorWidgetFg .. '">% home:</span>${/home used_p}<span color="' .. colorWidgetFg .. '">% data:</span>${/mnt/data used_p}<span color="' .. colorWidgetFg .. '">%</span>', 5)
- -- Divider
- textEndPanel = widget({ type = "textbox" })
- textEndPanel.width = 2
- -- Create a wibox for each screen and add it
- mywibox_top = {}
- mywibox_bottom = {}
- 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 not c:isvisible() then
- awful.tag.viewonly(c:tags()[1])
- end
- client.focus = c
- c:raise()
- end),
- awful.button({ }, 3, function ()
- if instance then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({ width=400 })
- 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)))
- -- Create a taglist widget
- mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
- -- Create a tasklist widget
- -- mytasklist[s] = awful.widget.tasklist(function(c)
- -- return awful.widget.tasklist.label.currenttags(c, s)
- -- end, mytasklist.buttons)
- mytasklist[s] = awful.widget.tasklist(function(c)
- local text, bg, status_image, icon =
- awful.widget.tasklist.label.currenttags(c, s)
- return nil, nil, nil, c.icon
- end, mytasklist.buttons)
- -- Create the wibox
- mywibox_top[s] = awful.wibox({ position = "top", height = "16", screen = s })
- mywibox_bottom[s] = awful.wibox({ position = "bottom", height = "16", screen = s })
- -- Add widgets to the wibox - order matters
- mywibox_top[s].widgets = {
- {
- mytaglist[s],
- mypromptbox[s],
- layout = awful.widget.layout.horizontal.leftright
- },
- textClock,
- textDivider,
- textKbLayout,
- textDivider,
- textVolume,
- textDivider,
- layout = awful.widget.layout.horizontal.rightleft
- }
- mywibox_bottom[s].widgets = {
- textEndPanel,
- mylayoutbox[s],
- textDivider,
- textDisk,
- textDivider,
- textMemory,
- textDivider,
- textCPU,
- textDivider,
- --s == 1 and mysystray or nil,
- {
- textMPD,
- --textDivider,
- --mytasklist[s],
- layout = awful.widget.layout.horizontal.leftright
- },
- layout = awful.widget.layout.horizontal.rightleft
- }
- 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, }, "w", function () mymainmenu:show({keygrabber=true}) end),
- -- Layout manipulation
- 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, "Shift" }, "Return", function () awful.util.spawn(terminal_fixed) 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),
- -- Prompt
- 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),
- -- scrot
- awful.key({ }, "Print", function () awful.util.spawn('sh -c ~/scripts/scrotrc-png.sh') end),
- awful.key({ "Shift" }, "Print", function () awful.util.spawn('sh -c ~/scripts/scrotrc-jpg.sh') end),
- awful.key({ modkey2, }, "Print", function () awful.util.spawn('sh -c ~/scripts/scrotrc-focused-png.sh') end),
- awful.key({ modkey2, "Shift" }, "Print", function () awful.util.spawn('sh -c ~/scripts/scrotrc-focused-jpg.sh') end),
- -- Shifty
- awful.key({ modkey, "Shift" }, "Left", shifty.shift_prev),
- awful.key({ modkey, "Shift" }, "Right", shifty.shift_next),
- --awful.key({ modkey, }, "t", function() shifty.add({ rel_index = 1 }) end),
- --awful.key({ modkey, "Control" }, "t", function() shifty.add({ rel_index = 1, nopopup = true }) end),
- --awful.key({ modkey, }, "e", shifty.rename),
- awful.key({ modkey, }, "d", shifty.del),
- nil
- )
- 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",
- function (c)
- awful.client.floating.set(c, not awful.client.floating.get(c))
- -- Always on top for floating windows
- c.ontop = not c.ontop
- end),
- 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, "Shift" }, "t", function (c) c.ontop = not c.ontop end),
- awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
- awful.key({ modkey, }, "m",
- function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end)
- )
- -- bindings / global / shifty.getpos
- for i=1, ( shifty.config.maxtags or 9 ) do
- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey }, i,
- function ()
- local t = awful.tag.viewonly(shifty.getpos(i))
- end))
- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Control" }, i,
- function ()
- local t = shifty.getpos(i)
- t.selected = not t.selected
- end))
- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Control", "Shift" }, i,
- function ()
- if client.focus then
- awful.client.toggletag(shifty.getpos(i))
- end
- end))
- -- move clients to other tags
- globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey, "Shift" }, i,
- function ()
- if client.focus then
- local t = shifty.getpos(i)
- awful.client.movetotag(t)
- awful.tag.viewonly(t)
- end
- end))
- end
- -- Set keys
- root.keys(globalkeys)
- shifty.config.globalkeys = globalkeys
- shifty.config.clientkeys = clientkeys
- -- }}}
- -- {{{ 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 })
- -- Always on top for floating windows
- c.ontop = awful.client.floating.get(c)
- -- 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
- --fnKbLayoutUpdate()
- end)
- client.add_signal("unfocus", function(c)
- c.border_color = beautiful.border_normal
- --fnKbLayoutUpdate()
- end)
- awful.util.spawn_with_shell(awful.util.getdir("config") .. "/autorun.sh")
- -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement