Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 61c66c51ae762287d42b507110c1241dd125b9db 1 parent 9f88f35
authored
2  .Xdefaults
@@ -18,7 +18,7 @@ URxvt.depth: 32
18 18
 URxvt.geometry: 90x30
19 19
 URxvt.transparent: false
20 20
 URxvt.fading: 0
21  
-! URxvt.urgentOnBell: true
  21
+URxvt.urgentOnBell: true
22 22
 ! URxvt.visualBell: true
23 23
 URxvt.loginShell: true
24 24
 URxvt.saveLines: 5000
1  .config/awesome/calendar2.lua
1  .config/awesome/delightful
1  .config/awesome/delightful-git
... ...
@@ -0,0 +1 @@
  1
+Subproject commit 838d58d2233929e05761ee47ae6b3427d2e40a47
125  .config/awesome/eminent.lua
... ...
@@ -0,0 +1,125 @@
  1
+----------------------------------------------------------------
  2
+-- Effortless wmii-style dynamic tagging.
  3
+----------------------------------------------------------------
  4
+-- Lucas de Vries <lucas@glacicle.org>
  5
+-- Licensed under the WTFPL version 2
  6
+--   * http://sam.zoy.org/wtfpl/COPYING
  7
+----------------------------------------------------------------
  8
+-- To use this module add:
  9
+--   require("eminent")
  10
+-- to the top of your rc.lua. 
  11
+--
  12
+-- That's it. Through magical monkey-patching, all you need to
  13
+-- do to start dynamic tagging is loading it.
  14
+--
  15
+-- Use awesome like you normally would, you don't need to
  16
+-- change a thing.
  17
+----------------------------------------------------------------
  18
+
  19
+-- Grab environment
  20
+local ipairs = ipairs
  21
+local pairs = pairs
  22
+local awful = require("awful")
  23
+local table = table
  24
+local capi = {
  25
+    tag = tag,
  26
+    mouse = mouse,
  27
+    client = client,
  28
+    screen = screen,
  29
+    wibox = wibox,
  30
+    timer = timer,
  31
+    keygrabber = keygrabber,
  32
+}
  33
+
  34
+-- Eminent: Effortless wmii-style dynamic tagging
  35
+module("eminent")
  36
+
  37
+-- Grab the original functions we're replacing
  38
+local deflayout = nil
  39
+local orig = {
  40
+    new = awful.tag.new,
  41
+    viewidx = awful.tag.viewidx,
  42
+
  43
+    taglist = awful.widget.taglist.new,
  44
+    label = awful.widget.taglist.label.all,
  45
+}
  46
+
  47
+-- Return tags with stuff on them, mark others hidden
  48
+function gettags(screen)
  49
+    local tags = {}
  50
+
  51
+    for k, t in ipairs(capi.screen[screen]:tags()) do
  52
+        if t.selected or #t:clients() > 0 then
  53
+            awful.tag.setproperty(t, "hide", false)
  54
+            table.insert(tags, t)
  55
+        else
  56
+            awful.tag.setproperty(t, "hide", true)
  57
+        end
  58
+    end
  59
+
  60
+    return tags
  61
+end
  62
+
  63
+-- Pre-create tags
  64
+awful.tag.new = function (names, screen, layout)
  65
+    deflayout = layout and layout[1] or layout
  66
+    return orig.new(names, screen, layout)
  67
+end
  68
+
  69
+-- View tag by relative index
  70
+awful.tag.viewidx = function (i, screen)
  71
+    -- Hide tags
  72
+    local s = screen and screen.index or capi.mouse.screen
  73
+    local ctags = capi.screen[s]:tags()
  74
+    local tags = gettags(s)
  75
+    local sel = awful.tag.selected()
  76
+
  77
+    -- Check if we should "create" a new tag
  78
+    local selidx = awful.util.table.hasitem(tags, sel)
  79
+    local tagidx = awful.util.table.hasitem(ctags, sel)
  80
+
  81
+    -- Create a new tag if needed
  82
+    if selidx == #tags and i == 1 and #sel:clients() > 0 then
  83
+        -- Deselect all
  84
+        awful.tag.viewnone(s)
  85
+
  86
+        if #ctags >= tagidx+1 then
  87
+            -- Focus next
  88
+            ctags[tagidx+1].selected = true
  89
+        else
  90
+            -- Create new
  91
+            local tag = capi.tag { name = ""..(tagidx+1) }
  92
+            tag.screen = s
  93
+            tag.selected = true
  94
+            awful.tag.setproperty(tag, "layout", deflayout)
  95
+        end
  96
+    else
  97
+        -- Call original
  98
+        orig.viewidx(i, screen)
  99
+    end
  100
+end
  101
+
  102
+-- Taglist label functions
  103
+awful.widget.taglist.label.all = function (t, args)
  104
+    if t.selected or #t:clients() > 0 then
  105
+        return orig.label(t, args)
  106
+    end
  107
+end
  108
+
  109
+
  110
+-- Update hidden status
  111
+local function uc(c) gettags(c.screen) end
  112
+local function ut(s, t) gettags(s.index) end
  113
+
  114
+capi.client.add_signal("unmanage", uc)
  115
+capi.client.add_signal("new", function(c)
  116
+    c:add_signal("property::screen", uc)
  117
+    c:add_signal("tagged", uc)
  118
+    c:add_signal("untagged", uc)
  119
+end)
  120
+
  121
+for screen=1, capi.screen.count() do
  122
+    awful.tag.attached_add_signal(screen, "property::selected", uc)
  123
+    capi.screen[screen]:add_signal("tag::attach", ut)
  124
+    capi.screen[screen]:add_signal("tag::detach", ut)
  125
+end
1  .config/awesome/freedesktop
176  .config/awesome/rc.lua
@@ -8,30 +8,96 @@ require("beautiful")
8 8
 require("naughty")
9 9
 -- dynamic tagging
10 10
 require("eminent")
  11
+
  12
+-- {{{ Error handling
  13
+-- Check if awesome encountered an error during startup and fell back to
  14
+-- another config (This code will only ever execute for the fallback config)
  15
+if awesome.startup_errors then
  16
+    naughty.notify({ preset = naughty.config.presets.critical,
  17
+                     title = "Oops, there were errors during startup!",
  18
+                     text = awesome.startup_errors })
  19
+end
  20
+
  21
+-- Handle runtime errors after startup
  22
+do
  23
+    local in_error = false
  24
+    awesome.add_signal("debug::error", function (err)
  25
+        -- Make sure we don't go into an endless error loop
  26
+        if in_error then return end
  27
+        in_error = true
  28
+
  29
+        naughty.notify({ preset = naughty.config.presets.critical,
  30
+                         title = "Oops, an error happened!",
  31
+                         text = err })
  32
+        in_error = false
  33
+    end)
  34
+end
  35
+-- }}}
  36
+
11 37
 -- {{{ Variable definitions
12 38
 -- Themes define colours, icons, and wallpapers
13 39
 beautiful.init(awful.util.getdir("config") .. "/themes/zenburn/theme.lua")
14 40
 
15 41
 -- This is used later as the default terminal and editor to run.
16  
-terminal = "gnome-terminal"
  42
+terminal = "urxvt256c"
17 43
 editor = os.getenv("EDITOR") or "vim"
18 44
 editor_cmd = terminal .. " -e " .. editor
19 45
 
20 46
 -- Default modkey.
21  
--- Usually, Mod4 is the key with a logo between Control and Alt.
22  
--- If you do not like this or do not have such a key,
23  
--- I suggest you to remap Mod4 to another key using xmodmap or other tools.
24  
--- However, you can use another modifier like Mod1, but it may interact with others.
25  
-modkey = "Mod1"
  47
+modkey = "Mod4"
  48
+
  49
+-- Delightful widgets
  50
+require("delightful.widgets.cpu")
  51
+require("delightful.widgets.datetime")
  52
+require("delightful.widgets.memory")
  53
+require("delightful.widgets.pulseaudio")
  54
+
  55
+-- RP - wouldn't it be delightful to mash the following bits
  56
+-- together into one?  This three stanzas worth of stuff seems
  57
+-- rather wordy.
  58
+
  59
+-- Delightful widgets install order
  60
+install_delightful = {
  61
+  delightful.widgets.cpu,
  62
+  delightful.widgets.memory,
  63
+  delightful.widgets.pulseaudio,
  64
+  delightful.widgets.datetime,
  65
+}
  66
+
  67
+-- Delightful widgets config
  68
+delightful_config = {
  69
+  --[delightful.widgets.cpu]    = { command = 'gnome-system-monitor', },
  70
+  --[delightful.widgets.memory] = { command = 'gnome-system-monitor', },
  71
+  [delightful.widgets.pulseaudio] = {
  72
+      sink_nums = { 0 },
  73
+      mixer_command = 'pavucontrol',
  74
+  },
  75
+}
  76
+
  77
+-- Prepare the container that is used when constructing the wibox
  78
+local d_container = { widgets = {}, icons = {} }
  79
+if install_delightful then
  80
+    for _, widget in pairs(awful.util.table.reverse(install_delightful)) do
  81
+        local config = delightful_config and delightful_config[widget]
  82
+        local widgets, icons = widget:load(config)
  83
+        if widgets then
  84
+            if not icons then
  85
+                icons = {}
  86
+            end
  87
+            table.insert(d_container.widgets, awful.util.table.reverse(widgets))
  88
+            table.insert(d_container.icons,   awful.util.table.reverse(icons))
  89
+        end
  90
+    end
  91
+end
26 92
 
27 93
 -- Table of layouts to cover with awful.layout.inc, order matters.
28 94
 layouts =
29 95
 {
30 96
 --    awful.layout.suit.floating,
31 97
 --    awful.layout.suit.tile,
  98
+    awful.layout.suit.tile.right,
32 99
     awful.layout.suit.tile.top,
33 100
     awful.layout.suit.tile.bottom,
34  
-    awful.layout.suit.tile.left,
35 101
     awful.layout.suit.fair,
36 102
     awful.layout.suit.fair.horizontal,
37 103
 --    awful.layout.suit.spiral,
@@ -55,7 +121,7 @@ end
55 121
 -- Create a laucher widget and a main menu
56 122
 myawesomemenu = {
57 123
    { "manual", terminal .. " -e man awesome" },
58  
-   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  124
+   { "edit config", editor_cmd .. " " .. awesome.conffile },
59 125
    { "restart", awesome.restart },
60 126
    { "quit", awesome.quit }
61 127
 }
@@ -70,33 +136,37 @@ mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
70 136
 -- }}}
71 137
 
72 138
 -- {{{ Wibox
73  
--- Create a textclock widget
74  
-mytextclock = awful.widget.textclock({ align = "right" })
75  
-
76 139
 -- Create a systray
77 140
 mysystray = widget({ type = "systray" })
78 141
 
  142
+
79 143
 -- Create a wibox for each screen and add it
80 144
 mywibox = {}
81 145
 mypromptbox = {}
82 146
 mylayoutbox = {}
83 147
 mytaglist = {}
84 148
 mytaglist.buttons = awful.util.table.join(
85  
-                    awful.button({ }, 1, awful.tag.viewonly),
  149
+                    awful.button({        }, 1, awful.tag.viewonly),
86 150
                     awful.button({ modkey }, 1, awful.client.movetotag),
87  
-                    awful.button({ }, 3, awful.tag.viewtoggle),
  151
+                    awful.button({        }, 3, awful.tag.viewtoggle),
88 152
                     awful.button({ modkey }, 3, awful.client.toggletag),
89  
-                    awful.button({ }, 4, awful.tag.viewnext),
90  
-                    awful.button({ }, 5, awful.tag.viewprev)
  153
+                    awful.button({        }, 4, awful.tag.viewnext),
  154
+                    awful.button({        }, 5, awful.tag.viewprev)
91 155
                     )
92 156
 mytasklist = {}
93 157
 mytasklist.buttons = awful.util.table.join(
94 158
                      awful.button({ }, 1, function (c)
95  
-                                              if not c:isvisible() then
96  
-                                                  awful.tag.viewonly(c:tags()[1])
  159
+                                              if c == client.focus then
  160
+                                                  c.minimized = true
  161
+                                              else
  162
+                                                  if not c:isvisible() then
  163
+                                                      awful.tag.viewonly(c:tags()[1])
  164
+                                                  end
  165
+                                                  -- This will also un-minimize
  166
+                                                  -- the client, if needed
  167
+                                                  client.focus = c
  168
+                                                  c:raise()
97 169
                                               end
98  
-                                              client.focus = c
99  
-                                              c:raise()
100 170
                                           end),
101 171
                      awful.button({ }, 3, function ()
102 172
                                               if instance then
@@ -105,14 +175,14 @@ mytasklist.buttons = awful.util.table.join(
105 175
                                               else
106 176
                                                   instance = awful.menu.clients({ width=250 })
107 177
                                               end
108  
-                                          end),
109  
-                     awful.button({ }, 4, function ()
110  
-                                              awful.client.focus.byidx(1)
111  
-                                              if client.focus then client.focus:raise() end
112  
-                                          end),
113  
-                     awful.button({ }, 5, function ()
114  
-                                              awful.client.focus.byidx(-1)
115  
-                                              if client.focus then client.focus:raise() end
  178
+--                                          end),
  179
+--                     awful.button({ }, 4, function ()
  180
+--                                              awful.client.focus.byidx(1)
  181
+--                                              if client.focus then client.focus:raise() end
  182
+--                                          end),
  183
+--                     awful.button({ }, 5, function ()
  184
+--                                              awful.client.focus.byidx(-1)
  185
+--                                              if client.focus then client.focus:raise() end
116 186
                                           end))
117 187
 
118 188
 for s = 1, screen.count() do
@@ -137,7 +207,7 @@ for s = 1, screen.count() do
137 207
     -- Create the wibox
138 208
     mywibox[s] = awful.wibox({ position = "top", screen = s })
139 209
     -- Add widgets to the wibox - order matters
140  
-    mywibox[s].widgets = {
  210
+    local widgets_front = {
141 211
         {
142 212
             mylauncher,
143 213
             mytaglist[s],
@@ -145,11 +215,24 @@ for s = 1, screen.count() do
145 215
             layout = awful.widget.layout.horizontal.leftright
146 216
         },
147 217
         mylayoutbox[s],
148  
-        mytextclock,
  218
+    }
  219
+
  220
+    local widgets_middle = {}
  221
+    for dc_index, dc_data in pairs(d_container.widgets) do
  222
+        for widget_index, widget_data in pairs(dc_data) do
  223
+            table.insert(widgets_middle, widget_data)
  224
+            if d_container.icons[dc_index] and d_container.icons[dc_index][widget_index] then
  225
+                table.insert(widgets_middle, d_container.icons[dc_index][widget_index])
  226
+            end
  227
+        end
  228
+    end
  229
+
  230
+    local widgets_end = {
149 231
         s == 1 and mysystray or nil,
150 232
         mytasklist[s],
151 233
         layout = awful.widget.layout.horizontal.rightleft
152 234
     }
  235
+    mywibox[s].widgets = awful.util.table.join(widgets_front, widgets_middle, widgets_end)
153 236
 end
154 237
 -- }}}
155 238
 
@@ -193,13 +276,32 @@ globalkeys = awful.util.table.join(
193 276
             end
194 277
         end),
195 278
 
  279
+    -- Media Keys
  280
+    -- TODO - figure out how to poke the volume widget to update itself.
  281
+    awful.key({}, "XF86AudioMute",
  282
+        function()
  283
+          awful.util.spawn('pa-volume.sh mute')
  284
+        end
  285
+    ),
  286
+    awful.key({}, "XF86AudioRaiseVolume",
  287
+        function()
  288
+          awful.util.spawn('pa-volume.sh plus')
  289
+        end
  290
+    ),
  291
+    awful.key({}, "XF86AudioLowerVolume",
  292
+        function()
  293
+          awful.util.spawn('pa-volume.sh minus')
  294
+        end
  295
+    ),
  296
+
  297
+
196 298
     -- Standard program
197 299
     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
198 300
     awful.key({ modkey, "Control" }, "r", awesome.restart),
199 301
     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
200 302
 
201  
-    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
202 303
     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  304
+    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
203 305
     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
204 306
     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
205 307
     --awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
@@ -207,10 +309,12 @@ globalkeys = awful.util.table.join(
207 309
     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
208 310
     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
209 311
 
  312
+    awful.key({ modkey, "Control" }, "n", awful.client.restore),
  313
+
210 314
     -- Prompt
211 315
     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
212 316
 
213  
-    awful.key({ modkey },            "x",
  317
+    awful.key({ modkey }, "x",
214 318
               function ()
215 319
                   awful.prompt.run({ prompt = "Run Lua code: " },
216 320
                   mypromptbox[mouse.screen].widget,
@@ -227,7 +331,12 @@ clientkeys = awful.util.table.join(
227 331
     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
228 332
     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
229 333
     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
230  
-    awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  334
+    awful.key({ modkey,           }, "n",
  335
+        function (c)
  336
+            -- The client currently has the input focus, so it cannot be
  337
+            -- minimized, since minimized clients can't have the focus.
  338
+            c.minimized = true
  339
+        end),
231 340
     awful.key({ modkey,           }, "m",
232 341
         function (c)
233 342
             c.maximized_horizontal = not c.maximized_horizontal
@@ -298,6 +407,9 @@ awful.rules.rules = {
298 407
       properties = { floating = true } },
299 408
     { rule = { class = "gimp" },
300 409
       properties = { floating = true } },
  410
+    { rule = { class = "Pavucontrol" },
  411
+      properties = { floating = true },
  412
+      callback = awful.placement.centered },
301 413
     -- Set Firefox to always map on tags number 2 of screen 1.
302 414
     -- { rule = { class = "Firefox" },
303 415
     --   properties = { tag = tags[1][2] } },
1  .config/awesome/vicious
32  .config/awesome/volume.lua
... ...
@@ -0,0 +1,32 @@
  1
+    volume_widget = widget({ type = "textbox", name = "tb_volume",
  2
+                             align = "right" })
  3
+
  4
+    function update_volume(widget)
  5
+        local fd = io.popen("amixer sget Master")
  6
+        local status = fd:read("*all")
  7
+        fd:close()
  8
+        
  9
+        local volume = tonumber(string.match(status, "(%d?%d?%d)%%")) / 100
  10
+        -- volume = string.format("% 3d", volume)
  11
+
  12
+        status = string.match(status, "%[(o[^%]]*)%]")
  13
+
  14
+        -- starting colour
  15
+        local sr, sg, sb = 0x3F, 0x3F, 0x3F
  16
+        -- ending colour
  17
+        local er, eg, eb = 0xDC, 0xDC, 0xCC
  18
+
  19
+        local ir = volume * (er - sr) + sr
  20
+        local ig = volume * (eg - sg) + sg
  21
+        local ib = volume * (eb - sb) + sb
  22
+        interpol_colour = string.format("%.2x%.2x%.2x", ir, ig, ib)
  23
+        if string.find(status, "on", 1, true) then
  24
+            volume = " <span background='#" .. interpol_colour .. "'>   </span>"
  25
+        else
  26
+            volume = " <span color='red' background='#" .. interpol_colour .. "'> M </span>"
  27
+        end
  28
+        widget.text = volume
  29
+     end
  30
+
  31
+    update_volume(volume_widget)
  32
+    awful.hooks.timer.register(1, function () update_volume(volume_widget) end)
1  .gitignore
@@ -115,6 +115,7 @@ bin/*.pyc
115 115
 .pulse-cookie
116 116
 .pulse/
117 117
 .purple/
  118
+.quodlibet/
118 119
 .qt/
119 120
 .recently-used.xbel
120 121
 .rdebug_hist
3  .gitmodules
@@ -67,3 +67,6 @@
67 67
 [submodule ".vim/bundle/supertab"]
68 68
 	path = .vim/bundle/supertab
69 69
 	url = git://github.com/ervandew/supertab.git
  70
+[submodule ".config/awesome/delightful-git"]
  71
+	path = .config/awesome/delightful-git
  72
+	url = git://scm.solitudo.net/delightful.git
1,362  bin/dropbox.py
1362 additions, 0 deletions not shown
36  bin/pa-volume.sh
... ...
@@ -0,0 +1,36 @@
  1
+#!/bin/bash
  2
+
  3
+SINK_NAME="alsa_output.pci-0000_00_1b.0.analog-stereo"
  4
+VOL_STEP="0x01000"
  5
+
  6
+VOL_NOW=`pacmd dump | grep -P "^set-sink-volume $SINK_NAME\s+" | perl -p -i -e 's/.+\s(.x.+)$/$1/'`
  7
+
  8
+case "$1" in
  9
+  plus)
  10
+    VOL_NEW=$((VOL_NOW + VOL_STEP))
  11
+    if [ $VOL_NEW -gt $((0x10000)) ]
  12
+     then
  13
+        VOL_NEW=$((0x10000))
  14
+    fi
  15
+    pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
  16
+
  17
+  ;;
  18
+  minus)
  19
+    VOL_NEW=$((VOL_NOW - VOL_STEP))
  20
+    if [ $(($VOL_NEW)) -lt $((0x00000)) ]
  21
+     then
  22
+        VOL_NEW=$((0x00000))
  23
+    fi
  24
+    pactl set-sink-volume $SINK_NAME `printf "0x%X" $VOL_NEW`
  25
+  ;;
  26
+  mute)
  27
+
  28
+    MUTE_STATE=`pacmd dump | grep -P "^set-sink-mute $SINK_NAME\s+" | perl -p -i -e 's/.+\s(yes|no)$/$1/'`
  29
+    if [ $MUTE_STATE = no ]
  30
+     then
  31
+        pactl set-sink-mute $SINK_NAME 1
  32
+    elif [ $MUTE_STATE = yes ]
  33
+     then
  34
+        pactl set-sink-mute $SINK_NAME 0
  35
+    fi
  36
+esac

0 notes on commit 61c66c5

Please sign in to comment.
Something went wrong with that request. Please try again.