Added backlight module
parent
8e8c4840da
commit
3014105bbf
30
bin/init.lua
30
bin/init.lua
|
@ -17,36 +17,6 @@ return {
|
|||
end
|
||||
},
|
||||
|
||||
backlight = {
|
||||
watch = function(timeout, callback, widget)
|
||||
awful.widget.watch(script_dir .. "backlight get", timeout, callback, widget)
|
||||
end,
|
||||
|
||||
get = function(callback)
|
||||
awful.spawn.easy_async(script_dir .. "backlight get", callback)
|
||||
end,
|
||||
|
||||
set = function(value)
|
||||
awful.spawn(script_dir .. "backlight set " .. value, false)
|
||||
end,
|
||||
|
||||
up = function()
|
||||
awful.spawn(script_dir .. "backlight up", false)
|
||||
end,
|
||||
|
||||
down = function()
|
||||
awful.spawn(script_dir .. "backlight down", false)
|
||||
end,
|
||||
|
||||
redshift = function(temp)
|
||||
awful.spawn("redshift -O " .. tostring(temp), false)
|
||||
end,
|
||||
|
||||
redshift_reset = function()
|
||||
awful.spawn("redshift -x", false)
|
||||
end,
|
||||
},
|
||||
|
||||
battery = {
|
||||
watch = function(timeout, callback, widget)
|
||||
awful.widget.watch(script_dir .. "battery", timeout, callback, widget)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
return {
|
||||
keys = gears.table.join(
|
||||
require("binds.system.backlight"),
|
||||
require("binds.system.system"),
|
||||
|
||||
require("binds.window.client"),
|
||||
|
|
|
@ -10,7 +10,6 @@ local desktop = {
|
|||
tagindicator = require("desktop.widgets.tagindicator"),
|
||||
launcher = require("desktop.widgets.launcher"),
|
||||
shortcut = require("desktop.widgets.shortcut"),
|
||||
--winstat = require("desktop.widgets.window_status"),
|
||||
|
||||
space = function(size)
|
||||
return wibox.widget {
|
||||
|
@ -45,7 +44,7 @@ local desktop = {
|
|||
|
||||
-- Load conditional modules
|
||||
if conf.backlight_enabled then
|
||||
desktop.widgets.backlight = require("desktop.widgets.backlight")
|
||||
desktop.widgets.backlight = modules.backlight.widgets.backlight
|
||||
end
|
||||
if conf.battery_enabled then
|
||||
desktop.widgets.battery = require("desktop.widgets.battery")
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
local backlight = {}
|
||||
|
||||
|
||||
backlight.icon = wibox.widget {
|
||||
id = "icon",
|
||||
image = beautiful.icons.brightness.i,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
backlight.arc = wibox.widget {
|
||||
{
|
||||
backlight.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
|
||||
backlight.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{ -- Main indicator. Can be replaced with backlight.arc
|
||||
backlight.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
backlight.widget:connect_signal("mouse::enter", function(result)
|
||||
backlight.widget.bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
backlight.widget:connect_signal("mouse::leave", function(result)
|
||||
backlight.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
backlight.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
-- Scroll up
|
||||
if (button == 4) then
|
||||
wrapper.backlight.up()
|
||||
-- Scroll down
|
||||
elseif (button == 5) then
|
||||
wrapper.backlight.down()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
backlight.update = function(value)
|
||||
backlight.arc.value = value
|
||||
|
||||
--[[if value > 90 then backlight.icon.image = beautiful.icons.brightness.i
|
||||
elseif value > 80 then backlight.icon.image = beautiful.icons.brightness.h
|
||||
elseif value > 70 then backlight.icon.image = beautiful.icons.brightness.g
|
||||
elseif value > 60 then backlight.icon.image = beautiful.icons.brightness.f
|
||||
elseif value > 50 then backlight.icon.image = beautiful.icons.brightness.e
|
||||
elseif value > 40 then backlight.icon.image = beautiful.icons.brightness.d
|
||||
elseif value > 30 then backlight.icon.image = beautiful.icons.brightness.c
|
||||
elseif value > 20 then backlight.icon.image = beautiful.icons.brightness.b
|
||||
elseif value <= 10 then backlight.icon.image = beautiful.icons.brightness.a end
|
||||
--]]
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Add various hooks
|
||||
wrapper.backlight.add_hook(backlight.update)
|
||||
bin.backlight.watch(
|
||||
5,
|
||||
function()
|
||||
wrapper.backlight.read(backlight.update)
|
||||
end,
|
||||
backlight.widget
|
||||
)
|
||||
|
||||
return backlight.widget
|
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
widgets = {
|
||||
backlight = require("modules.backlight.widget").widget
|
||||
},
|
||||
keybinds = require("modules.backlight.keybinds"),
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
local backlight = req_rel(..., "util")
|
||||
|
||||
return gears.table.join(
|
||||
awful.key( {}, "XF86MonBrightnessUp",
|
||||
function ()
|
||||
wrapper.backlight.up()
|
||||
backlight.backlight_up()
|
||||
end,
|
||||
{
|
||||
description = "Raise brightness",
|
||||
|
@ -11,7 +13,7 @@ return gears.table.join(
|
|||
|
||||
awful.key( {}, "XF86MonBrightnessDown",
|
||||
function ()
|
||||
wrapper.backlight.down()
|
||||
backlight.backlight_down()
|
||||
end,
|
||||
{
|
||||
description = "Lower brightness",
|
||||
|
@ -21,7 +23,7 @@ return gears.table.join(
|
|||
|
||||
awful.key( { "Mod4" }, "o",
|
||||
function ()
|
||||
bin.backlight.redshift(5600)
|
||||
backlight.redshift(5600)
|
||||
end,
|
||||
{
|
||||
description = "Default redshift",
|
||||
|
@ -31,7 +33,7 @@ return gears.table.join(
|
|||
|
||||
awful.key( { "Mod4", "Shift" }, "o",
|
||||
function ()
|
||||
bin.backlight.redshift_reset()
|
||||
backlight.reset_redshift()
|
||||
end,
|
||||
{
|
||||
description = "Reset redshift",
|
||||
|
@ -41,11 +43,11 @@ return gears.table.join(
|
|||
|
||||
awful.key( { "Mod4", "Shift", "Control" }, "o",
|
||||
function ()
|
||||
bin.backlight.redshift_reset()
|
||||
backlight.reset_redshift()
|
||||
awful.prompt.run {
|
||||
prompt = "<b>Color temperature: </b>",
|
||||
textbox = awful.screen.focused().mypromptbox.widget,
|
||||
exe_callback = bin.backlight.redshift
|
||||
exe_callback = backlight.redshift
|
||||
}
|
||||
end,
|
||||
{
|
|
@ -0,0 +1,62 @@
|
|||
local backlight = {}
|
||||
|
||||
-- The space at the end is important!
|
||||
local script = configuration_dir .. "modules/backlight/backlight.fish"
|
||||
script = script .. " "
|
||||
|
||||
backlight.hooks = {}
|
||||
backlight.add_hook = function(callback)
|
||||
backlight.hooks[#backlight.hooks + 1] = callback
|
||||
end
|
||||
|
||||
backlight.exec_hooks = function()
|
||||
backlight.read(function(status)
|
||||
for i=1, #backlight.hooks do
|
||||
backlight.hooks[i](status)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
backlight.read = function(callback)
|
||||
awful.spawn.easy_async(
|
||||
script .. "get",
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
callback(tonumber(stdout))
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
backlight.set = function(value)
|
||||
awful.spawn(script .. "set " .. value, false)
|
||||
end
|
||||
|
||||
backlight.watch = function(timeout, callback, widget)
|
||||
awful.widget.watch(
|
||||
script .. "get",
|
||||
timeout,
|
||||
callback,
|
||||
widget
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
backlight.backlight_up = function()
|
||||
awful.spawn(script .. "up", false)
|
||||
backlight.exec_hooks()
|
||||
end
|
||||
|
||||
backlight.backlight_down = function()
|
||||
awful.spawn(script .. "down", false)
|
||||
backlight.exec_hooks()
|
||||
end
|
||||
|
||||
backlight.redshift = function(temp)
|
||||
awful.spawn("redshift -O " .. tostring(temp), false)
|
||||
end
|
||||
|
||||
backlight.reset_redshift = function()
|
||||
awful.spawn("redshift -x", false)
|
||||
end
|
||||
|
||||
|
||||
return backlight
|
|
@ -0,0 +1,101 @@
|
|||
local backlight = req_rel(..., "util")
|
||||
local widget = {}
|
||||
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
id = "icon",
|
||||
image = beautiful.icons.brightness.i,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
widget.arc = wibox.widget {
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{ -- Main indicator. Can be replaced with widget.arc
|
||||
widget.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
widget.widget:connect_signal("mouse::enter", function(result)
|
||||
widget.widget.bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("mouse::leave", function(result)
|
||||
widget.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
-- Scroll up
|
||||
if (button == 4) then
|
||||
backlight.backlight_up()
|
||||
-- Scroll down
|
||||
elseif (button == 5) then
|
||||
backlight.backlight_down()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
widget.update = function(value)
|
||||
widget.arc.value = value
|
||||
|
||||
--[[if value > 90 then widget.icon.image = beautiful.icons.brightness.i
|
||||
elseif value > 80 then widget.icon.image = beautiful.icons.brightness.h
|
||||
elseif value > 70 then widget.icon.image = beautiful.icons.brightness.g
|
||||
elseif value > 60 then widget.icon.image = beautiful.icons.brightness.f
|
||||
elseif value > 50 then widget.icon.image = beautiful.icons.brightness.e
|
||||
elseif value > 40 then widget.icon.image = beautiful.icons.brightness.d
|
||||
elseif value > 30 then widget.icon.image = beautiful.icons.brightness.c
|
||||
elseif value > 20 then widget.icon.image = beautiful.icons.brightness.b
|
||||
elseif value <= 10 then widget.icon.image = beautiful.icons.brightness.a end
|
||||
--]]
|
||||
|
||||
end
|
||||
|
||||
|
||||
backlight.add_hook(widget.update)
|
||||
backlight.watch(
|
||||
5,
|
||||
function()
|
||||
backlight.read(widget.update)
|
||||
end,
|
||||
widget.widget
|
||||
)
|
||||
|
||||
return widget
|
1
rc.lua
1
rc.lua
|
@ -31,7 +31,6 @@ layoutmanager = require("desktop.layoutmanager")
|
|||
layoutmanager.layouts = conf.layouts
|
||||
|
||||
bin = require("bin")
|
||||
wrapper = require("wrapper")
|
||||
|
||||
|
||||
beautiful.init(require("theme"))
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
local backlight = {}
|
||||
|
||||
|
||||
backlight.hooks = {}
|
||||
backlight.add_hook = function(callback)
|
||||
backlight.hooks[#backlight.hooks + 1] = callback
|
||||
end
|
||||
|
||||
backlight.exec_hooks = function()
|
||||
backlight.read(function(status)
|
||||
for i=1, #backlight.hooks do
|
||||
backlight.hooks[i](status)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
backlight.read = function(callback)
|
||||
bin.backlight.get(
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
callback(tonumber(stdout))
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
backlight.up = function()
|
||||
bin.backlight.up()
|
||||
backlight.exec_hooks()
|
||||
end
|
||||
|
||||
backlight.down = function()
|
||||
bin.backlight.down()
|
||||
backlight.exec_hooks()
|
||||
end
|
||||
|
||||
return backlight
|
|
@ -1,3 +0,0 @@
|
|||
return {
|
||||
backlight = require("wrapper.backlight")
|
||||
}
|
Loading…
Reference in New Issue