mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-23 02:08:35 +02:00
brightness: use gsd-backlight-helper instead of xbacklight
xbacklight is currently broken.
This commit is contained in:
parent
cfac99fcc6
commit
a7b63b1450
2 changed files with 24 additions and 11 deletions
|
@ -1,7 +1,8 @@
|
||||||
-- Handle brightness (with xbacklight)
|
-- Handle brightness (with gsd-backlight-helper)
|
||||||
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
|
local math = math
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local string = string
|
local string = string
|
||||||
local os = os
|
local os = os
|
||||||
|
@ -14,24 +15,37 @@ local icons = package.loaded["vbe/icons"]
|
||||||
module("vbe/brightness")
|
module("vbe/brightness")
|
||||||
|
|
||||||
local nid = nil
|
local nid = nil
|
||||||
local function change(what)
|
local function change(percent)
|
||||||
os.execute("xbacklight -" .. what)
|
local cmd = "pkexec /usr/lib/gnome-settings-daemon/gsd-backlight-helper"
|
||||||
local out = awful.util.pread("xbacklight -get")
|
|
||||||
if not out or out == "" then return end
|
-- Current value
|
||||||
out = tonumber(out)
|
local current = awful.util.pread(cmd .. " --get-brightness")
|
||||||
|
if not current or current == "" then return end
|
||||||
|
current = tonumber(current)
|
||||||
|
|
||||||
|
-- Maximum value
|
||||||
|
local max = tonumber(awful.util.pread(cmd .. " --get-max-brightness"))
|
||||||
|
|
||||||
|
-- Set new value
|
||||||
|
local target = math.floor(current + percent*max / 100)
|
||||||
|
target = math.max(0, target)
|
||||||
|
target = math.min(max, target)
|
||||||
|
os.execute(cmd .. " --set-brightness " .. target)
|
||||||
|
current = tonumber(awful.util.pread(cmd .. " --get-brightness"))
|
||||||
|
|
||||||
local icon = icons.lookup({name = "display-brightness",
|
local icon = icons.lookup({name = "display-brightness",
|
||||||
type = "status"})
|
type = "status"})
|
||||||
|
|
||||||
nid = naughty.notify({ text = string.format("%3d %%", out),
|
nid = naughty.notify({ text = string.format("%3d %%", current * 100 / max),
|
||||||
icon = icon,
|
icon = icon,
|
||||||
font = "Free Sans Bold 24",
|
font = "Free Sans Bold 24",
|
||||||
replaces_id = nid }).id
|
replaces_id = nid }).id
|
||||||
end
|
end
|
||||||
|
|
||||||
function increase()
|
function increase()
|
||||||
change("inc 5")
|
change(5)
|
||||||
end
|
end
|
||||||
|
|
||||||
function decrease()
|
function decrease()
|
||||||
change("dec 5")
|
change(-5)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ awesome
|
||||||
awesome-extra
|
awesome-extra
|
||||||
i3lock
|
i3lock
|
||||||
xss-lock
|
xss-lock
|
||||||
xbacklight
|
gnome-settings-daemon
|
||||||
libnotify-bin
|
libnotify-bin
|
||||||
xfonts-terminus
|
xfonts-terminus
|
||||||
ttf-dejavu
|
ttf-dejavu
|
||||||
|
@ -21,4 +21,3 @@ pidgin
|
||||||
gnome-bluetooth
|
gnome-bluetooth
|
||||||
pulseaudio
|
pulseaudio
|
||||||
numlockx
|
numlockx
|
||||||
evilvte
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue