Last active
October 31, 2015 17:46
-
-
Save josefnpat/b813b8ed089f47f37753 to your computer and use it in GitHub Desktop.
Simple screen brightness app that leverages xbacklight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function love.conf(t) | |
t.version = "0.9.2" | |
t.window.title = "Screen Brightness" | |
t.window.width = 400 | |
t.window.height = 32 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local temp_file = "xbacklight" | |
function love.load() | |
love.filesystem.write(temp_file,"0") | |
os.execute("xbacklight > \""..love.filesystem.getSaveDirectory().."\"/".. | |
temp_file) | |
current = love.filesystem.read(temp_file)/100 or 0 | |
end | |
function love.draw() | |
love.graphics.rectangle("fill",0,0, | |
current*love.graphics.getWidth(), | |
love.graphics.getHeight()) | |
end | |
function love.mousepressed(x,y,button) | |
current = x/love.graphics.getWidth() | |
os.execute("xbacklight -set "..math.floor(current*100)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment