AwesomeWM config snippets

My favourite windowmanager is awesomewm. I use it on all my workplaces (notebook, desktop, at work).

Some changes from my config

  • bind ctrl-alt-l to lock screen
awful.key({ "Mod1", "Control" }, "l",
  function () awful.util.spawn("xscreensaver-command -lock") end)
  • (simple) battery widget using Vicious .
baticon = widget({ type = "imagebox" })
baticon.image = image(beautiful.widget_bat)

batwidget = widget({ type = "textbox" })
vicious.register(batwidget, vicious.widgets.bat,
function (widget, args)
      return "<b>" .. args[1] .. "</b>"
end, 10, "BAT1")

Other battery widgets with Vicious: http://git.sysphere.org/vicious/tree/contrib

  • Volume widget using Vicious
volicon = widget({ type = "imagebox" })
volicon.image = image(beautiful.widget_vol)
volwidget = widget({type = "textbox", name = "volwidget"})

function volume(command,widget)
      if command == "update" then
              local fd = io.popen("amixer sget Master")
              local status = fd:read("*all")
              fd:close()

              local volume = tonumber(string.match(status, "(%d?%d?%d)%%"))

              if (string.find(status, "off", 1, true)) then
                      ret = "<b>Muted</b>"
              else
                      ret = "♫ <b>" .. volume .. "</b>"
              end
              widget.text = ret
      elseif command == "raise" then
              awful.util.spawn("amixer set Master 3%+ &")
              volume("update",volwidget)
      elseif command == "lower" then
              awful.util.spawn("amixer set Master 3%- &")
              volume("update",volwidget)
      elseif command == "toggle" then
              awful.util.spawn("amixer set Master toggle &")
              volume("update",volwidget)
      end
end
volume("update",volwidget)
-- Autorefresh every minute
awful.hooks.timer.register(60, function () volume("update", volwidget) end)

There are lots of other solutions, i.e. http://awesome.naquadah.org/wiki/Farhavens_volume_widget and http://jasonmaur.com/awesome-wm-widgets-configuration/

  • register audio keys on notebook keyboard (using the volume function above)
awful.key({}, "XF86AudioMute", function () volume("toggle", volwidget) end ),
awful.key({}, "XF86AudioRaiseVolume", function () volume("raise",volwidget) end),
awful.key({}, "XF86AudioLowerVolume", function () volume("lower",volwidget) end ),