aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/components/signals
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
init dots
Diffstat (limited to '.config/awesome/components/signals')
-rw-r--r--.config/awesome/components/signals/awesome.lua32
-rw-r--r--.config/awesome/components/signals/client.lua104
-rw-r--r--.config/awesome/components/signals/init.lua5
-rw-r--r--.config/awesome/components/signals/naughty.lua64
-rw-r--r--.config/awesome/components/signals/rules.lua102
-rw-r--r--.config/awesome/components/signals/screen.lua79
6 files changed, 386 insertions, 0 deletions
diff --git a/.config/awesome/components/signals/awesome.lua b/.config/awesome/components/signals/awesome.lua
new file mode 100644
index 0000000..37b9bdb
--- /dev/null
+++ b/.config/awesome/components/signals/awesome.lua
@@ -0,0 +1,32 @@
+-- Taken from https://www.reddit.com/r/awesomewm/comments/syjolb/comment/hy0xy35/
+
+awesome.connect_signal('exit', function(reason_restart)
+ if not reason_restart then return end
+
+ local file = io.open('/tmp/awesomewm-last-selected-tags', 'w+')
+
+ for s in screen do
+ file:write(s.selected_tag.index, '\n')
+ end
+
+ file:close()
+end)
+
+awesome.connect_signal('startup', function()
+ local file = io.open('/tmp/awesomewm-last-selected-tags', 'r')
+ if not file then return end
+
+ local selected_tags = {}
+
+ for line in file:lines() do
+ table.insert(selected_tags, tonumber(line))
+ end
+
+ for s in screen do
+ local i = selected_tags[s.index]
+ local t = s.tags[i]
+ t:view_only()
+ end
+
+ file:close()
+end)
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)
diff --git a/.config/awesome/components/signals/init.lua b/.config/awesome/components/signals/init.lua
new file mode 100644
index 0000000..6e42252
--- /dev/null
+++ b/.config/awesome/components/signals/init.lua
@@ -0,0 +1,5 @@
+require "components.signals.naughty"
+require "components.signals.awesome"
+require "components.signals.client"
+require "components.signals.rules"
+require "components.signals.screen"
diff --git a/.config/awesome/components/signals/naughty.lua b/.config/awesome/components/signals/naughty.lua
new file mode 100644
index 0000000..bab4712
--- /dev/null
+++ b/.config/awesome/components/signals/naughty.lua
@@ -0,0 +1,64 @@
+local awful = require "awful"
+local vars = require "themes.prismite.vars"
+local wibox = require "wibox"
+local naughty = require "naughty"
+local xresources = require "beautiful.xresources"
+local dpi = xresources.apply_dpi
+
+function build_notification(n)
+
+
+ local popup = awful.popup {
+ widget = {
+ {
+ {
+ widget = naughty.widget.icon,
+ image = n.image,
+ forced_height = 64,
+ forced_width = 64,
+ clip_shape = vars.shape
+ },
+ {
+ {
+ widget = wibox.widget.textbox,
+ text = n.title
+ },
+ {
+ widget = wibox.widget.textbox,
+ text = n.message
+ },
+ layout = wibox.layout.fixed.vertical
+ },
+ layout = wibox.layout.fixed.horizontal
+ },
+ widget = wibox.container.margin,
+ margins = dpi(4)
+ },
+ border_color = vars.colors.bright.black,
+ border_width = vars.border_width,
+ ontop = true,
+ placement = function(d)
+ return awful.placement.bottom_right(d, {
+ honor_padding = true
+ })
+ end,
+ bg = vars.colors.bg,
+ shape = vars.shape,
+ }
+
+ -- popup.y = screen[1].tiling_area.height - - dpi(4)
+end
+
+-- naughty.connect_signal("request::display", build_notification)
+
+naughty.connect_signal("request::display", function(n)
+ naughty.layout.box { notification = n }
+end)
+
+naughty.connect_signal("request::display_error", function(message, startup)
+ naughty.notification {
+ urgency = "critical",
+ title = "Oops, an error happened"..(startup and " during startup!" or "!"),
+ message = message
+ }
+end)
diff --git a/.config/awesome/components/signals/rules.lua b/.config/awesome/components/signals/rules.lua
new file mode 100644
index 0000000..65db501
--- /dev/null
+++ b/.config/awesome/components/signals/rules.lua
@@ -0,0 +1,102 @@
+local ruled = require "ruled"
+local beautiful = require "beautiful"
+local awful = require "awful"
+local vars = require "themes.prismite.vars"
+
+ruled.client.connect_signal("request::rules", function()
+ ruled.client.append_rule({
+ id = "global",
+ rule = {},
+ properties = {
+ border_width = beautiful.border_width,
+ border_color = beautiful.border_normal,
+ focus = awful.client.focus.filter,
+ raise = true,
+ screen = awful.screen.preferred,
+ placement = awful.placement.centered+awful.placement.no_offscreen,
+ floating = false,
+ shape = vars.shape,
+ honor_padding = true
+ -- tag = "1"
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "titlebars",
+ rule_any = {
+ type = {
+ "normal",
+ "dialog"
+ }
+ },
+ properties = {
+ titlebars_enabled = true
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "steam",
+ rule_any = {
+ class = { "Steam" }
+ },
+ properties = {
+ screen = 1,
+ tag = screen[1].tags[6]
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "browser_tag",
+ rule_any = {
+ class = { "firefox" }
+ },
+ properties = {
+ screen = 1,
+ tag = screen[1].tags[2]
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "chat_tag",
+ rule_any = {
+ class = { "discord" }
+ },
+ properties = {
+ screen = 1,
+ tag = screen[1].tags[3]
+ }
+ })
+
+
+ ruled.client.append_rule({
+ id = "music_tag",
+ rule_any = {
+ class = { "Spotify" }
+ },
+ properties = {
+ screen = 1,
+ tag = screen[1].tags[4]
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "code_tag",
+ rule_any = {
+ class = { "lite-xl", "code_kitty" }
+ },
+ properties = {
+ screen = 1,
+ tag = screen[1].tags[5]
+ }
+ })
+
+ ruled.client.append_rule({
+ id = "pip",
+ rule = {
+ name = "Picture-in-Picture"
+ },
+ properties = {
+ ontop = true
+ }
+ })
+end)
diff --git a/.config/awesome/components/signals/screen.lua b/.config/awesome/components/signals/screen.lua
new file mode 100644
index 0000000..3e49a68
--- /dev/null
+++ b/.config/awesome/components/signals/screen.lua
@@ -0,0 +1,79 @@
+local awful = require "awful"
+local wibox = require "wibox"
+local beautiful = require "beautiful"
+local xresources = require "beautiful.xresources"
+local dpi = xresources.apply_dpi
+
+screen.connect_signal("request::wallpaper", function(s)
+ awful.wallpaper {
+ screen = s,
+ widget = {
+ {
+ image = beautiful.wallpaper,
+ upscale = true,
+ downscale = true,
+ widget = wibox.widget.imagebox,
+ },
+ valign = "center",
+ halign = "center",
+ tiled = false,
+ widget = wibox.container.tile,
+ }
+ }
+end)
+
+screen.connect_signal("request::desktop_decoration", function(s)
+ -- s.padding = dpi(4)
+
+ awful.tag.add(
+ "",
+ {
+ screen = s,
+ layout = awful.layout.suit.floating,
+ selected = true
+ }
+ )
+
+ awful.tag.add(
+ "󰈹",
+ {
+ screen = s,
+ layout = awful.layout.suit.floating,
+
+ }
+ )
+
+ awful.tag.add(
+ "󰡠",
+ {
+ screen = s,
+ layout = awful.layout.suit.tile.left,
+ master_width_factor = 0.7
+ }
+ )
+
+ awful.tag.add(
+ "",
+ {
+ screen = s,
+ layout = awful.layout.suit.tile
+ }
+ )
+
+ awful.tag.add(
+ "",
+ {
+ screen = s,
+ layout = awful.layout.suit.tile.right,
+ master_width_factor = 0.7
+ }
+ )
+
+ awful.tag.add(
+ "",
+ {
+ screen = s,
+ layout = awful.layout.suit.floating,
+ }
+ )
+end)