summaryrefslogtreecommitdiffstats
path: root/.config/awesome
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-10-07 15:23:23 +0200
committerGravatar Tom Willemsen2012-10-07 15:23:23 +0200
commit52abe4f88168002420813e20751d772023d96718 (patch)
treed87aeefe7ca798fd8cdb911d932a2712944f5ca3 /.config/awesome
parent5b8d412cf79168fc6cdd45eac3ce65934d1f7b8d (diff)
parent049a44b608aacbaf1f040183def77fd7e7243fe3 (diff)
downloaddotfiles-52abe4f88168002420813e20751d772023d96718.tar.gz
dotfiles-52abe4f88168002420813e20751d772023d96718.zip
Merge remote-tracking branch 'origin/master' into phoenix
Conflicts: .config/awesome/rc.lua
Diffstat (limited to '.config/awesome')
-rw-r--r--.config/awesome/ext.lua67
-rw-r--r--.config/awesome/oni.lua73
-rw-r--r--.config/awesome/rc.lua100
-rw-r--r--.config/awesome/themes/custom/theme.lua2
4 files changed, 153 insertions, 89 deletions
diff --git a/.config/awesome/ext.lua b/.config/awesome/ext.lua
new file mode 100644
index 0000000..d564867
--- /dev/null
+++ b/.config/awesome/ext.lua
@@ -0,0 +1,67 @@
+local client=client
+local awful=awful
+local pairs=pairs
+local table=table
+
+module("ext")
+
+-- 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 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()
+ awful.screen.focus(c.screen)
+ return
+ end
+ awful.util.spawn(cmd)
+end
diff --git a/.config/awesome/oni.lua b/.config/awesome/oni.lua
new file mode 100644
index 0000000..7cc5df1
--- /dev/null
+++ b/.config/awesome/oni.lua
@@ -0,0 +1,73 @@
+local awful = awful
+local beautiful = beautiful
+local client = client
+local ext = require("ext")
+local lfs = require("lfs")
+local pairs = pairs
+local string = string
+local table = table
+local widget = widget
+
+module("oni")
+
+local maildirfmt = "/home/slash/documents/mail/%s/inbox/new/"
+
+function mailcount(account)
+ local i = 0
+ local dir = string.format(maildirfmt, account)
+
+ for file in lfs.dir(dir) do
+ if file ~= "." and file ~= ".." then
+ i = i + 1
+ end
+ end
+
+ return i
+end
+
+local function showmail(name)
+ awful.util.spawn("emacsclient -e '(oni:view-mail \"" .. name .. "\")'")
+end
+
+function 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 ", mailcount(account))
+ widgets.count.bg = beautiful.bg_focus
+ widgets.count:buttons(
+ awful.util.table.join(
+ awful.button({ }, 1, function (c) showmail(name) end)))
+
+ return widgets
+end
+
+function focus_raise(direction)
+ awful.client.focus.bydirection(direction)
+ if client.focus then client.focus:raise() end
+end
+
+function ror_browser()
+ ext.run_or_raise("conkeror", { class = "Conkeror" })
+end
+
+function ror_editor()
+ ext.run_or_raise("emacsclient -c -a emacs", { class = "Emacs" })
+end
+
+function ror_term()
+ ext.run_or_raise("urxvt", { class = "URxvt" })
+end
+
+function run_browser()
+ awful.util.spawn("conkeror")
+end
+
+function run_editor()
+ awful.util.spawn("emacsclient -c -a emacs")
+end
+
+function run_term()
+ awful.util.spawn("urxvt")
+end
diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua
index 38e9a72..24ff5fe 100644
--- a/.config/awesome/rc.lua
+++ b/.config/awesome/rc.lua
@@ -4,10 +4,9 @@ require("awful.rules")
require("beautiful")
require("bowl")
require("keychain")
-require("lfs")
require("naughty")
-
-oni = { } -- Container for custom functions.
+require("ext")
+require("oni")
--- Error handling
-- Check if awesome encountered an error during startup and fell back to
@@ -33,72 +32,6 @@ do
end)
end
---- Functions
-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 oni.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 oni.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()
- awful.screen.focus(c.screen)
- return
- end
- awful.util.spawn(cmd)
-end
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("/home/slash/.config/awesome/themes/custom/theme.lua")
@@ -282,28 +215,19 @@ globalkeys = awful.util.table.join(
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({ "Shift", }, "e",
- function () awful.util.spawn("emacsclient -c -a emacs") end),
- sub({ }, "c",
- function () oni.run_or_raise("urxvt",
- { class = "URxvt" }) end),
- sub({ "Shift", }, "c",
- function () awful.util.spawn("urxvt") end),
- sub({ }, "w",
- function () oni.run_or_raise("conkeror",
- { class = "Conkeror" }) end),
- sub({ "Shift", }, "w",
- function () awful.util.spawn("conkeror") end) }),
+ sub({ }, "c", oni.ror_term),
+ sub({ "Shift", }, "c", oni.run_term),
+ sub({ }, "e", oni.ror_editor),
+ sub({ "Shift", }, "e", oni.run_editor),
+ sub({ }, "w", oni.ror_browser),
+ sub({ "Shift", }, "w", oni.run_browser) }),
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),
+ 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),
+ -- awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
-- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
diff --git a/.config/awesome/themes/custom/theme.lua b/.config/awesome/themes/custom/theme.lua
index 3cdb9ca..c65edc8 100644
--- a/.config/awesome/themes/custom/theme.lua
+++ b/.config/awesome/themes/custom/theme.lua
@@ -74,7 +74,7 @@ theme.titlebar_maximized_button_normal_active = "/home/slash/.config/awesome/the
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" }
+theme.wallpaper_cmd = { "awsetbg -u feh -c /usr/share/archlinux/wallpaper/archlinux-simplyblack.png" }
-- You can use your own layout icons like this:
theme.layout_fairh = "/home/slash/.config/awesome/themes/custom/layouts/fairhw.png"