Skip to content
Guff edited this page Jul 23, 2011 · 2 revisions

Miscellaneous

Introduce a delay after each failed login attempt

hook.connect("auth-failed", function () utils.sleep(3) end)

Make the delay increase after each failed attempt

local delay = 3
hook.connect("auth-failed", function ()
    utils.sleep(delay)
    delay = delay + 3
end)

Cap the delay

local delay = 3
hook.connect("auth-failed", function ()
    utils.sleep(delay)
    delay = math.min(delay + 3, 60)
end)

Pause MPD when the screen is locked

hook.connect("lock", function () utils.spawn("mpc pause") end)

Resume MPD when the screen is unlocked

hook.connect("unlock", function () utils.spawn("mpc play") end)

Add an indicator for your battery

require "odious"
batt_box = odious.widget.progressbar{ width = 20, height = 60, x = 0.8, y = 0.1 }
batt_box:set_border_color("white"):set_vertical(true):set_color("green")
batt_timer = timer(function ()
    local batt_info = odious.util.get_battery("BAT0")
    local level = batt_info.charge_now / batt_info.charge_full
    batt_box:set_value(level)
end, 1)
batt_timer:start()