Permalink
Browse files

Another stab at awesomewm. Many modules meandering in a menacing manner

  • Loading branch information...
1 parent 9f88f35 commit 61c66c51ae762287d42b507110c1241dd125b9db Russell Pickett committed Feb 26, 2012
View
2 .Xdefaults
@@ -18,7 +18,7 @@ URxvt.depth: 32
URxvt.geometry: 90x30
URxvt.transparent: false
URxvt.fading: 0
-! URxvt.urgentOnBell: true
+URxvt.urgentOnBell: true
! URxvt.visualBell: true
URxvt.loginShell: true
URxvt.saveLines: 5000
View
1 .config/awesome/calendar2.lua
View
1 .config/awesome/delightful
1 .config/awesome/delightful-git
@@ -0,0 +1 @@
+Subproject commit 838d58d2233929e05761ee47ae6b3427d2e40a47
View
125 .config/awesome/eminent.lua
@@ -0,0 +1,125 @@
+----------------------------------------------------------------
+-- Effortless wmii-style dynamic tagging.
+----------------------------------------------------------------
+-- Lucas de Vries <lucas@glacicle.org>
+-- Licensed under the WTFPL version 2
+-- * http://sam.zoy.org/wtfpl/COPYING
+----------------------------------------------------------------
+-- To use this module add:
+-- require("eminent")
+-- to the top of your rc.lua.
+--
+-- That's it. Through magical monkey-patching, all you need to
+-- do to start dynamic tagging is loading it.
+--
+-- Use awesome like you normally would, you don't need to
+-- change a thing.
+----------------------------------------------------------------
+
+-- Grab environment
+local ipairs = ipairs
+local pairs = pairs
+local awful = require("awful")
+local table = table
+local capi = {
+ tag = tag,
+ mouse = mouse,
+ client = client,
+ screen = screen,
+ wibox = wibox,
+ timer = timer,
+ keygrabber = keygrabber,
+}
+
+-- Eminent: Effortless wmii-style dynamic tagging
+module("eminent")
+
+-- Grab the original functions we're replacing
+local deflayout = nil
+local orig = {
+ new = awful.tag.new,
+ viewidx = awful.tag.viewidx,
+
+ taglist = awful.widget.taglist.new,
+ label = awful.widget.taglist.label.all,
+}
+
+-- Return tags with stuff on them, mark others hidden
+function gettags(screen)
+ local tags = {}
+
+ for k, t in ipairs(capi.screen[screen]:tags()) do
+ if t.selected or #t:clients() > 0 then
+ awful.tag.setproperty(t, "hide", false)
+ table.insert(tags, t)
+ else
+ awful.tag.setproperty(t, "hide", true)
+ end
+ end
+
+ return tags
+end
+
+-- Pre-create tags
+awful.tag.new = function (names, screen, layout)
+ deflayout = layout and layout[1] or layout
+ return orig.new(names, screen, layout)
+end
+
+-- View tag by relative index
+awful.tag.viewidx = function (i, screen)
+ -- Hide tags
+ local s = screen and screen.index or capi.mouse.screen
+ local ctags = capi.screen[s]:tags()
+ local tags = gettags(s)
+ local sel = awful.tag.selected()
+
+ -- Check if we should "create" a new tag
+ local selidx = awful.util.table.hasitem(tags, sel)
+ local tagidx = awful.util.table.hasitem(ctags, sel)
+
+ -- Create a new tag if needed
+ if selidx == #tags and i == 1 and #sel:clients() > 0 then
+ -- Deselect all
+ awful.tag.viewnone(s)
+
+ if #ctags >= tagidx+1 then
+ -- Focus next
+ ctags[tagidx+1].selected = true
+ else
+ -- Create new
+ local tag = capi.tag { name = ""..(tagidx+1) }
+ tag.screen = s
+ tag.selected = true
+ awful.tag.setproperty(tag, "layout", deflayout)
+ end
+ else
+ -- Call original
+ orig.viewidx(i, screen)
+ end
+end
+
+-- Taglist label functions
+awful.widget.taglist.label.all = function (t, args)
+ if t.selected or #t:clients() > 0 then
+ return orig.label(t, args)
+ end
+end
+
+
+-- Update hidden status
+local function uc(c) gettags(c.screen) end
+local function ut(s, t) gettags(s.index) end
+
+capi.client.add_signal("unmanage", uc)
+capi.client.add_signal("new", function(c)
+ c:add_signal("property::screen", uc)
+ c:add_signal("tagged", uc)
+ c:add_signal("untagged", uc)
+end)
+
+for screen=1, capi.screen.count() do
+ awful.tag.attached_add_signal(screen, "property::selected", uc)
+ capi.screen[screen]:add_signal("tag::attach", ut)
+ capi.screen[screen]:add_signal("tag::detach", ut)
+end
View
1 .config/awesome/freedesktop
View
176 .config/awesome/rc.lua
@@ -8,30 +8,96 @@ require("beautiful")
require("naughty")
-- dynamic tagging
require("eminent")
+
+-- {{{ 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(awful.util.getdir("config") .. "/themes/zenburn/theme.lua")
-- This is used later as the default terminal and editor to run.
-terminal = "gnome-terminal"
+terminal = "urxvt256c"
editor = os.getenv("EDITOR") or "vim"
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 = "Mod1"
+modkey = "Mod4"
+
+-- Delightful widgets
+require("delightful.widgets.cpu")
+require("delightful.widgets.datetime")
+require("delightful.widgets.memory")
+require("delightful.widgets.pulseaudio")
+
+-- RP - wouldn't it be delightful to mash the following bits
+-- together into one? This three stanzas worth of stuff seems
+-- rather wordy.
+
+-- Delightful widgets install order
+install_delightful = {
+ delightful.widgets.cpu,
+ delightful.widgets.memory,
+ delightful.widgets.pulseaudio,
+ delightful.widgets.datetime,
+}
+
+-- Delightful widgets config
+delightful_config = {
+ --[delightful.widgets.cpu] = { command = 'gnome-system-monitor', },
+ --[delightful.widgets.memory] = { command = 'gnome-system-monitor', },
+ [delightful.widgets.pulseaudio] = {
+ sink_nums = { 0 },
+ mixer_command = 'pavucontrol',
+ },
+}
+
+-- Prepare the container that is used when constructing the wibox
+local d_container = { widgets = {}, icons = {} }
+if install_delightful then
+ for _, widget in pairs(awful.util.table.reverse(install_delightful)) do
+ local config = delightful_config and delightful_config[widget]
+ local widgets, icons = widget:load(config)
+ if widgets then
+ if not icons then
+ icons = {}
+ end
+ table.insert(d_container.widgets, awful.util.table.reverse(widgets))
+ table.insert(d_container.icons, awful.util.table.reverse(icons))
+ end
+ end
+end
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
-- awful.layout.suit.floating,
-- awful.layout.suit.tile,
+ awful.layout.suit.tile.right,
awful.layout.suit.tile.top,
awful.layout.suit.tile.bottom,
- awful.layout.suit.tile.left,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
-- awful.layout.suit.spiral,
@@ -55,7 +121,7 @@ end
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
- { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
+ { "edit config", editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
@@ -70,33 +136,37 @@ mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
-- }}}
-- {{{ 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({ }, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag),
- awful.button({ }, 3, awful.tag.viewtoggle),
+ 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)
+ 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])
+ 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
- client.focus = c
- c:raise()
end),
awful.button({ }, 3, function ()
if instance then
@@ -105,14 +175,14 @@ mytasklist.buttons = awful.util.table.join(
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),
+-- 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
@@ -137,19 +207,32 @@ for s = 1, screen.count() do
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Add widgets to the wibox - order matters
- mywibox[s].widgets = {
+ local widgets_front = {
{
mylauncher,
mytaglist[s],
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s],
- mytextclock,
+ }
+
+ local widgets_middle = {}
+ for dc_index, dc_data in pairs(d_container.widgets) do
+ for widget_index, widget_data in pairs(dc_data) do
+ table.insert(widgets_middle, widget_data)
+ if d_container.icons[dc_index] and d_container.icons[dc_index][widget_index] then
+ table.insert(widgets_middle, d_container.icons[dc_index][widget_index])
+ end
+ end
+ end
+
+ local widgets_end = {
s == 1 and mysystray or nil,
mytasklist[s],
layout = awful.widget.layout.horizontal.rightleft
}
+ mywibox[s].widgets = awful.util.table.join(widgets_front, widgets_middle, widgets_end)
end
-- }}}
@@ -193,24 +276,45 @@ globalkeys = awful.util.table.join(
end
end),
+ -- Media Keys
+ -- TODO - figure out how to poke the volume widget to update itself.
+ awful.key({}, "XF86AudioMute",
+ function()
+ awful.util.spawn('pa-volume.sh mute')
+ end
+ ),
+ awful.key({}, "XF86AudioRaiseVolume",
+ function()
+ awful.util.spawn('pa-volume.sh plus')
+ end
+ ),
+ awful.key({}, "XF86AudioLowerVolume",
+ function()
+ awful.util.spawn('pa-volume.sh minus')
+ 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, }, "l", 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",
+ awful.key({ modkey }, "x",
function ()
awful.prompt.run({ prompt = "Run Lua code: " },
mypromptbox[mouse.screen].widget,
@@ -227,7 +331,12 @@ clientkeys = awful.util.table.join(
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) c.minimized = not c.minimized 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
@@ -298,6 +407,9 @@ awful.rules.rules = {
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
+ { rule = { class = "Pavucontrol" },
+ properties = { floating = true },
+ callback = awful.placement.centered },
-- Set Firefox to always map on tags number 2 of screen 1.
-- { rule = { class = "Firefox" },
-- properties = { tag = tags[1][2] } },
View
1 .config/awesome/vicious
View
32 .config/awesome/volume.lua
@@ -0,0 +1,32 @@
+ volume_widget = widget({ type = "textbox", name = "tb_volume",
+ align = "right" })
+
+ function update_volume(widget)
+ local fd = io.popen("amixer sget Master")
+ local status = fd:read("*all")
+ fd:close()
+
+ local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100
+ -- volume = string.format("% 3d", volume)
+
+ status = string.match(status, "%[(o[^%]]*)%]")
+
+ -- starting colour
+ local sr, sg, sb = 0x3F, 0x3F, 0x3F
+ -- ending colour
+ local er, eg, eb = 0xDC, 0xDC, 0xCC
+
+ local ir = volume * (er - sr) + sr
+ local ig = volume * (eg - sg) + sg
+ local ib = volume * (eb - sb) + sb
+ interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib)
+ if string.find(status, "on", 1, true) then
+ volume = " <span background='#" .. interpol_colour .. "'> </span>"
+ else
+ volume = " <span color='red' background='#" .. interpol_colour .. "'> M </span>"
+ end
+ widget.text = volume
+ end
+
+ update_volume(volume_widget)
+ awful.hooks.timer.register(1, function () update_volume(volume_widget) end)
View
1 .gitignore
@@ -115,6 +115,7 @@ bin/*.pyc
.pulse-cookie
.pulse/
.purple/
+.quodlibet/
.qt/
.recently-used.xbel
.rdebug_hist
View
3 .gitmodules
@@ -67,3 +67,6 @@
[submodule ".vim/bundle/supertab"]
path = .vim/bundle/supertab
url = git://github.com/ervandew/supertab.git
+[submodule ".config/awesome/delightful-git"]
+ path = .config/awesome/delightful-git
+ url = git://scm.solitudo.net/delightful.git
View
1,362 bin/dropbox.py
1,362 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
36 bin/pa-volume.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+SINK_NAME="alsa_output.pci-0000_00_1b.0.analog-stereo"
+VOL_STEP="0x01000"
+
+VOL_NOW=`pacmd dump | grep -P "^set-sink-volume $SINK_NAME\s+" | perl -p -i -e 's/.+\s(.x.+)$/$1/'`
+
+case "$1" in
+ plus)
+ VOL_NEW=$((VOL_NOW + VOL_STEP))
+ if [ $VOL_NEW -gt $((0x10000)) ]
+ then
+ VOL_NEW=$((0x10000))
+ fi
+ pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
+
+ ;;
+ minus)
+ VOL_NEW=$((VOL_NOW - VOL_STEP))
+ if [ $(($VOL_NEW)) -lt $((0x00000)) ]
+ then
+ VOL_NEW=$((0x00000))
+ fi
+ pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
+ ;;
+ mute)
+
+ MUTE_STATE=`pacmd dump | grep -P "^set-sink-mute $SINK_NAME\s+" | perl -p -i -e 's/.+\s(yes|no)$/$1/'`
+ if [ $MUTE_STATE = no ]
+ then
+ pactl set-sink-mute $SINK_NAME 1
+ elif [ $MUTE_STATE = yes ]
+ then
+ pactl set-sink-mute $SINK_NAME 0
+ fi
+esac

0 comments on commit 61c66c5

Please sign in to comment.