Compare commits

..

No commits in common. "90804f75bb9bc364f760293580f2e54c5de96e40" and "84cfee9afa4a2d260b75492b5307d68ffccfa74d" have entirely different histories.

2 changed files with 47 additions and 5 deletions

View File

@ -0,0 +1,37 @@
#!/usr/bin/fish
#
# Usage:
# backlight get
# backlight set [value]
# backlight max
#
# Returns:
# Set - nothing
# Get, max - Number between 0 and 100 (eg: 0, 25.445283, 100)
#
function backlight
switch $argv[1]
case "get"
xbacklight -get
case "max"
echo 100
case "set"
xbacklight -set $argv[2]
case "up"
xbacklight -inc $argv[2]
case "down"
xbacklight -dec $argv[2]
case "*"
echo "Unknown function \"$argv[1]\""
echo ""
echo "Usage:"
echo " backlight get"
echo " backlight set [value]"
echo " backlight max"
return 0
end
return 1
end
backlight $argv

View File

@ -1,8 +1,13 @@
local backlight = {}
-- The space at the end is important!
local script = conf_dir .. "modules/backlight/backlight.fish"
script = script .. " "
backlight.get = function(callback)
awful.spawn.easy_async(
"xbacklight -get",
script .. "get",
function(stdout, stderr, exitreason, exitcode)
callback(tonumber(stdout))
end
@ -10,12 +15,12 @@ backlight.get = function(callback)
end
backlight.set = function(value)
awful.spawn("xbacklight -set " .. value, false)
awful.spawn(script .. "set " .. value, false)
end
backlight.watch = function(timeout, callback, widget)
awful.widget.watch(
"xbacklight -get",
script .. "get",
timeout,
callback,
widget
@ -25,7 +30,7 @@ end
backlight.backlight_up = function(value)
awful.spawn.easy_async(
"xbacklight -inc " .. value,
script .. "up " .. value,
function(stdout, stderr, exitreason, exitcode)
awesome.emit_signal("module::backlight:update_read")
end
@ -34,7 +39,7 @@ end
backlight.backlight_down = function(value)
awful.spawn.easy_async(
"xbacklight -dec " .. value,
script .. "down " .. value,
function(stdout, stderr, exitreason, exitcode)
awesome.emit_signal("module::backlight:update_read")
end