From ab1346c7a8d0fefca62d57fb9aba2d042af793a1 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 12 Sep 2012 23:15:44 +0200 Subject: Add awesome config --- .config/awesome/rc.lua | 410 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 410 insertions(+) create mode 100644 .config/awesome/rc.lua (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua new file mode 100644 index 0000000..674e5c0 --- /dev/null +++ b/.config/awesome/rc.lua @@ -0,0 +1,410 @@ +-- Standard awesome library +require("awful") +require("awful.autofocus") +require("awful.rules") +-- Theme handling library +require("beautiful") +-- Notification library +require("naughty") +require("bowl") +require("keychain") + +-- {{{ Error handling +-- Check if awesome encountered an error during startup and fell back to +-- another config (This code will only ever execute for the fallback config) +if awesome.startup_errors then + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) +end + +-- Handle runtime errors after startup +do + local in_error = false + awesome.add_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 +-- }}} + +-- {{{ Variable definitions +-- Themes define colours, icons, and wallpapers +beautiful.init("/usr/share/awesome/themes/default/theme.lua") + +bowl.init({ use_timers = true, timeout = 1 }) +bowl.default_setup() + +-- This is used later as the default terminal and editor to run. +terminal = "urxvt" +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.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, + awful.layout.suit.floating +} +-- }}} + +-- {{{ Tags +-- Define a tag table which hold all screen tags. +tags = {} +for s = 1, screen.count() do + -- Each screen has its own tag table. + tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1]) +end +-- }}} + +-- {{{ Menu +-- Create a laucher widget and a main menu +myawesomemenu = { + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { "quit", awesome.quit } +} + +mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal } + } + }) + +mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), + menu = mymainmenu }) +-- }}} + +-- {{{ Wibox +-- Create a textclock widget +mytextclock = awful.widget.textclock({ align = "right" }) + +-- 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 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))) + -- 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 + mywibox[s] = awful.wibox({ position = "top", screen = s }) + -- Add widgets to the wibox - order matters + mywibox[s].widgets = { + { + mylauncher, + mytaglist[s], + mypromptbox[s], + layout = awful.widget.layout.horizontal.leftright + }, + mylayoutbox[s], + mytextclock, + s == 1 and mysystray or nil, + mytasklist[s], + 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) +)) +-- }}} + +function keyhandler (mod, key, event) + if event == "release" then return true end + + if key == "o" then + awful.client.focus.byidx(1) + if client.focus then client.focus:raise() end + elseif key == "O" then + awful.screen.focus_relative(1) + elseif key == "f" then + awful.client.focus.bydirection("right") + if client.focus then client.focus:raise() end + elseif key == "b" then + awful.client.focus.bydirection("left") + if client.focus then client.focus:raise() end + elseif key == "n" then + awful.client.focus.bydirection("down") + if client.focus then client.focus:raise() end + elseif key == "p" then + awful.client.focus.bydirection("up") + if client.focus then client.focus:raise() end + else + naughty.notify({text=key}) + end + + return false +end + +-- {{{ Key bindings +local bind = keychain +local sub = keychain.sub +globalkeys = awful.util.table.join( + bind({ "Control", }, "z", + { sub({ }, "o", + function () + awful.client.focus.byidx(1) + if client.focus then client.focus:raise() end + end), + sub({ "Shift", }, "o", + function () + awful.screen.focus_relative(1) + end), + sub({ }, "f", + function () + awful.client.focus.bydirection("right") + if client.focus then client.focus:raise() end + end) }), + 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, }, "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, }, "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), + + -- 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) +) + +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) +) + +-- 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) +-- }}} + +-- {{{ 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 } }, + -- 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) +-- }}} -- cgit v1.2.3-54-g00ecf From f7f8460b8334a8c3c820e6e6095471b2b723f22b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 12 Sep 2012 23:26:52 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 674e5c0..d61195d 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -223,6 +223,11 @@ function keyhandler (mod, key, event) return false end +function focus_raise(direction) + awful.client.focus.bydirection(direction) + if client.focus then client.focus:raise() end +end + -- {{{ Key bindings local bind = keychain local sub = keychain.sub @@ -234,14 +239,11 @@ globalkeys = awful.util.table.join( if client.focus then client.focus:raise() end end), sub({ "Shift", }, "o", - function () - awful.screen.focus_relative(1) - end), - sub({ }, "f", - function () - awful.client.focus.bydirection("right") - if client.focus then client.focus:raise() end - end) }), + function () awful.screen.focus_relative(1) end), + sub({ }, "f", function () focus_raise("right") end), + sub({ }, "b", function () focus_raise("left") end), + sub({ }, "n", function () focus_raise("down") end), + sub({ }, "p", function () focus_raise("up") end)}), awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), awful.key({ modkey, }, "Escape", awful.tag.history.restore), -- cgit v1.2.3-54-g00ecf From af2ad2ac32bdac686dfa149965381f3db966281c Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 12 Sep 2012 23:27:44 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index d61195d..b89934a 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -196,33 +196,6 @@ root.buttons(awful.util.table.join( )) -- }}} -function keyhandler (mod, key, event) - if event == "release" then return true end - - if key == "o" then - awful.client.focus.byidx(1) - if client.focus then client.focus:raise() end - elseif key == "O" then - awful.screen.focus_relative(1) - elseif key == "f" then - awful.client.focus.bydirection("right") - if client.focus then client.focus:raise() end - elseif key == "b" then - awful.client.focus.bydirection("left") - if client.focus then client.focus:raise() end - elseif key == "n" then - awful.client.focus.bydirection("down") - if client.focus then client.focus:raise() end - elseif key == "p" then - awful.client.focus.bydirection("up") - if client.focus then client.focus:raise() end - else - naughty.notify({text=key}) - end - - return false -end - function focus_raise(direction) awful.client.focus.bydirection(direction) if client.focus then client.focus:raise() end -- cgit v1.2.3-54-g00ecf From b08f6026edcc8c7918aa50ad3e830593c055538b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 12 Sep 2012 23:32:08 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index b89934a..12ddae7 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -213,10 +213,12 @@ globalkeys = awful.util.table.join( end), sub({ "Shift", }, "o", function () awful.screen.focus_relative(1) end), + sub({ "Shift", }, "1", + function () mypromptbox[mouse.screen]:run() end), sub({ }, "f", function () focus_raise("right") end), sub({ }, "b", function () focus_raise("left") end), sub({ }, "n", function () focus_raise("down") end), - sub({ }, "p", function () focus_raise("up") end)}), + sub({ }, "p", function () focus_raise("up") end) }), awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), awful.key({ modkey, }, "Escape", awful.tag.history.restore), -- cgit v1.2.3-54-g00ecf From 0228c95a0b433216382334194852fb0e70da82ff Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 13 Sep 2012 01:57:14 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 99 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 11 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 12ddae7..099d3c5 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -9,6 +9,8 @@ require("naughty") require("bowl") require("keychain") +oni = { } -- Container for custom functions. + -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) @@ -34,6 +36,71 @@ do end -- }}} +function oni.focus_raise(direction) + awful.client.focus.bydirection(direction) + if client.focus then client.focus:raise() end +end + +-- Returns true if all pairs in table1 are present in table2 +function match(table1, table2) + for k, v in pairs(table1) do + if table[k] ~= v and not table2[k]:find(v) then + return false + end + end + + return true +end + +--- Spawns cmd if no client can be found matching properties +-- If such a client can be found, pop to first tag where it is +-- visible, and give it focus +function oni.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 n == 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 table.getn(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 + -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers beautiful.init("/usr/share/awesome/themes/default/theme.lua") @@ -196,11 +263,6 @@ root.buttons(awful.util.table.join( )) -- }}} -function focus_raise(direction) - awful.client.focus.bydirection(direction) - if client.focus then client.focus:raise() end -end - -- {{{ Key bindings local bind = keychain local sub = keychain.sub @@ -215,10 +277,19 @@ globalkeys = awful.util.table.join( function () awful.screen.focus_relative(1) end), sub({ "Shift", }, "1", function () mypromptbox[mouse.screen]:run() end), - sub({ }, "f", function () focus_raise("right") end), - sub({ }, "b", function () focus_raise("left") end), - sub({ }, "n", function () focus_raise("down") end), - sub({ }, "p", function () focus_raise("up") end) }), + sub({ }, "f", function () oni.focus_raise("right") end), + sub({ }, "b", function () oni.focus_raise("left") end), + sub({ }, "n", function () oni.focus_raise("down") end), + sub({ }, "p", function () oni.focus_raise("up") end), + sub({ }, "e", + function () oni.run_or_raise("emacsclient -c -a emacs", + { class = "Emacs" }) end), + sub({ }, "c", + function () oni.run_or_raise("urxvt", + { class = "URxvt" }) end), + sub({ }, "w", + function () oni.run_or_raise("conkeror", + { class = "Conkeror" }) end) }), awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), awful.key({ modkey, }, "Escape", awful.tag.history.restore), @@ -349,9 +420,15 @@ awful.rules.rules = { properties = { floating = true } }, { rule = { class = "gimp" }, properties = { floating = true } }, + { rule = { class = "Emacs" }, + properties = { tag = tags[1][1] } }, -- Set Firefox to always map on tags number 2 of screen 1. - -- { rule = { class = "Firefox" }, - -- properties = { tag = tags[1][2] } }, + { rule = { class = "Firefox" }, + properties = { tag = tags[2][1] } }, + { rule = { class = "Conkeror" }, + properties = { tag = tags[2][1] } }, + { rule = { class = "URxvt" }, + properties = { tag = tags[2][1] } }, } -- }}} -- cgit v1.2.3-54-g00ecf From ddff03f5ecf8a06c0e57feef2f03103fa0c1b467 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 13 Sep 2012 10:32:33 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 099d3c5..b602eb7 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -1,15 +1,15 @@ --- Standard awesome library require("awful") require("awful.autofocus") require("awful.rules") --- Theme handling library require("beautiful") --- Notification library -require("naughty") require("bowl") require("keychain") +require("lfs") +require("naughty") + +oni = { } -- Container for custom functions. -oni = { } -- Container for custom functions. +oni.maildirfmt = "/home/slash/documents/mail/%s/inbox/new/" -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to @@ -41,8 +41,21 @@ function oni.focus_raise(direction) if client.focus then client.focus:raise() end end +function oni.mailcount(account) + local i = 0 + local dir = string.format(oni.maildirfmt, account) + + for file in lfs.dir(dir) do + if file ~= "." and file ~= ".." then + i = i + 1 + end + end + + return i +end + -- Returns true if all pairs in table1 are present in table2 -function match(table1, table2) +function oni.match(table1, table2) for k, v in pairs(table1) do if table[k] ~= v and not table2[k]:find(v) then return false @@ -64,7 +77,7 @@ function oni.run_or_raise(cmd, properties) for i, c in pairs(clients) do -- make an array of matched clients - if match(properties, c) then + if oni.match(properties, c) then n = n + 1 matched_clients[n] = c @@ -108,6 +121,11 @@ beautiful.init("/usr/share/awesome/themes/default/theme.lua") bowl.init({ use_timers = true, timeout = 1 }) bowl.default_setup() +keychain.init({ escapes = { + keychain.keystroke ({ }, "Escape"), + keychain.keystroke ({ "Control", }, "g") +} }) + -- This is used later as the default terminal and editor to run. terminal = "urxvt" editor = os.getenv("EDITOR") or "nano" -- cgit v1.2.3-54-g00ecf From adf8e13bb0e722ca6e98d85182b41a47a6e26621 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 13 Sep 2012 10:57:37 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index b602eb7..b544d93 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -54,6 +54,15 @@ function oni.mailcount(account) return i end +function oni.mailcount_text() + return string.format("ryu: %d aet: %d gmail: %d 9f: %d", + oni.mailcount("ryuslash.org"), + oni.mailcount("aethon"), + oni.mailcount("gmail"), + oni.mailcount("ninthfloor")) +end + + -- Returns true if all pairs in table1 are present in table2 function oni.match(table1, table2) for k, v in pairs(table1) do @@ -190,6 +199,16 @@ mytextclock = awful.widget.textclock({ align = "right" }) -- Create a systray mysystray = widget({ type = "systray" }) +-- Create a mailbox widget +mymailbox = widget({ type = "textbox" }) +mymailbox.text = oni.mailcount_text() +mymailboxtimer = timer({ timeout = 60 }) +mymailboxtimer:add_signal("timeout", + function () + mymailbox.text = oni.mailcount_text() + end) +mymailboxtimer:start() + -- Create a wibox for each screen and add it mywibox = {} mypromptbox = {} @@ -267,6 +286,7 @@ for s = 1, screen.count() do mylayoutbox[s], mytextclock, s == 1 and mysystray or nil, + s == 1 and mymailbox or nil, mytasklist[s], layout = awful.widget.layout.horizontal.rightleft } -- cgit v1.2.3-54-g00ecf From 802607545beea16c5db8fdf4d2947e32aa04d3a6 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 13 Sep 2012 17:14:39 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index b544d93..03067e2 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -11,7 +11,7 @@ oni = { } -- Container for custom functions. oni.maildirfmt = "/home/slash/documents/mail/%s/inbox/new/" --- {{{ Error handling +--- Error handling -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then @@ -34,8 +34,8 @@ do in_error = false end) end --- }}} +--- Functions function oni.focus_raise(direction) awful.client.focus.bydirection(direction) if client.focus then client.focus:raise() end @@ -118,6 +118,7 @@ function oni.run_or_raise(cmd, properties) -- And then focus the client client.focus = c c:raise() + awful.screen.focus(c.screen) return end awful.util.spawn(cmd) -- cgit v1.2.3-54-g00ecf From d5836762a01d8c75460b6c58aaa16c4ad15e60f4 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 14 Sep 2012 09:55:58 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 03067e2..99d6751 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -126,7 +126,7 @@ end -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers -beautiful.init("/usr/share/awesome/themes/default/theme.lua") +beautiful.init("/home/slash/.config/awesome/themes/custom/theme.lua") bowl.init({ use_timers = true, timeout = 1 }) bowl.default_setup() @@ -329,6 +329,8 @@ globalkeys = awful.util.table.join( sub({ }, "w", function () oni.run_or_raise("conkeror", { class = "Conkeror" }) end) }), + awful.key({ "Control", "Mod1" }, "l", + function () awful.util.spawn("i3lock -c 000000") end), awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), awful.key({ modkey, }, "Escape", awful.tag.history.restore), -- cgit v1.2.3-54-g00ecf From a5689e945dd73839f587dadbf373e4621949f6bc Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 14 Sep 2012 10:31:10 +0200 Subject: .config/awesome/ --- .config/awesome/rc.lua | 2 +- .config/awesome/themes/custom/README | 3 ++ .config/awesome/themes/custom/theme.lua | 96 +++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .config/awesome/themes/custom/README create mode 100644 .config/awesome/themes/custom/theme.lua (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 99d6751..47de684 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -55,7 +55,7 @@ function oni.mailcount(account) end function oni.mailcount_text() - return string.format("ryu: %d aet: %d gmail: %d 9f: %d", + return string.format(" ryu: %d aet: %d gmail: %d 9f: %d --", oni.mailcount("ryuslash.org"), oni.mailcount("aethon"), oni.mailcount("gmail"), diff --git a/.config/awesome/themes/custom/README b/.config/awesome/themes/custom/README new file mode 100644 index 0000000..1ddb349 --- /dev/null +++ b/.config/awesome/themes/custom/README @@ -0,0 +1,3 @@ +Background images: + Mikael Eriksson + Licensed under CC-BY-SA-3.0 diff --git a/.config/awesome/themes/custom/theme.lua b/.config/awesome/themes/custom/theme.lua new file mode 100644 index 0000000..3cdb9ca --- /dev/null +++ b/.config/awesome/themes/custom/theme.lua @@ -0,0 +1,96 @@ +--------------------------- +-- Default awesome theme -- +--------------------------- + +theme = {} + +theme.font = "osaka_unicode 10" + +theme.bg_normal = "#222222" +theme.bg_focus = "#535d6c" +theme.bg_urgent = "#ff0000" +theme.bg_minimize = "#444444" + +theme.fg_normal = "#aaaaaa" +theme.fg_focus = "#ffffff" +theme.fg_urgent = "#ffffff" +theme.fg_minimize = "#ffffff" + +theme.border_width = "1" +theme.border_normal = "#000000" +theme.border_focus = "#535d6c" +theme.border_marked = "#91231c" + +-- There are other variable sets +-- overriding the default one when +-- defined, the sets are: +-- [taglist|tasklist]_[bg|fg]_[focus|urgent] +-- titlebar_[bg|fg]_[normal|focus] +-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color] +-- mouse_finder_[color|timeout|animate_timeout|radius|factor] +-- Example: +--theme.taglist_bg_focus = "#ff0000" + +-- Display the taglist squares +theme.taglist_squares_sel = "/home/slash/.config/awesome/themes/custom/taglist/squarefw.png" +theme.taglist_squares_unsel = "/home/slash/.config/awesome/themes/custom/taglist/squarew.png" + +theme.tasklist_floating_icon = "/home/slash/.config/awesome/themes/custom/tasklist/floatingw.png" + +-- Variables set for theming the menu: +-- menu_[bg|fg]_[normal|focus] +-- menu_[border_color|border_width] +theme.menu_submenu_icon = "/home/slash/.config/awesome/themes/custom/submenu.png" +theme.menu_height = "15" +theme.menu_width = "100" + +-- You can add as many variables as +-- you wish and access them by using +-- beautiful.variable in your rc.lua +--theme.bg_widget = "#cc0000" + +-- Define the image to load +theme.titlebar_close_button_normal = "/home/slash/.config/awesome/themes/custom/titlebar/close_normal.png" +theme.titlebar_close_button_focus = "/home/slash/.config/awesome/themes/custom/titlebar/close_focus.png" + +theme.titlebar_ontop_button_normal_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/ontop_normal_inactive.png" +theme.titlebar_ontop_button_focus_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/ontop_focus_inactive.png" +theme.titlebar_ontop_button_normal_active = "/home/slash/.config/awesome/themes/custom/titlebar/ontop_normal_active.png" +theme.titlebar_ontop_button_focus_active = "/home/slash/.config/awesome/themes/custom/titlebar/ontop_focus_active.png" + +theme.titlebar_sticky_button_normal_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/sticky_normal_inactive.png" +theme.titlebar_sticky_button_focus_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/sticky_focus_inactive.png" +theme.titlebar_sticky_button_normal_active = "/home/slash/.config/awesome/themes/custom/titlebar/sticky_normal_active.png" +theme.titlebar_sticky_button_focus_active = "/home/slash/.config/awesome/themes/custom/titlebar/sticky_focus_active.png" + +theme.titlebar_floating_button_normal_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/floating_normal_inactive.png" +theme.titlebar_floating_button_focus_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/floating_focus_inactive.png" +theme.titlebar_floating_button_normal_active = "/home/slash/.config/awesome/themes/custom/titlebar/floating_normal_active.png" +theme.titlebar_floating_button_focus_active = "/home/slash/.config/awesome/themes/custom/titlebar/floating_focus_active.png" + +theme.titlebar_maximized_button_normal_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/maximized_normal_inactive.png" +theme.titlebar_maximized_button_focus_inactive = "/home/slash/.config/awesome/themes/custom/titlebar/maximized_focus_inactive.png" +theme.titlebar_maximized_button_normal_active = "/home/slash/.config/awesome/themes/custom/titlebar/maximized_normal_active.png" +theme.titlebar_maximized_button_focus_active = "/home/slash/.config/awesome/themes/custom/titlebar/maximized_focus_active.png" + +-- You can use your own command to set your wallpaper +theme.wallpaper_cmd = { "awsetbg -u hsetroot /home/slash/pictures/wallpapers/3600x1080/wallpaper-1085607.jpg" } + +-- You can use your own layout icons like this: +theme.layout_fairh = "/home/slash/.config/awesome/themes/custom/layouts/fairhw.png" +theme.layout_fairv = "/home/slash/.config/awesome/themes/custom/layouts/fairvw.png" +theme.layout_floating = "/home/slash/.config/awesome/themes/custom/layouts/floatingw.png" +theme.layout_magnifier = "/home/slash/.config/awesome/themes/custom/layouts/magnifierw.png" +theme.layout_max = "/home/slash/.config/awesome/themes/custom/layouts/maxw.png" +theme.layout_fullscreen = "/home/slash/.config/awesome/themes/custom/layouts/fullscreenw.png" +theme.layout_tilebottom = "/home/slash/.config/awesome/themes/custom/layouts/tilebottomw.png" +theme.layout_tileleft = "/home/slash/.config/awesome/themes/custom/layouts/tileleftw.png" +theme.layout_tile = "/home/slash/.config/awesome/themes/custom/layouts/tilew.png" +theme.layout_tiletop = "/home/slash/.config/awesome/themes/custom/layouts/tiletopw.png" +theme.layout_spiral = "/home/slash/.config/awesome/themes/custom/layouts/spiralw.png" +theme.layout_dwindle = "/home/slash/.config/awesome/themes/custom/layouts/dwindlew.png" + +theme.awesome_icon = "/usr/share/awesome/icons/awesome16.png" + +return theme +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 -- cgit v1.2.3-54-g00ecf From ab024745fa51b03e3cc4fff01d0c0e6203174f3a Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sat, 15 Sep 2012 02:04:23 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 2 -- 1 file changed, 2 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 47de684..0cc96ae 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -157,8 +157,6 @@ layouts = 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, -- cgit v1.2.3-54-g00ecf From bbc17210a1d3b0c69c36207891d9fb18fd8759f9 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sat, 15 Sep 2012 14:28:45 +0200 Subject: .config/awesome/rc.lua --- .config/awesome/rc.lua | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to '.config/awesome/rc.lua') diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 0cc96ae..e3d4548 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -62,6 +62,22 @@ function oni.mailcount_text() oni.mailcount("ninthfloor")) end +function oni.mailcount_widgets(label, account, name) + widgets = {} + widgets.label = widget({ type = "textbox" }) + widgets.label.text = string.format(" %s: ", label) + widgets.count = widget({ type = "textbox" }) + widgets.count.text = string.format(" %d ", oni.mailcount(account)) + widgets.count.bg = beautiful.bg_focus + widgets.count:buttons( + awful.util.table.join( + awful.button({ }, 1, + function (c) + awful.util.spawn("emacsclient -e '(oni:view-mail \"" .. name .. "\")'") + end))) + + return widgets +end -- Returns true if all pairs in table1 are present in table2 function oni.match(table1, table2) @@ -199,13 +215,20 @@ mytextclock = awful.widget.textclock({ align = "right" }) mysystray = widget({ type = "systray" }) -- Create a mailbox widget -mymailbox = widget({ type = "textbox" }) -mymailbox.text = oni.mailcount_text() +myryumailbox = oni.mailcount_widgets("ryu", "ryuslash.org", "ryuslash") +myaethonmailbox = oni.mailcount_widgets("aet", "aethon", "aethon") +mygmailmailbox = oni.mailcount_widgets("gmail", "gmail", "gmail") +my9fmailbox = oni.mailcount_widgets("9f", "ninthfloor", "ninthfloor") + mymailboxtimer = timer({ timeout = 60 }) -mymailboxtimer:add_signal("timeout", - function () - mymailbox.text = oni.mailcount_text() - end) +mymailboxtimer:add_signal( + "timeout", + function () + myryumailbox.count.text = string.format(" %d ", oni.mailcount("ryuslash.org")) + myaethonmailbox.count.text = string.format(" %d ", oni.mailcount("aethon")) + mygmailmailbox.count.text = string.format(" %d ", oni.mailcount("gmail")) + my9fmailbox.count.text = string.format(" %d ", oni.mailcount("ninthfloor")) + end) mymailboxtimer:start() -- Create a wibox for each screen and add it @@ -285,7 +308,14 @@ for s = 1, screen.count() do mylayoutbox[s], mytextclock, s == 1 and mysystray or nil, - s == 1 and mymailbox or nil, + s == 1 and my9fmailbox.count or nil, + s == 1 and my9fmailbox.label or nil, + s == 1 and mygmailmailbox.count or nil, + s == 1 and mygmailmailbox.label or nil, + s == 1 and myaethonmailbox.count or nil, + s == 1 and myaethonmailbox.label or nil, + s == 1 and myryumailbox.count or nil, + s == 1 and myryumailbox.label or nil, mytasklist[s], layout = awful.widget.layout.horizontal.rightleft } -- cgit v1.2.3-54-g00ecf