Big changes

This commit is contained in:
2022-04-14 00:35:06 +03:00
parent 5b218de55a
commit 9136f7ef3d
96 changed files with 1780 additions and 671 deletions

View File

@@ -5,7 +5,7 @@ local op = beautiful.flash_focus_start_opacity or 0.6
local stp = beautiful.flash_focus_step or 0.01
local flashfocus = function(c)
if c then
if c and #c.screen.clients > 1 then
c.opacity = op
local q = op
local g = gears.timer({

View File

@@ -293,10 +293,10 @@ function Scratchpad:turn_on()
animate_turn_on(self, anim_y, "y")
end
self:emit_signal("inital_apply", c1)
self.client.disconnect_signal("manage", inital_apply)
client.disconnect_signal("manage", inital_apply)
end
end
self.client.connect_signal("manage", inital_apply)
client.connect_signal("manage", inital_apply)
end
end
end

View File

@@ -53,36 +53,37 @@ function apply(wallpaper_object, args)
args.offset = args.offset or { x = 0, y = 0 }
args.scale = args.scale or 1
local positions = {
["centered"] = function()
["centered"] = function(s)
gears.wallpaper.centered(
wallpaper_object,
args.screen,
s,
args.background,
args.scale
)
end,
["tiled"] = function()
gears.wallpaper.tiled(wallpaper_object, args.screen, args.offset)
["tiled"] = function(s)
gears.wallpaper.tiled(wallpaper_object, s, args.offset)
end,
["maximized"] = function()
["maximized"] = function(s)
gears.wallpaper.maximized(
wallpaper_object,
args.screen,
s,
args.ignore_aspect,
args.offset
)
end,
["fit"] = function()
gears.wallpaper.fit(wallpaper_object, args.screen, args.background)
["fit"] = function(s)
gears.wallpaper.fit(wallpaper_object, s, args.background)
end,
}
local call_func = nil
if
type(wallpaper_object) == "string"
and gears.filesystem.file_readable(wallpaper_object)
then
-- path of an image file, we use a position function
local p = args.position or "centered"
positions[p]()
call_func = positions[p]
elseif type(wallpaper_object) == "function" then
-- function
wallpaper_object(args)
@@ -91,10 +92,13 @@ function apply(wallpaper_object, args)
and args.position
then
-- if the user sets a position function, wallpaper_object should be a cairo surface
positions[args.position]()
call_func = positions[args.position]
else
gears.wallpaper.set(wallpaper_object)
end
if call_func then
call_func(args.screen)
end
end
--- Converts `args.wallpaper` to a list of `wallpaper_objects` readable by `apply` function).
@@ -154,7 +158,15 @@ local simple_index = 0
function setters.simple(args)
local wallpapers = prepare_list(args)
simple_index = (simple_index % #wallpapers) + 1
apply(wallpapers[simple_index], args)
if type(args.screen) == 'table' then
for _,v in ipairs(args.screen) do
args.screen = v
apply(wallpapers[simple_index], args)
args.screen = nil
end
else
apply(wallpapers[simple_index], args)
end
end
--- Set a random wallpaper from a list.
@@ -164,7 +176,15 @@ end
-- @see prepare_list
function setters.random(args)
local wallpapers = prepare_list(args)
apply(wallpapers[math.random(#wallpapers)], args)
if type(args.screen) == 'table' then
for _,v in ipairs(args.screen) do
args.screen = v
apply(wallpapers[math.random(#wallpapers)], args)
args.screen = nil
end
else
apply(wallpapers[math.random(#wallpapers)], args)
end
end
local simple_schedule_object = nil
@@ -310,7 +330,10 @@ function setup(args)
config.set_function = config.set_function
or (config.wallpaper and setters.simple or setters.awesome_wallpaper)
local function set_wallpaper(s)
config.screen = s or config.screen
if type(config.screen) ~= 'table' then
if config.screen and s and config.screen ~= s then return end
config.screen = s or config.screen
end
config.set_function(config)
end
@@ -324,7 +347,7 @@ function setup(args)
end,
})
end
if awesome.version == "v4.3" then
if awesome.version == "v4.3" or awesome.version == "4.3" then
awful.screen.connect_for_each_screen(set_wallpaper)
else
screen.connect_signal("request::wallpaper", set_wallpaper)

View File

@@ -11,53 +11,93 @@ local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local window_swallowing_activated = false
-- you might want to add or remove applications here
local dont_swallow_classname_list = beautiful.dont_swallow_classname_list
local parent_filter_list = beautiful.parent_filter_list
or beautiful.dont_swallow_classname_list
or { "firefox", "Gimp", "Google-chrome" }
local activate_dont_swallow_filter = beautiful.dont_swallow_filter_activated
or true
local child_filter_list = beautiful.child_filter_list
or beautiful.dont_swallow_classname_list or { }
-- checks if client classname matches with any entry of the dont-swallow-list
local function check_if_swallow(c)
if not activate_dont_swallow_filter then
return true
end
for _, classname in ipairs(dont_swallow_classname_list) do
if classname == c.class then
return false
-- for boolean values the or chain way to set the values breaks with 2 vars
-- and always defaults to true so i had to do this to se the right value...
local swallowing_filter = true
local filter_vars = { beautiful.swallowing_filter, beautiful.dont_swallow_filter_activated }
for _, var in pairs(filter_vars) do
swallowing_filter = var
end
-- check if element exist in table
-- returns true if it is
local function is_in_table(element, table)
local res = false
for _, value in pairs(table) do
if element:match(value) then
res = true
break
end
end
return true
return res
end
-- if the swallowing filter is active checks the child and parent classes
-- against their filters
local function check_swallow(parent, child)
local res = true
if swallowing_filter then
local prnt = not is_in_table(parent, parent_filter_list)
local chld = not is_in_table(child, child_filter_list)
res = ( prnt and chld )
end
return res
end
-- async function to get the parent's pid
-- recieves a child process pid and a callback function
-- parent_pid in format "init(1)---ancestorA(pidA)---ancestorB(pidB)...---process(pid)"
function get_parent_pid(child_ppid, callback)
local ppid_cmd = string.format("pstree -A -p -s %s", child_ppid)
awful.spawn.easy_async(ppid_cmd, function(stdout, stderr, reason, exit_code)
-- primitive error checking
if stderr and stderr ~= "" then
callback(stderr)
return
end
local ppid = stdout
callback(nil, ppid)
end)
end
-- the function that will be connected to / disconnected from the spawn client signal
local function manage_clientspawn(c)
-- get the last focused window to check if it is a parent window
local parent_client = awful.client.focus.history.get(c.screen, 1)
if not parent_client then
return
elseif parent_client.type == "dialog" or parent_client.type == "splash" then
return
end
-- io.popen is normally discouraged. Should probably be changed
local handle = io.popen(
[[pstree -T -p -a -s ]]
.. tostring(c.pid)
.. [[ | sed '2q;d' | grep -o '[0-9]*$' | tr -d '\n']]
)
local parent_pid = handle:read("*a")
handle:close()
get_parent_pid(c.pid, function(err, ppid)
if err then
return
end
parent_pid = ppid
if
(tostring(parent_pid) == tostring(parent_client.pid))
and check_if_swallow(c)
-- will search for "(parent_client.pid)" inside the parent_pid string
( tostring(parent_pid):find("("..tostring(parent_client.pid)..")") )
and check_swallow(parent_client.class, c.class)
then
c:connect_signal("unmanage", function()
helpers.client.turn_on(parent_client)
helpers.client.sync(parent_client, c)
if parent_client then
helpers.client.turn_on(parent_client)
helpers.client.sync(parent_client, c)
end
end)
helpers.client.sync(c, parent_client)
helpers.client.turn_off(parent_client)
end
end)
end
-- without the following functions that module would be autoloaded by require("bling")