Skip to content

Instantly share code, notes, and snippets.

@gulafaran
Created July 7, 2015 04:25
Show Gist options
  • Save gulafaran/848a32c397c92e5227f9 to your computer and use it in GitHub Desktop.
Save gulafaran/848a32c397c92e5227f9 to your computer and use it in GitHub Desktop.
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 menubar = require("menubar")
local vicious = require("vicious")
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
beautiful.init("/home/tom/.config/awesome/theme/theme.lua")
terminal = "termite"
modkey = "Mod4"
local layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
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 = {}
for s = 1, screen.count() do
if s == 1 then
tags[s] = awful.tag({"sys", "dev", "web", "fps", "foo"}, s, {layouts[2], layouts[2], layouts[2], layouts[1], layouts[1]})
elseif s == 2 then
tags[s] = awful.tag({"p2p", "sys", "web", "foo"}, s, {layouts[2], layouts[2], layouts[2], layouts[1]})
elseif s == 3 then
tags[s] = awful.tag({"irc", "sys", "foo"}, s, {layouts[2], layouts[2], layouts[1]})
end
end
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", terminal .. " -e 'vim /home/tom/.config/awesome/rc.lua' " },
{ "reload", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "open terminal", terminal }
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu })
menubar.utils.terminal = terminal
mytextclock = awful.widget.textclock()
cpuwidget = wibox.widget.textbox()
vicious.register(cpuwidget, vicious.widgets.cpu, "CPU: $1% ")
memwidget = wibox.widget.textbox()
vicious.register(memwidget, vicious.widgets.mem, "MEM: $1% ($2MB/$3MB) ", 13)
oswidget = wibox.widget.textbox()
vicious.register(oswidget, vicious.widgets.os, "$1 $2 ")
volwidget = wibox.widget.textbox()
vicious.register(volwidget, vicious.widgets.volume, "VOL: $1% ", 2, "Master")
upwidget = wibox.widget.textbox()
vicious.register(upwidget, vicious.widgets.uptime, "UP: $1d $2h $3m ", 60)
pkwidget = wibox.widget.textbox()
vicious.register(pkwidget, vicious.widgets.pkg, "PKG: $1 ", 400, "Arch C")
mywibox = {}
mywidgetbox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(awful.button({ }, 1, awful.tag.viewonly))
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))
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)
mywibox[s] = awful.wibox({ position = "top", screen = s })
mywidgetbox[s] = awful.wibox({ position = "bottom", screen = s})
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(mytaglist[s])
left_layout:add(mypromptbox[s])
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
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)
local bot_left = wibox.layout.fixed.horizontal()
bot_left:add(oswidget)
bot_left:add(cpuwidget)
bot_left:add(memwidget)
local bot_right = wibox.layout.fixed.horizontal()
bot_right:add(pkwidget)
bot_right:add(volwidget)
bot_right:add(upwidget)
bot_right:add(mytextclock)
local bot_layout = wibox.layout.align.horizontal()
bot_layout:set_left(bot_left)
bot_layout:set_right(bot_right)
mywidgetbox[s]:set_widget(bot_layout)
end
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, "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),
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "F9", awesome.restart),
awful.key({ modkey, "Control" }, "F10", 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),
awful.key({ modkey }, "p", function() menubar.show() end),
awful.key({ modkey }, "F1", function() os.execute("ponymix toggle") end),
awful.key({ modkey }, "F2", function() os.execute("ponymix increase 1") end),
awful.key({ modkey }, "F3", function() os.execute("ponymix decrease 1") end),
awful.key({ modkey }, "F5", function() os.execute("spotifycli --play") end),
awful.key({ modkey }, "F6", function() os.execute("spotifycli --stop") end),
awful.key({ modkey }, "F7", function() os.execute("spotifycli --next") end),
awful.key({ modkey }, "F8", function() os.execute("spotifycli --previous") 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, }, "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)
)
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
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,
raise = true,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
{ rule = { class = "dota2" },
properties = { floating = true } },
{ rule = { class = "dota.sh" },
properties = { floating = true } },
}
client.connect_signal("manage", function (c, startup)
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifie and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
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 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 left_layout = wibox.layout.fixed.horizontal()
left_layout:add(awful.titlebar.widget.iconwidget(c))
left_layout:buttons(buttons)
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_left(left_layout)
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c):set_widget(layout)
end
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment