Merge branch 'master' into update-brightnessctl
This commit is contained in:
commit
fc7d966cb9
|
@ -125,7 +125,7 @@ local function worker(user_args)
|
|||
local battery_info = {}
|
||||
local capacities = {}
|
||||
for s in stdout:gmatch("[^\r\n]+") do
|
||||
local status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
|
||||
local status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
|
||||
if status ~= nil then
|
||||
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
|
||||
else
|
||||
|
|
|
@ -39,6 +39,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | Icon of the warning popup |
|
||||
| `enable_battery_warning` | `true` | Display low battery warning |
|
||||
| `show_notification_mode` | `on_hover` | How to trigger a notification with the battery status: `on_hover`, `on_click` or `off` |
|
||||
| `notification_position` | `top_left` | Where to show she notification when triggered. Values: `top_right`, `top_left`, `bottom_left`, `bottom_right`, `top_middle`, `bottom_middle`. (default `top_right`) |
|
||||
|
||||
## Requirements
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ local function worker(user_args)
|
|||
local size = args.size or 18
|
||||
local timeout = args.timeout or 10
|
||||
local show_notification_mode = args.show_notification_mode or 'on_hover' -- on_hover / on_click
|
||||
local notification_position = args.notification_position or 'top_right' -- see naughty.notify position argument
|
||||
|
||||
local main_color = args.main_color or beautiful.fg_color
|
||||
local bg_color = args.bg_color or '#ffffff11'
|
||||
|
@ -89,7 +90,7 @@ local function worker(user_args)
|
|||
local charge = 0
|
||||
local status
|
||||
for s in stdout:gmatch("[^\r\n]+") do
|
||||
local cur_status, charge_str, _ = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
|
||||
local cur_status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
|
||||
if cur_status ~= nil and charge_str ~=nil then
|
||||
local cur_charge = tonumber(charge_str)
|
||||
if cur_charge > charge then
|
||||
|
@ -146,6 +147,7 @@ local function worker(user_args)
|
|||
title = "Battery status",
|
||||
timeout = 5,
|
||||
width = 200,
|
||||
position = notification_position,
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `step` | 5 | Step |
|
||||
| `base` | 20 | Base level to set brightness to on left click. |
|
||||
| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon |
|
||||
| `font` | `Play 9` | Font |
|
||||
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
|
||||
| `timeout` | 1 | How often in seconds the widget refreshes. Check the note below |
|
||||
| `tooltip` | false | Display brightness level in a tooltip when the mouse cursor hovers the widget |
|
||||
| `percentage` | false | Display a '%' character after the brightness level |
|
||||
|
|
|
@ -14,6 +14,7 @@ local watch = require("awful.widget.watch")
|
|||
local spawn = require("awful.spawn")
|
||||
local gfs = require("gears.filesystem")
|
||||
local naughty = require("naughty")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
local ICON_DIR = gfs.get_configuration_dir() .. "awesome-wm-widgets/brightness-widget/"
|
||||
local get_brightness_cmd
|
||||
|
@ -32,164 +33,159 @@ local function show_warning(message)
|
|||
end
|
||||
|
||||
local function worker(user_args)
|
||||
local args = user_args or {}
|
||||
local args = user_args or {}
|
||||
|
||||
local type = args.type or "arc" -- arc or icon_and_text
|
||||
local path_to_icon = args.path_to_icon or ICON_DIR .. "brightness.svg"
|
||||
local font = args.font or "Play 9"
|
||||
local timeout = args.timeout or 100
|
||||
local type = args.type or 'arc' -- arc or icon_and_text
|
||||
local path_to_icon = args.path_to_icon or ICON_DIR .. 'brightness.svg'
|
||||
local font = args.font or beautiful.font
|
||||
local timeout = args.timeout or 100
|
||||
|
||||
local program = args.program or "light"
|
||||
local step = args.step or 5
|
||||
local base = args.base or 20
|
||||
local current_level = 0 -- current brightness value
|
||||
local tooltip = args.tooltip or false
|
||||
local percentage = args.percentage or false
|
||||
if program == "light" then
|
||||
get_brightness_cmd = "light -G"
|
||||
set_brightness_cmd = "light -S %d" -- <level>
|
||||
inc_brightness_cmd = "light -A " .. step
|
||||
dec_brightness_cmd = "light -U " .. step
|
||||
elseif program == "xbacklight" then
|
||||
get_brightness_cmd = "xbacklight -get"
|
||||
set_brightness_cmd = "xbacklight -set %d" -- <level>
|
||||
inc_brightness_cmd = "xbacklight -inc " .. step
|
||||
dec_brightness_cmd = "xbacklight -dec " .. step
|
||||
elseif program == "brightnessctl" then
|
||||
get_brightness_cmd = "brightnessctl get"
|
||||
local program = args.program or 'light'
|
||||
local step = args.step or 5
|
||||
local base = args.base or 20
|
||||
local current_level = 0 -- current brightness value
|
||||
local tooltip = args.tooltip or false
|
||||
local percentage = args.percentage or false
|
||||
if program == 'light' then
|
||||
get_brightness_cmd = 'light -G'
|
||||
set_brightness_cmd = 'light -S %d' -- <level>
|
||||
inc_brightness_cmd = 'light -A ' .. step
|
||||
dec_brightness_cmd = 'light -U ' .. step
|
||||
elseif program == 'xbacklight' then
|
||||
get_brightness_cmd = 'xbacklight -get'
|
||||
set_brightness_cmd = 'xbacklight -set %d' -- <level>
|
||||
inc_brightness_cmd = 'xbacklight -inc ' .. step
|
||||
dec_brightness_cmd = 'xbacklight -dec ' .. step
|
||||
elseif program == 'brightnessctl' then
|
||||
get_brightness_cmd = "brightnessctl get"
|
||||
set_brightness_cmd = "brightnessctl set %d%%" -- <level>
|
||||
inc_brightness_cmd = "brightnessctl set +" .. step .. "%"
|
||||
dec_brightness_cmd = "brightnessctl set " .. step .. "-%"
|
||||
else
|
||||
show_warning(program .. " command is not supported by the widget")
|
||||
return
|
||||
end
|
||||
else
|
||||
show_warning(program .. " command is not supported by the widget")
|
||||
return
|
||||
end
|
||||
|
||||
if type == "icon_and_text" then
|
||||
brightness_widget.widget = wibox.widget({
|
||||
{
|
||||
{
|
||||
image = path_to_icon,
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
valign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
{
|
||||
id = "txt",
|
||||
font = font,
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = 4,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
set_value = function(self, level)
|
||||
local display_level = level
|
||||
if percentage then
|
||||
display_level = display_level .. "%"
|
||||
end
|
||||
self:get_children_by_id("txt")[1]:set_text(display_level)
|
||||
end,
|
||||
})
|
||||
elseif type == "arc" then
|
||||
brightness_widget.widget = wibox.widget({
|
||||
{
|
||||
{
|
||||
image = path_to_icon,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
valign = "center",
|
||||
layout = wibox.container.place,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = 2,
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
forced_height = 18,
|
||||
forced_width = 18,
|
||||
paddings = 2,
|
||||
widget = wibox.container.arcchart,
|
||||
set_value = function(self, level)
|
||||
self:set_value(level)
|
||||
end,
|
||||
})
|
||||
else
|
||||
show_warning(type .. " type is not supported by the widget")
|
||||
return
|
||||
end
|
||||
if type == 'icon_and_text' then
|
||||
brightness_widget.widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
image = path_to_icon,
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
valign = 'center',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
{
|
||||
id = 'txt',
|
||||
font = font,
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = 4,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
set_value = function(self, level)
|
||||
local display_level = level
|
||||
if percentage then
|
||||
display_level = display_level .. '%'
|
||||
end
|
||||
self:get_children_by_id('txt')[1]:set_text(display_level)
|
||||
end
|
||||
}
|
||||
elseif type == 'arc' then
|
||||
brightness_widget.widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
image = path_to_icon,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
valign = 'center',
|
||||
layout = wibox.container.place
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = 2,
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
forced_height = 18,
|
||||
forced_width = 18,
|
||||
paddings = 2,
|
||||
widget = wibox.container.arcchart,
|
||||
set_value = function(self, level)
|
||||
self:set_value(level)
|
||||
end
|
||||
}
|
||||
else
|
||||
show_warning(type .. " type is not supported by the widget")
|
||||
return
|
||||
|
||||
local update_widget = function(widget, stdout, _, _, _)
|
||||
local brightness_level = tonumber(string.format("%.0f", stdout))
|
||||
current_level = brightness_level
|
||||
widget:set_value(brightness_level)
|
||||
end
|
||||
end
|
||||
|
||||
function brightness_widget:set(value)
|
||||
current_level = value
|
||||
spawn.easy_async(string.format(set_brightness_cmd, value), function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
local old_level = 0
|
||||
function brightness_widget:toggle()
|
||||
if old_level < 0.1 then
|
||||
-- avoid toggling between '0' and 'almost 0'
|
||||
old_level = 1
|
||||
end
|
||||
if current_level < 0.1 then
|
||||
-- restore previous level
|
||||
current_level = old_level
|
||||
else
|
||||
-- save current brightness for later
|
||||
old_level = current_level
|
||||
current_level = 0
|
||||
end
|
||||
brightness_widget:set(current_level)
|
||||
end
|
||||
function brightness_widget:inc()
|
||||
spawn.easy_async(inc_brightness_cmd, function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
function brightness_widget:dec()
|
||||
spawn.easy_async(dec_brightness_cmd, function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
local update_widget = function(widget, stdout, _, _, _)
|
||||
local brightness_level = tonumber(string.format("%.0f", stdout))
|
||||
current_level = brightness_level
|
||||
widget:set_value(brightness_level)
|
||||
end
|
||||
|
||||
brightness_widget.widget:buttons(awful.util.table.join(
|
||||
awful.button({}, 1, function()
|
||||
brightness_widget:set(base)
|
||||
end),
|
||||
awful.button({}, 3, function()
|
||||
brightness_widget:toggle()
|
||||
end),
|
||||
awful.button({}, 4, function()
|
||||
brightness_widget:inc()
|
||||
end),
|
||||
awful.button({}, 5, function()
|
||||
brightness_widget:dec()
|
||||
end)
|
||||
))
|
||||
function brightness_widget:set(value)
|
||||
current_level = value
|
||||
spawn.easy_async(string.format(set_brightness_cmd, value), function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
local old_level = 0
|
||||
function brightness_widget:toggle()
|
||||
if old_level < 0.1 then
|
||||
-- avoid toggling between '0' and 'almost 0'
|
||||
old_level = 1
|
||||
end
|
||||
if current_level < 0.1 then
|
||||
-- restore previous level
|
||||
current_level = old_level
|
||||
else
|
||||
-- save current brightness for later
|
||||
old_level = current_level
|
||||
current_level = 0
|
||||
end
|
||||
brightness_widget:set(current_level)
|
||||
end
|
||||
function brightness_widget:inc()
|
||||
spawn.easy_async(inc_brightness_cmd, function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
function brightness_widget:dec()
|
||||
spawn.easy_async(dec_brightness_cmd, function()
|
||||
spawn.easy_async(get_brightness_cmd, function(out)
|
||||
update_widget(brightness_widget.widget, out)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
watch(get_brightness_cmd, timeout, update_widget, brightness_widget.widget)
|
||||
brightness_widget.widget:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, 1, function() brightness_widget:set(base) end),
|
||||
awful.button({}, 3, function() brightness_widget:toggle() end),
|
||||
awful.button({}, 4, function() brightness_widget:inc() end),
|
||||
awful.button({}, 5, function() brightness_widget:dec() end)
|
||||
)
|
||||
)
|
||||
|
||||
if tooltip then
|
||||
awful.tooltip({
|
||||
objects = { brightness_widget.widget },
|
||||
timer_function = function()
|
||||
return current_level .. " %"
|
||||
end,
|
||||
})
|
||||
end
|
||||
watch(get_brightness_cmd, timeout, update_widget, brightness_widget.widget)
|
||||
|
||||
return brightness_widget.widget
|
||||
if tooltip then
|
||||
awful.tooltip {
|
||||
objects = { brightness_widget.widget },
|
||||
timer_function = function()
|
||||
return current_level .. " %"
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
return brightness_widget.widget
|
||||
end
|
||||
|
||||
return setmetatable(brightness_widget, {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
|
@ -45,7 +45,7 @@ It is possible to customize the widget by providing a table with all or some of
|
|||
|
||||
| Name | Default | Description |
|
||||
|---|---|---|
|
||||
| `font` | `Play 9` | Font used for the track title |
|
||||
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
|
||||
| `path_to_icons` | `/usr/share/icons/Arc/actions/symbolic/` | Alternative path for the icons |
|
||||
| `timeout`| `10` | Refresh cooldown |
|
||||
| `space` | `3` | Space between icon and track title |
|
||||
|
|
|
@ -10,21 +10,14 @@ local awful = require("awful")
|
|||
local wibox = require("wibox")
|
||||
local watch = require("awful.widget.watch")
|
||||
local spawn = require("awful.spawn")
|
||||
local naughty = require("naughty")
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local cmus_widget = {}
|
||||
|
||||
local function show_warning(message)
|
||||
naughty.notify{
|
||||
preset = naughty.config.presets.critical,
|
||||
title = "Cmus Widget",
|
||||
text = message}
|
||||
end
|
||||
|
||||
local function worker(user_args)
|
||||
|
||||
local args = user_args or {}
|
||||
local font = args.font or "Play 9"
|
||||
local font = args.font or beautiful.font
|
||||
|
||||
local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/actions/symbolic/"
|
||||
local timeout = args.timeout or 10
|
||||
|
@ -44,6 +37,7 @@ local function worker(user_args)
|
|||
font = font,
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = space,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
update_icon = function(self, name)
|
||||
self:get_children_by_id("playback_icon")[1]:set_image(path_to_icons .. name)
|
||||
|
@ -53,7 +47,7 @@ local function worker(user_args)
|
|||
end
|
||||
}
|
||||
|
||||
function update_widget(widget, stdout, _, _, code)
|
||||
local function update_widget(widget, stdout, _, _, code)
|
||||
if code == 0 then
|
||||
local cmus_info = {}
|
||||
|
||||
|
@ -63,12 +57,12 @@ local function worker(user_args)
|
|||
if key and val then
|
||||
cmus_info[key] = val
|
||||
else
|
||||
local key, val = string.match(s, "^set (%a+) (.+)$")
|
||||
key, val = string.match(s, "^set (%a+) (.+)$")
|
||||
|
||||
if key and val then
|
||||
cmus_info[key] = val
|
||||
else
|
||||
local key, val = string.match(s, "^(%a+) (.+)$")
|
||||
key, val = string.match(s, "^(%a+) (.+)$")
|
||||
if key and val then
|
||||
cmus_info[key] = val
|
||||
end
|
||||
|
@ -96,7 +90,6 @@ local function worker(user_args)
|
|||
widget.visible = true
|
||||
else
|
||||
widget.visible = false
|
||||
widget.width = 0
|
||||
end
|
||||
else
|
||||
widget.visible = false
|
||||
|
|
|
@ -15,6 +15,8 @@ It is possible to customize widget by providing a table with all or some of the
|
|||
| `color_used` | `beautiful.bg_urgent` | Color for used RAM |
|
||||
| `color_free` | `beautiful.fg_normal` | Color for free RAM |
|
||||
| `color_buf` | `beautiful.border_color_active` | Color for buffers/cache |
|
||||
| `widget_height` | `25` | Height of the widget |
|
||||
| `widget_width` | `25` | Width of the widget |
|
||||
| `widget_show_buf` | `false` | Whether to display buffers/cache separately in the tray widget. If `false`, buffers/cache are considered free RAM. |
|
||||
| `timeout` | 1 | How often (in seconds) the widget refreshes |
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ local function worker(user_args)
|
|||
local color_free = args.color_free or beautiful.fg_normal
|
||||
local color_buf = args.color_buf or beautiful.border_color_active
|
||||
local widget_show_buf = args.widget_show_buf or false
|
||||
local widget_height = args.widget_height or 25
|
||||
local widget_width = args.widget_width or 25
|
||||
|
||||
--- Main ram widget shown on wibar
|
||||
ramgraph_widget = wibox.widget {
|
||||
|
@ -25,7 +27,8 @@ local function worker(user_args)
|
|||
color_buf,
|
||||
},
|
||||
display_labels = false,
|
||||
forced_width = 25,
|
||||
forced_height = widget_height,
|
||||
forced_width = widget_width,
|
||||
widget = wibox.widget.piechart
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue