-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- Run or Raise
require("aweror")
-- Scratchpad
require("scratch")
-- Widgets!
require("vicious")
-- Dynamic Tagging Tool
require("shifty")
-- Load Debian menu entries
require("debian.menu")
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/home/case/.config/awesome/themes/dinosaur/theme.lua")
-- This is used later as the default terminal and editor to run.
terminal = "terminator"
editor = os.getenv("EDITOR") or "nano"
editor_cmd = terminal .. " -e " .. editor
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.floating, --1
awful.layout.suit.tile, --2
awful.layout.suit.tile.left, --3
awful.layout.suit.tile.bottom, --4
awful.layout.suit.tile.top, --5
awful.layout.suit.fair, --6
awful.layout.suit.fair.horizontal, --7
awful.layout.suit.spiral, --8
awful.layout.suit.spiral.dwindle, --9
awful.layout.suit.max, --10
awful.layout.suit.max.fullscreen, --11
awful.layout.suit.magnifier --12
}
-- }}}
-- {{{ Shifty config
-- tag settings
shifty.config.tags = {
["home"] = { init = true, position = 1, exclusive = false, mwfact = 0.50, },
["www"] = { position = 2, exclusive = false, layout = awful.layout.suit.floating, },
["gimp"] = { layout = "float" },
["word"] = { layout = awful.layout.suit.fair },
}
-- client settings
-- order here matters, early rules will be applied first
shifty.config.apps = {
{ match = { "Google-chrome", "jumanji", "uzbl%", "midori" } , tag = "www" } ,
{ match = { "terminator"} , honorsizehints = false, slave = true, tag = "term" } ,
{ match = { "thunar" }, slave = true } ,
{ match = { "gimp" }, tag = "gimp" },
{ match = { "abiword", "libreoffice" }, tag = "word" },
--[[{ match = { "" }, buttons = {
button({ }, 1, function (c) client.focus = c; c:raise() end),
button({ modkey }, 1, function (c) awful.mouse.client.move() end),
button({ modkey }, 3, awful.mouse.client.resize ), }, },--]]
}
-- tag defaults
shifty.config.defaults = {
layout = awful.layout.suit.tile,
ncol = 1,
mwfact = 0.50,
floatBars=true,
}
shifty.init()
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "restart", awesome.restart },
{ "logout", awesome.quit }
}
-- {{{ Build the individual app lists first
app_tools = {
{ "search", "catfish" },
{ "archive", "file-roller" },
{ "text", "gedit" },
{ "term", "terminator" },
{ "file", "thunar" },
{ '<span color="red">file</span>', "gksudo thunar" },
{ "calc", "gcalctool" } }
app_web = {
{ "midori", "midori" },
{ "chrome", "google-chrome" },
{ "jumanji", "jumanji" },
{ "uzbl", "uzbl-tabbed" },
{ "gFTP", "gftp" },
{ "torrent", "transmission" },
{ "irc", "xchat" },
{ "chat", "gajim" },
{ "heybuddy", "heybuddy" } }
app_img = {
{ "gimp", "gimp" },
{ "view", "viewnior" },
{ "color", "gcolor2" } }
app_media = {
{ "vlc", "vlc"},
{ "decibel", "decibel-audio-player" },
{ "pithos", "pithos" },
{ "pogo", "pogo" },
{ "rip", "asunder" },
{ "mix", "xfce4-mixer" } }
app_work = {
{ "abiword", "abiword" },
{ "gnumeric", "gnumeric" },
{ "gummi", "gummi" },
{ "libreoffice", "libreoffice" } }
apps_menu = {
{ "tools", app_tools },
{ "web", app_web },
{ "img", app_img },
{ "media", app_media },
{ "work", app_work } }
--same thing with settings
set_term = {
{ "man", 'terminator --command="man terminator"' },
{ "config", 'gedit ~/.config/terminator/config' } }
set_display = {
{ "grandr", "grandr" },
{ "xrandr", "xrandr" },
{ "man xrandr", 'terminator --command="man xrandr"' } }
set_system = {
{ "printing", "gksudo system-config-printer" },
{ "gparted", "gksudo gparted" },
{ "gdm", "gksudo gdmsetup" },
{ "synaptic", "gksudo synaptic" } }
settings_menu = {
{ "term", set_term },
{ "display", set_display },
{ "defaults", 'terminator --command="sudo update-alternatives --all"' },
{ "gtk", "lxappearance" },
{ "screensaver", "xscreensaver-demo" },
{ "system", set_system } }
--and the end stuff
screenshots = {
{ "Now", "scrot '%Y-%m-%d--%s_$wx$h_scrot.png' -e 'mv $f /home/case/images/screenshots/$f'" },
{ "Wait 5s", "scrot -d 5 '%Y-%m-%d--%s_$wx$h_scrot.png' -e 'mv $f /home/case/images/screenshots/$f'" } }
help_menu = {
{ "awesome wiki", "midori https://awesome.naquadah.org/wiki/Main_Page" } }
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "web", "midori" },
{ "text", "gedit" },
{ "word", "abiword" },
{ "zim", "zim" },
{ "file", "thunar" },
{ "apps", apps_menu },
{ "settings", settings_menu },
{ "screenshot", screenshots },
{ "help", help_menu }
}
})
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
menu = mymainmenu })
-- }}}
-- {{{ Wibox
-- {{{ for volume widget
volumecfg = {}
volumecfg.cardid = 0
volumecfg.channel = "Master"
volumecfg.widget = widget({ type = "textbox", name = "volumecfg.widget", align = "right" })
-- command must start with a space!
volumecfg.mixercommand = function (command)
local fd = io.popen("amixer -c " .. volumecfg.cardid .. command)
local status = fd:read("*all")
fd:close()
local volume = string.match(status, "(%d?%d?%d)%%")
volume = string.format("% 3d", volume)
status = string.match(status, "%[(o[^%]]*)%]")
if string.find(status, "on", 1, true) then
volume = volume .. "%"
else
volume = " -- "
end
if (volume == " 100%") then
volume = "100%"
end
volumecfg.widget.text = volume
end
volumecfg.update = function ()
volumecfg.mixercommand(" sget " .. volumecfg.channel)
end
volumecfg.up = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 5%+")
end
volumecfg.down = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " 5%-")
end
volumecfg.toggle = function ()
volumecfg.mixercommand(" sset " .. volumecfg.channel .. " toggle")
end
volumecfg.widget:buttons(awful.util.table.join(
awful.button({ }, 4, function () volumecfg.up() end),
awful.button({ }, 5, function () volumecfg.down() end),
awful.button({ }, 1, function () volumecfg.toggle() end)))
volumecfg.update()
-- }}}
-- Reusable separators
separator = widget({ type = "imagebox" })
separator.image = image(beautiful.widget_sep)
deadspace = widget({ type = "imagebox" })
deadspace.image = image(beautiful.widget_dead)
--deadspace = widget({ type = "textbox" })
-- Icons
volicon = widget({ type = "imagebox" })
volicon.image = image(beautiful.widget_vol)
volicon:buttons(awful.util.table.join(
awful.button({ }, 4, function () volumecfg.up() end),
awful.button({ }, 5, function () volumecfg.down() end),
awful.button({ }, 1, function () volumecfg.toggle() end)))
-- {{{ Vicious Widgets
--gmail widget
gmailicon = widget({ type = "imagebox" })
gmailicon.image = image(beautiful.widget_gmail)
gmailicon_none = widget({ type = "imagebox" })
gmailicon_none.image = image(beautiful.widget_gmail_none)
gmailWidget = widget({type = "textbox" })
vicious.register(gmailWidget, vicious.widgets.gmail, " ${count}", 30) --[[
function (widget, args)
if args["{count}"] == 0 then return nil
else return {separator, ' ' .. args["{count}"], gmailicon} end end, 30)--]]
--battery widget
baticon = widget({type = "imagebox" })
baticon.image = image(beautiful.widget_bat)
baticon:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.util.spawn("xfce4-power-manager-settings") end)))
batWidget = widget({type = "textbox" })
vicious.register(batWidget, vicious.widgets.bat, " $2$1", 30, "BAT1")
batWidget:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.util.spawn("xfce4-power-manager-settings") end)))
-- }}}
-- Create a textclock widget
mytextclock = awful.widget.textclock({ align = "right" }, '<span color="white">%l:%M|%a %e</span>')
-- Create a systray
mysystray = widget({ type = "systray" })
-- 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),
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=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, prompt = '<span color="red">></span>', })
-- 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)
-- Create the wibox
widgetz = {
s ==1 and mysystray or nil,
mypromptbox[s],
{
deadspace, volumecfg.widget, volicon,
separator, batWidget, baticon,
separator, gmailWidget, gmailicon,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace, deadspace, deadspace, deadspace, deadspace,
deadspace,
mytextclock,
layout = awful.widget.layout.horizontal.rightleft
},
layout = awful.widget.layout.horizontal.leftright
}
mywibox[s] = awful.wibox({ position = "top", height = "24", screen = s })
-- Add widgets to the wibox - order matters
mywibox[s].widgets = {
--[[ { ------------------------------------------------------WIBOX-------
-- mylauncher, --traditional version
mytaglist[s],
mylayoutbox[s],
mypromptbox[s], separator,
layout = awful.widget.layout.horizontal.leftright
},
deadspace, mytextclock,
separator, s == 1 and mysystray or nil,
separator, volumecfg.widget, volicon,
separator, batWidget, baticon,
separator, gmailWidget, gmailicon,
separator, mytasklist[s],
layout = awful.widget.layout.horizontal.rightleft --]]
---[[ --crazy version!
layout = awful.widget.layout.vertical.flex,
widgetz,
{
mylauncher, deadspace, mylayoutbox[s],
mytaglist[s], separator,
mytasklist[s], separator,
layout = awful.widget.layout.horizontal.leftright,
} --]]
}
end
shifty.taglist = mytaglist
-- }}}
-- {{{ 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, "Shift" }, "Left", shifty.shift_prev ),
awful.key({ modkey, "Shift" }, "Right", shifty.shift_next ),
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
awful.key({ modkey, }, "t", function () shifty.add({ rel_index = 1}) end),
awful.key({ modkey, "Shift" }, "t", function () shifty.add({ rel_index = 1, nopopup = true }) end),
awful.key({ modkey, }, "r", shifty.rename),
awful.key({ modkey, }, "w", shifty.del),
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" }, "`", 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, "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, "Control" }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Control", "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
---[[ Volume
awful.key({}, "XF86AudioLowerVolume", function() volumecfg.down() end),
awful.key({}, "XF86AudioRaiseVolume", function() volumecfg.up() end),
awful.key({}, "XF86AudioMute", function () volumecfg.toggle() end),
--]]
-- Brightness (uses my brightness thing)
awful.key({ modkey }, "F5", function() awful.util.spawn_with_shell("brightness -1") end),
awful.key({ modkey }, "F6", function() awful.util.spawn_with_shell("brightness +1") end),
--ScratchPad
awful.key({ modkey, }, "s", function() scratch.pad.toggle() end),
--awful.key({}, "F12", function () scratch.drop("terminator", "top") end),
-- Prompt
awful.key({ modkey, }, "space", function () mypromptbox[mouse.screen]:run() end),
awful.key({ modkey }, "z",
function ()
awful.prompt.run({ prompt = '<span color="green">Lua></span>' },
mypromptbox[mouse.screen].widget,
awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval")
end)
)
-- Client Keybindings
clientkeys = awful.util.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, }, "c", function (c) c:kill() end),
awful.key({ modkey, "Alt" }, "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, "Control" }, "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),
awful.key({ modkey, }, "d", function (c) scratch.pad.set(c, 0.50, 0.50, true) 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
-- }}}
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
-- [ror]
globalkeys = awful.util.table.join(globalkeys, aweror.genkeys(modkey))
root.keys(globalkeys)
shifty.config.globalkeys = globalkeys
shifty.config.clientkeys = clientkeys
-- }}}
-- {{{ Rules
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 = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
{ rule = { class = "zathura" },
properties = { floating = true } },
{ rule = { class = "pidgin" },
properties = { floating = true } },
-- 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
c.opacity = 1
end)
--[[ FOCUS OPACITY
client.add_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
c.opacity = 0.7
end)--]]
-- }}}
-- {{{ Autostart
awful.util.spawn_with_shell("awesome-autostart")
-- }}}
It uses shifty for dynamic tagging, which is great only I can't name a new tag "ad hoc". If anyone knows how to get this to happen, please let me know.