From 923eb46350b1102749eb05cd2120c96cc6a715d0 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Fri, 18 Oct 2024 21:49:17 -0500 Subject: initial commit --- func/noborders.lua | 20 ++++++++++++++++++++ func/sloppyfocus.lua | 4 ++++ func/tagnames.lua | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ func/warpcursor.lua | 22 ++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 func/noborders.lua create mode 100644 func/sloppyfocus.lua create mode 100644 func/tagnames.lua create mode 100644 func/warpcursor.lua (limited to 'func') diff --git a/func/noborders.lua b/func/noborders.lua new file mode 100644 index 0000000..fe67024 --- /dev/null +++ b/func/noborders.lua @@ -0,0 +1,20 @@ +local beautiful = require("beautiful") + +-- TODO this function will call arrange multiple times. once per each change of c.border_width +local function update_borders(s) + local max = s.selected_tag.layout.name == "max" + local only_one = #s.tiled_clients == 1 -- use tiled_clients so that other floating windows don't affect the count + + -- but iterate over clients instead of tiled_clients as tiled_clients doesn't include maximized windows + for _, c in pairs(s.clients) do + if c.prevent_kill then + c.border_width = beautiful.border_width * 3 + elseif (max or only_one or c.maximized) and not c.floating then + c.border_width = 0 + else + c.border_width = beautiful.border_width + end + end +end + +screen.connect_signal("arrange", update_borders) -- NOTE this signal may eventually be deprecated. see issue #2581 and the v5 milestone on github diff --git a/func/sloppyfocus.lua b/func/sloppyfocus.lua new file mode 100644 index 0000000..a616286 --- /dev/null +++ b/func/sloppyfocus.lua @@ -0,0 +1,4 @@ +-- Enable sloppy focus, so that focus follows mouse. +client.connect_signal("mouse::enter", function(c) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) +end) diff --git a/func/tagnames.lua b/func/tagnames.lua new file mode 100644 index 0000000..fcd01a4 --- /dev/null +++ b/func/tagnames.lua @@ -0,0 +1,51 @@ +--TODO find out why it doesnt work at start +--local awful = require("awful") + +function nametags(s) + local tags = s.tags + for _, tag in ipairs(tags) do + -- set tag basename + if tag.basename == nil then + tag.basename = tag.name + end + + -- check if tag has any clients. if not, use basename + if next(tag:clients()) == nil then + tag.name = tag.basename + else + -- loop over all screen clients (ordered top to bottom) + local hastag = nil + for _, c in ipairs(s.clients) do + -- test if client in on the tag + for _, ctag in ipairs(c:tags()) do + if ctag == tag then + hastag = c + break + end + end + -- if it does, this will be the tag name. so break + if hastag ~= nil then + break + end + end + -- set tag name + -- there should always be a tag since we checked above so if there isnt then there is clearly a problem + --TODO remove this if statement + if hastag then + tag.name = tag.basename .. ": " .. hastag.class + end + end + end +end + +function nametagsc(c) + nametags(c.screen) +end + +client.connect_signal("manage", nametagsc) +client.connect_signal("swapped", nametagsc) +client.connect_signal("tagged", nametagsc) +client.connect_signal("unmanage", nametagsc) +client.connect_signal("untagged", nametagsc) + +--awful.screen.connect_for_each_screen(nametags) diff --git a/func/warpcursor.lua b/func/warpcursor.lua new file mode 100644 index 0000000..f1a46bd --- /dev/null +++ b/func/warpcursor.lua @@ -0,0 +1,22 @@ +function warp_cursor(c) +-- if c ~= client.focus or not c.warp_cursor then + if not c.warp_cursor then + return + end + + -- dont allow moving mouse unless it is over another client or over nothing + local canmovemouse = mouse.current_client or (mouse.current_wibox or mouse.current_widget) == nil + + if canmovemouse and mouse.current_client ~= c then + mouse.coords { + x = c.x + (c.width / 2), + y = c.y + (c.height / 2), + } + end +end + +client.connect_signal("focus", warp_cursor) +--client.connect_signal("property::size", warp_cursor) +--client.connect_signal("property::position", warp_cursor) + +return warp_cursor -- cgit v1.2.3