Bring master more in line with Laptop
This commit is contained in:
parent
2b598d3efd
commit
82c30ed921
|
@ -208,24 +208,31 @@ keys.globalkeys = gears.table.join(
|
||||||
{description = "-10%", group = "hotkeys"}
|
{description = "-10%", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
|
|
||||||
|
-- Brightness
|
||||||
|
awful.key({ }, "XF86MonBrightnessDown", function ()
|
||||||
|
awful.util.spawn("xbacklight -dec 15") end),
|
||||||
|
|
||||||
|
awful.key({ }, "XF86MonBrightnessUp", function ()
|
||||||
|
awful.util.spawn("xbacklight -inc 15") end),
|
||||||
|
|
||||||
-- ALSA volume control
|
-- ALSA volume control
|
||||||
awful.key({}, "XF86AudioRaiseVolume",
|
awful.key({}, "XF86AudioRaiseVolume",
|
||||||
function()
|
function()
|
||||||
volume_widget:inc(5)
|
volume_widget:inc(5)
|
||||||
end,
|
end,
|
||||||
{description = "volume up", group = "hotkeys"}
|
{description = "volume up", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
awful.key({}, "XF86AudioLowerVolume",
|
awful.key({}, "XF86AudioLowerVolume",
|
||||||
function()
|
function()
|
||||||
volume_widget:dec(5)
|
volume_widget:dec(5)
|
||||||
end,
|
end,
|
||||||
{description = "volume down", group = "hotkeys"}
|
{description = "volume down", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
awful.key({}, "XF86AudioMute",
|
awful.key({}, "XF86AudioMute",
|
||||||
function()
|
function()
|
||||||
volume_widget:toggle()
|
volume_widget:toggle()
|
||||||
end,
|
end,
|
||||||
{description = "toggle mute", group = "hotkeys"}
|
{description = "toggle mute", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
awful.key({}, "XF86AudioNext",
|
awful.key({}, "XF86AudioNext",
|
||||||
function()
|
function()
|
||||||
|
@ -245,6 +252,24 @@ keys.globalkeys = gears.table.join(
|
||||||
end,
|
end,
|
||||||
{description = "play/pause music", group = "hotkeys"}
|
{description = "play/pause music", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
|
awful.key({modkey}, "XF86AudioMute",
|
||||||
|
function()
|
||||||
|
awful.spawn("playerctl play-pause", false)
|
||||||
|
end,
|
||||||
|
{description = "play/pause music", group = "hotkeys"}
|
||||||
|
),
|
||||||
|
awful.key({modkey}, "XF86AudioRaiseVolume",
|
||||||
|
function()
|
||||||
|
awful.spawn("playerctl next", false)
|
||||||
|
end,
|
||||||
|
{description = "volume up", group = "hotkeys"}
|
||||||
|
),
|
||||||
|
awful.key({modkey}, "XF86AudioLowerVolume",
|
||||||
|
function()
|
||||||
|
awful.spawn("playerctl previous", false)
|
||||||
|
end,
|
||||||
|
{description = "volume down", group = "hotkeys"}
|
||||||
|
),
|
||||||
|
|
||||||
-- Screenshot on prtscn using scrot
|
-- Screenshot on prtscn using scrot
|
||||||
awful.key({}, "Print",
|
awful.key({}, "Print",
|
||||||
|
@ -275,7 +300,7 @@ keys.globalkeys = gears.table.join(
|
||||||
awful.key({}, "XF86PowerOff",
|
awful.key({}, "XF86PowerOff",
|
||||||
function()
|
function()
|
||||||
-- emit signal to show the exit screen
|
-- emit signal to show the exit screen
|
||||||
awesome.emit_signal("show_exit_screen")
|
awful.util.spawn("rofi -show power-menu -modi power-menu:~/.config/awesome/scripts/rofi-power-menu")
|
||||||
end,
|
end,
|
||||||
{description = "toggle exit screen", group = "hotkeys"}
|
{description = "toggle exit screen", group = "hotkeys"}
|
||||||
),
|
),
|
||||||
|
|
|
@ -125,20 +125,25 @@ local function worker(user_args)
|
||||||
local battery_info = {}
|
local battery_info = {}
|
||||||
local capacities = {}
|
local capacities = {}
|
||||||
for s in stdout:gmatch("[^\r\n]+") do
|
for s in stdout:gmatch("[^\r\n]+") do
|
||||||
|
-- Match a line with status and charge level
|
||||||
local status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
|
local status, charge_str, _ = string.match(s, '.+: ([%a%s]+), (%d?%d?%d)%%,?(.*)')
|
||||||
if status ~= nil then
|
if status ~= nil then
|
||||||
|
-- Enforce that for each entry in battery_info there is an
|
||||||
|
-- entry in capacities of zero. If a battery has status
|
||||||
|
-- "Unknown" then there is no capacity reported and we treat it
|
||||||
|
-- as zero capactiy for later calculations.
|
||||||
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
|
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
|
||||||
else
|
table.insert(capacities, 0)
|
||||||
local cap_str = string.match(s, '.+:.+last full capacity (%d+)')
|
end
|
||||||
table.insert(capacities, tonumber(cap_str))
|
|
||||||
|
-- Match a line where capacity is reported
|
||||||
|
local cap_str = string.match(s, '.+:.+last full capacity (%d+)')
|
||||||
|
if cap_str ~= nil then
|
||||||
|
capacities[#capacities] = tonumber(cap_str) or 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local capacity = 0
|
local capacity = 0
|
||||||
for _, cap in ipairs(capacities) do
|
|
||||||
capacity = capacity + cap
|
|
||||||
end
|
|
||||||
|
|
||||||
local charge = 0
|
local charge = 0
|
||||||
local status
|
local status
|
||||||
for i, batt in ipairs(battery_info) do
|
for i, batt in ipairs(battery_info) do
|
||||||
|
@ -148,7 +153,11 @@ local function worker(user_args)
|
||||||
-- this is arbitrary, and maybe another metric should be used
|
-- this is arbitrary, and maybe another metric should be used
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Adds up total (capacity-weighted) charge and total capacity.
|
||||||
|
-- It effectively ignores batteries with status "Unknown" as we
|
||||||
|
-- treat them with capacity zero.
|
||||||
charge = charge + batt.charge * capacities[i]
|
charge = charge + batt.charge * capacities[i]
|
||||||
|
capacity = capacity + capacities[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
charge = charge / capacity
|
charge = charge / capacity
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
-- ████████╗ █████╗ ███████╗██╗ ██╗ ██╗ ██╗███████╗████████╗
|
-- ████████╗ █████╗ ███████╗██╗ ██╗ ██╗ ██╗███████╗████████╗
|
||||||
-- ╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ██║ ██║██╔════╝╚══██╔══╝
|
-- ╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ██║ ██║██╔════╝╚══██╔══╝
|
||||||
-- ██║ ███████║███████╗█████╔╝ ██║ ██║███████╗ ██║
|
-- ██║ ███████║███████╗█████╔╝ ██║ ██║███████╗ ██║
|
||||||
-- ██║ ██╔══██║╚════██║██╔═██╗ ██║ ██║╚════██║ ██║
|
-- ██║ ██╔══██║╚════██║██╔═██╗ ██║ ██║╚════██║ ██║
|
||||||
-- ██║ ██║ ██║███████║██║ ██╗ ███████╗██║███████║ ██║
|
-- ██║ ██║ ██║███████║██║ ██╗ ███████╗██║███████║ ██║
|
||||||
-- ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝╚═╝╚══════╝ ╚═╝
|
-- ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝╚═╝╚══════╝ ╚═╝
|
||||||
|
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- Initialization
|
-- Initialization
|
||||||
|
@ -59,12 +59,19 @@ local function list_update(w, buttons, label, data, objects)
|
||||||
for _ in pairs(objects) do
|
for _ in pairs(objects) do
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
|
local static_length = 16 * count
|
||||||
|
local total_text_length = 0
|
||||||
|
for _, o in ipairs(objects) do
|
||||||
|
total_text_length = total_text_length + o.name:len()
|
||||||
|
end
|
||||||
|
local truncate = (total_text_length + static_length) > 170
|
||||||
|
|
||||||
for i, o in ipairs(objects) do
|
for i, o in ipairs(objects) do
|
||||||
index = index + 1
|
index = index + 1
|
||||||
local ib, cb, tb, cbm, bgb, tbm, ibm, tt, l, ll
|
local ib, cb, tb, cbm, bgb, tbm, ibm, tt, l, ll
|
||||||
ib = wibox.widget.imagebox()
|
ib = wibox.widget.imagebox()
|
||||||
tb = wibox.widget.textbox()
|
tb = wibox.widget.textbox()
|
||||||
cb = wibox.container.margin(wibox.widget.imagebox(ICON_DIR .. "close.svg"), dpi(9), dpi(9), dpi(9), dpi(9))
|
cb = wibox.container.margin(wibox.widget.imagebox(ICON_DIR .. "close.svg"), dpi(9), dpi(0), dpi(9), dpi(9))
|
||||||
cb.shape = gears.shape.circle
|
cb.shape = gears.shape.circle
|
||||||
cbm = wibox.container.margin(cb, dpi(0), dpi(0), dpi(0), dpi(0)) -- 4, 8 ,12 ,12 -- close button
|
cbm = wibox.container.margin(cb, dpi(0), dpi(0), dpi(0), dpi(0)) -- 4, 8 ,12 ,12 -- close button
|
||||||
cbm:buttons(gears.table.join(awful.button({}, 1, nil,
|
cbm:buttons(gears.table.join(awful.button({}, 1, nil,
|
||||||
|
@ -114,10 +121,10 @@ local function list_update(w, buttons, label, data, objects)
|
||||||
else
|
else
|
||||||
-- truncate when title is too long
|
-- truncate when title is too long
|
||||||
local text_only = text:match('>(.*)<')
|
local text_only = text:match('>(.*)<')
|
||||||
local max_length = math.floor(220 / count)
|
local max_length = math.floor((155 - static_length) / count)
|
||||||
if (text_only:len() > max_length) then
|
if (truncate and text_only:len() > max_length) then
|
||||||
text = text:gsub('>(.*)<', '>' .. utf8.char(utf8.codepoint(text_only, 1, max_length)) .. '...<')
|
text = text:gsub('>(.*)<', '>' .. utf8.char(utf8.codepoint(text_only, 1, max_length)) .. '...<')
|
||||||
tt:set_text(text_only)
|
tt:set_text(text)
|
||||||
tt:add_to_object(tb)
|
tt:add_to_object(tb)
|
||||||
else
|
else
|
||||||
tt:remove_from_object(tb)
|
tt:remove_from_object(tb)
|
||||||
|
@ -138,10 +145,6 @@ local function list_update(w, buttons, label, data, objects)
|
||||||
ibm:set_margins(0)
|
ibm:set_margins(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
bgb.shape = args.shape
|
|
||||||
bgb.shape_border_width = args.shape_border_width
|
|
||||||
bgb.shape_border_color = args.shape_border_color
|
|
||||||
|
|
||||||
w:add(bgb)
|
w:add(bgb)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,7 +167,7 @@ local function worker(user_args)
|
||||||
local widget_type = args.widget_type
|
local widget_type = args.widget_type
|
||||||
local refresh_rate = args.refresh_rate or 1
|
local refresh_rate = args.refresh_rate or 1
|
||||||
local step = args.step or 5
|
local step = args.step or 5
|
||||||
local device = args.device or 'pulse'
|
local device = args.device or 'pipewire'
|
||||||
|
|
||||||
if widget_types[widget_type] == nil then
|
if widget_types[widget_type] == nil then
|
||||||
volume.widget = widget_types['icon_and_text'].get_widget(args.icon_and_text_args)
|
volume.widget = widget_types['icon_and_text'].get_widget(args.icon_and_text_args)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue