Bring master more in line with Laptop

This commit is contained in:
Thomas Avé 2023-05-08 13:35:23 +02:00
parent 2b598d3efd
commit 82c30ed921
5 changed files with 2286 additions and 2238 deletions

View File

@ -208,6 +208,13 @@ 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()
@ -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"}
), ),

View File

@ -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)
end
-- Match a line where capacity is reported
local cap_str = string.match(s, '.+:.+last full capacity (%d+)') local cap_str = string.match(s, '.+:.+last full capacity (%d+)')
table.insert(capacities, tonumber(cap_str)) 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

View File

@ -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

View File

@ -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)

View File

@ -1160,11 +1160,16 @@ function osc_init()
if (mp.get_property('video') == 'no') then -- dummy/forced window if (mp.get_property('video') == 'no') then -- dummy/forced window
user_opts.visibility = "always" user_opts.visibility = "always"
<<<<<<< HEAD
user_opts.last_visibility = "always"
visibility_mode('always', true)
=======
<<<<<<< HEAD <<<<<<< HEAD
======= =======
user_opts.last_visibility = "always" user_opts.last_visibility = "always"
visibility_mode('always', true) visibility_mode('always', true)
>>>>>>> a21cfe5 (Fix OSC when playing audio) >>>>>>> a21cfe5 (Fix OSC when playing audio)
>>>>>>> master
scale = user_opts.scaleforcedwindow scale = user_opts.scaleforcedwindow
elseif state.fullscreen then elseif state.fullscreen then
scale = user_opts.scalefullscreen scale = user_opts.scalefullscreen
@ -1646,6 +1651,11 @@ function pause_state(name, enabled)
visibility_mode('always', true) visibility_mode('always', true)
show_osc() show_osc()
else else
<<<<<<< HEAD
if (mp.get_property('video') ~= 'no') then
visibility_mode(state.lastvisibility, true)
end
=======
<<<<<<< HEAD <<<<<<< HEAD
visibility_mode(state.lastvisibility, true) visibility_mode(state.lastvisibility, true)
======= =======
@ -1653,6 +1663,7 @@ function pause_state(name, enabled)
visibility_mode(state.lastvisibility, true) visibility_mode(state.lastvisibility, true)
end end
>>>>>>> a21cfe5 (Fix OSC when playing audio) >>>>>>> a21cfe5 (Fix OSC when playing audio)
>>>>>>> master
end end
end end
request_tick() request_tick()