aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/components/signals/client.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2023-01-29 09:59:52 +0100
committerdelta <darkussdelta@gmail.com>2023-01-29 10:02:22 +0100
commita0f8b5fa6acdd1c2477fb1881dd9067956bf0ae6 (patch)
tree04500ca0a4c97f85b1a2d875d8285effda7b57fe /.config/awesome/components/signals/client.lua
init dots
Diffstat (limited to '.config/awesome/components/signals/client.lua')
-rw-r--r--.config/awesome/components/signals/client.lua104
1 files changed, 104 insertions, 0 deletions
diff --git a/.config/awesome/components/signals/client.lua b/.config/awesome/components/signals/client.lua
new file mode 100644
index 0000000..0b44d62
--- /dev/null
+++ b/.config/awesome/components/signals/client.lua
@@ -0,0 +1,104 @@
+local awful = require "awful"
+local beautiful = require "beautiful"
+-- local cairo = require "lgi".cairo
+local gears = require "gears"
+local xresources = require "beautiful.xresources"
+local dpi = xresources.apply_dpi
+local wibox = require "wibox"
+
+client.connect_signal("property::name", function(c)
+ if not c then return end -- Sometimes c is nil for some reason
+ if not c.pid then return end
+
+ local out = io.popen("readlink /proc/" .. c.pid .. "/exe")
+ local name = c.name
+ if out ~= nil then
+ name = out:read("*a"):sub(0, -2):match("[^\\/]+$") or name
+ end
+ c.name = string.lower(name)
+end)
+
+client.connect_signal("property::urgent", function(c)
+ if c.class ~= "kitty" then
+ c:activate({
+ switch_to_tag = true
+ })
+ c.urgent = false
+ end
+end)
+
+client.connect_signal("request::manage", function (c)
+ local parent = c.transient_for
+ if parent then
+ c:move_to_tag(parent.first_tag)
+ end
+
+ if not c.pid then return end
+
+ awful.spawn.easy_async({ "readlink", "/proc/" .. c.pid .. "/exe" }, function(name)
+ c.name = string.lower(name:match("[^\\/]+$") or name)
+ end)
+
+ -- Forcefully set the correct icon for a client
+ -- Taken from https://discord.com/channels/702548301299580939/893586726885425163/947173452073287722 (Author: Orlando#0171) and modified a little bit
+ -- local icon_cache = Get_icon(beautiful.get().icon_theme, c)
+
+ -- if type(icon_cache) ~= "userdata" then
+ -- local s = gears.surface(icon_cache)
+ -- local img = cairo.ImageSurface.create(cairo.Format.ARGB32, s:get_width(), s:get_height())
+ -- local cr = cairo.Context(img)
+ -- cr:set_source_surface(s, 0, 0)
+ -- cr:paint()
+
+ -- c.icon = img._native
+ -- end
+end)
+
+client.connect_signal("property::maximized", function(c)
+ c.border_width = beautiful.border_width
+end)
+
+client.connect_signal("request::titlebars", function(c)
+ local buttons = gears.table.join(
+ awful.button({ }, 1, function()
+ c:emit_signal("request::activate", "titlebar", {raise = true})
+ awful.mouse.client.move(c)
+ end),
+ awful.button({ }, 3, function()
+ c:emit_signal("request::activate", "titlebar", {raise = true})
+ awful.mouse.client.resize(c)
+ end)
+ )
+
+ awful.titlebar.enable_tooltip = false
+
+ awful.titlebar(c) : setup {
+ -- {
+ -- widget = wibox.container.margin,
+ -- left = dpi(8),
+ -- awful.titlebar.widget.titlewidget(c),
+ -- buttons = buttons
+ -- },
+ nil,
+
+ {
+ widget = wibox.widget.base.empty_widget(),
+ buttons = buttons
+ },
+ {
+
+ {
+ awful.titlebar.widget.maximizedbutton (c),
+ awful.titlebar.widget.minimizebutton (c),
+ awful.titlebar.widget.closebutton (c),
+
+ spacing = dpi(4),
+ layout = wibox.layout.fixed.horizontal
+ },
+
+ margins = dpi(5),
+ widget = wibox.container.margin,
+ },
+ layout = wibox.layout.align.horizontal
+ }
+end)