Skip to content

Instantly share code, notes, and snippets.

@powerswitch
Created August 28, 2015 10:47
Show Gist options
  • Save powerswitch/0f389d1b4581f767bc2e to your computer and use it in GitHub Desktop.
Save powerswitch/0f389d1b4581f767bc2e to your computer and use it in GitHub Desktop.
Awesome WM: LCD Brightness lib
-- Handle brightness (with xbacklight)
local awful = require("awful")
local naughty = require("naughty")
local tonumber = tonumber
local string = string
local os = os
-- A bit odd, but...
require("lib/icons")
local icons = package.loaded["vbe/icons"]
module("snai/brightness")
local icon = icons.lookup({name = "computer-laptop",
type = "devices",
sizes = {'22x22', '16x16'}})
local nid = nil
local function change(what)
os.execute("xbacklight -time 50 -" .. what)
local out = awful.util.pread("xbacklight -get")
if not out then return end
out = tonumber(out)
nid = naughty.notify({ text = "Helligkeit " .. string.format("%3d %%", out),
font = "Free Sans Bold 12",
icon = icon,
replaces_id = nid }).id
end
function increase()
change("inc 5")
end
function decrease()
change("dec 5")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment