lae's notebook

Increasing Maximum Volume with ALSA

Since I don't have a set of monitors for my desktop, I use a pair of headphones often as speakers for audio. This setup usually is insufferable because of low audio, though mplayer has a "softvol" plugin that lets you increase your sound output's decibel level - and since I hardly needed sound for anything other than music or video, this solution worked perfectly (of course, for anything else I could put on my headphones).

That solution sufficed for me until recently, and I found out ALSA actually has a softvol plugin that lets you set max_dB (usually 0 by default). This can be done in /etc/asound.conf or ~/.asoundrc with the following definitions:

pcm.softvol {
        type softvol
        slave.pcm "cards.pcm.default"
        control {
                name "Software"
                card 0
        }
        max_dB 20.0
}
pcm.!default {
        type            plug
        slave.pcm       "softvol"
}

Depending on your configuration, the line slave.pcm "cards.pcm.default" and card 0 may need modification - you can run aplay -Ll to list your devices and card indices. Changes will take effect upon restarting applications that use sound.

This will create a "Software" control in applications like alsamixer, which will let you increase the decibel level up to 20dB (though there isn't any indication of what the decibel level is at other than percentages). Since I didn't specify min_dB, it defaults to -51dB.

You can also control the left and right channels independently, which is useful when you need volume to be louder in one speaker or headphone in a stereo setup.

First Dive Into Lua - A Battery Widget

So, it's come to the point where my laptop has unexpectedly turned off from a dead battery one too many times, so I decided to write a battery widget using Vicious for the window manager I'm using, Awesome. The configuration files are all written in Lua, and honestly I've never touched Lua or felt like programming in it since it looks so...confuzzling.

Nevertheless, I took a look at the Vicious and Naughty libraries, and some Lua documentation to get this up and running:

batmon = awful.widget.progressbar()
batmon:set_width(8)
batmon:set_vertical(true)
batmon:set_border_color("#3f3f3f")
batmon:set_color("#5f5f5f")
batmon_t = awful.tooltip({ objects = { batmon.widget },})
vicious.register(batmon, vicious.widgets.bat, function (widget, args)
	batmon_t:set_text(" State: " .. args[1] .. " | Charge: " .. args[2] .. "% | Remaining: " .. args[3])
	if args[2] <= 5 then
		naughty.notify({ text="Battery is low! " .. args[2] .. " percent remaining." })
	end
	return args[2]
end , 60, "BAT0")

What this basically does is create a progressbar widget with the Awful library, configure its settings, create a tooltip with detailed information, and registers the widget I created with Vicious. The Vicious portion of it uses the battery widget type and sets a timer to update it every 60 seconds, which updates the progressbar percentage and the tooltip. It also checks for a low battery, which for me pops up a little box at the upper right of my screen.

I'm probably not going to be touching Lua for a while again.

Postler and it's "INBOX is locked" message

I'm sure some of you have had Postler stop being able to receive messages from your email account one day or another, but have had no idea why.

Running postler in a command line, I would see the following when attempting to "receive mail":

    • (postler-service:2376): DEBUG: postler-service.vala:67: Line/ input: Connection is now encrypted ** (postler-service:2376): DEBUG: postler-service.vala:67: Line/ input: Logging in... ** (postler-service:2376): DEBUG: postler-service.vala:67: Line/ input: Opening slave local... ** (postler-service:2376): DEBUG: postler-service.vala:67: Line/ error: Error: channel :remote:INBOX-:local:INBOX is locked ** (postler-service:2376): DEBUG: postler-service.vala:303: Done: 0 new messages

I couldn't figure it out at first, and the first time it happened I thought it was a transitory issue since it seemed to have been fixed when I reinstalled Postler and move the old configuration directory out of the way. Then, it happened again and I had stopped using Postler to check mail.

Just yesterday, however, when I had a process to kill, I saw a postler-mbsync process while I wasn't running Postler. I killed it (killall postler-mbsync) and then started up Postler today, and lo and behold, the inbox is no longer locked and I am able to receive mail~