diff --git a/lib/brightness.lua b/lib/brightness.lua new file mode 100644 index 0000000..59c38f2 --- /dev/null +++ b/lib/brightness.lua @@ -0,0 +1,32 @@ +-- Handle brightness (with xbacklight) + +local awful = require("awful") +local naughty = require("naughty") +local tonumber = tonumber +local string = string +local os = os + +module("vbe/brightness") + +local nid = nil +local function change(what) + -- We don't really change the brightness, just report the change... + local out = awful.util.pread("xbacklight -get") + if not out then return end + + out = tonumber(out) + local icon = "/usr/share/icons/HighContrast/32x32/status/display-brightness.png" + + nid = naughty.notify({ text = string.format("%3d %%", out), + icon = icon, + font = "Free Sans Bold 24", + replaces_id = nid }).id +end + +function increase() + change("+ 5") +end + +function decrease() + change("- 5") +end diff --git a/rc/bindings.lua b/rc/bindings.lua index b16f9e2..dd5a109 100644 --- a/rc/bindings.lua +++ b/rc/bindings.lua @@ -1,6 +1,7 @@ config.keys = {} config.mouse = {} local volume = loadrc("volume", "vbe/volume") +local brightness = loadrc("brightness", "vbe/brightness") local function client_info() local v = "" @@ -80,6 +81,8 @@ config.keys.global = awful.util.table.join( awful.key({ modkey, "Control" }, "r", awesome.restart), -- Multimedia keys + awful.key({ }, "XF86MonBrightnessUp", brightness.increase), + awful.key({ }, "XF86MonBrightnessDown", brightness.decrease), awful.key({ }, "XF86AudioRaiseVolume", volume.increase), awful.key({ }, "XF86AudioLowerVolume", volume.decrease), awful.key({ }, "XF86AudioMute", volume.toggle)