Change to Gtk icon lookup for the application launcher, this cuts loading times to basically 0, notifications now only appear on primary screen

This commit is contained in:
Rene
2022-07-30 05:13:07 +02:00
parent e727015e81
commit 978a8580c8
9 changed files with 66 additions and 53 deletions

View File

@@ -9,6 +9,7 @@
-- Initialising, order is important! -- Initialising, order is important!
require("src.theme.user_config") require("src.theme.user_config")
require("src.theme.theme_config") require("src.theme.theme_config")
require("src.tools.icon_theme")
require("src.theme.init") require("src.theme.init")
require("src.core.error_handling") require("src.core.error_handling")
require("src.core.signals") require("src.core.signals")

1
awesome/src/assets/cache/rules.txt vendored Normal file
View File

@@ -0,0 +1 @@
Lutris;Steam;Io.elementary.appcenter;Repoman;Com.github.donadigo.eddy;Sysmontask;join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=join?action=join&confno=9992624875&confid=dXRpZD1VVElEXzM0ODYxOTgyYzg0YzQ1Y2NiYmM0YWNiMzczODNiYjgxJnVzcz1TaU1YUnNEWG5BQWNBYnRpYklBNWE0MjRDNkpBMzMyVXRUc2pCX1YxVm5JY0hWeVRybGN5WjZZS2VBa1pvNkszOXdNWEVkVE9hTU54Z3BROFZFckhPR3Y4eGo0MlB0emNCZjNRLnNlM28yNy13YWpGYy1ReXEmdGlkPTcyNjEzNGRjYWJkZTQyYTNhNzJmZjVjYjVkNTU2YTYw&browser=Gnome-calculator;Virt-manager;Gwe;whatsdesk;Totem;steam_app_431960;Viewer,;Viewer,;Nvidia-settings;openrgb;Minecraft;Pavucontrol;jamesdsp;

View File

@@ -317,7 +317,7 @@ return gears.table.join(
}, },
} }
awful.spawn.easy_async_with_shell( awful.spawn.easy_async_with_shell(
"cat ~/.config/awesome/src/assets/rules.txt", "cat ~/.config/awesome/src/assets/cache/rules.txt",
function(stdout2) function(stdout2)
for class in stdout2:gmatch("%a+") do for class in stdout2:gmatch("%a+") do
if class:match(stdout:gsub("\n", "")) then if class:match(stdout:gsub("\n", "")) then
@@ -325,7 +325,7 @@ return gears.table.join(
end end
end end
awful.spawn.with_shell("echo -n '" .. awful.spawn.with_shell("echo -n '" ..
stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/rules.txt") stdout:gsub("\n", "") .. ";' >> ~/.config/awesome/src/assets/cache/rules.txt")
local c = mouse.screen.selected_tag:clients() local c = mouse.screen.selected_tag:clients()
for _, client in ipairs(c) do for _, client in ipairs(c) do
if client.class:match(stdout:gsub("\n", "")) then if client.class:match(stdout:gsub("\n", "")) then
@@ -356,8 +356,8 @@ return gears.table.join(
awful.spawn.easy_async_with_shell( awful.spawn.easy_async_with_shell(
[[ [[
REMOVE="]] .. stdout:gsub("\n", "") .. [[;" REMOVE="]] .. stdout:gsub("\n", "") .. [[;"
STR=$(cat ~/.config/awesome/src/assets/rules.txt) STR=$(cat ~/.config/awesome/src/assets/cache/rules.txt)
echo -n ${STR//$REMOVE/} > ~/.config/awesome/src/assets/rules.txt echo -n ${STR//$REMOVE/} > ~/.config/awesome/src/assets/cache/rules.txt
]], ]],
function() function()
local c = mouse.screen.selected_tag:clients() local c = mouse.screen.selected_tag:clients()

View File

@@ -25,6 +25,9 @@ naughty.config.defaults.border_width = Theme_config.notification.border_width
naughty.config.defaults.border_color = Theme_config.notification.border_color naughty.config.defaults.border_color = Theme_config.notification.border_color
naughty.config.defaults.spacing = Theme_config.notification.spacing naughty.config.defaults.spacing = Theme_config.notification.spacing
--naughty.config.defaults.screen = screen.primary.index
Theme.notification_spacing = Theme_config.notification.corner_spacing Theme.notification_spacing = Theme_config.notification.corner_spacing
naughty.connect_signal( naughty.connect_signal(
@@ -392,10 +395,18 @@ naughty.connect_signal(
if key == 3 then if key == 3 then
n:destroy() n:destroy()
end end
-- TODO: Find out how to get the associated client -- Raise the client on click
-- for some reason n.clients is always empty if key == 1 then
--[[ if key == 1 then for _, client in ipairs(client.get()) do
end ]] if client.name:match(n.app_name) then
if not client:isvisible() and client.first_tag then
client.first_tag:view_only()
end
client:emit_signal('request::activate')
client:raise()
end
end
end
end end
) )
@@ -403,7 +414,7 @@ naughty.connect_signal(
notification = n, notification = n,
timeout = 3, timeout = 3,
type = "notification", type = "notification",
screen = awful.screen.focused(), screen = screen.primary,
shape = function(cr, width, height) shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10) gears.shape.rounded_rect(cr, width, height, 10)
end, end,
@@ -422,27 +433,6 @@ naughty.connect_signal(
end end
) )
-- Test notification
--[[ naughty.notification {
app_name = "System Notification",
title = "A notification 2",
message = "This is very informative and overflowing",
icon = "/home/crylia/.config/awesome/src/assets/userpfp/crylia.png",
urgency = "normal",
timeout = 0,
actions = {
naughty.action {
name = "Accept",
},
naughty.action {
name = "Refuse",
},
naughty.action {
name = "Ignore",
},
}
} ]]
naughty.connect_signal( naughty.connect_signal(
"invoked", "invoked",
function(_, action) function(_, action)

View File

@@ -74,7 +74,7 @@ awful.rules.rules = {
} }
awful.spawn.easy_async_with_shell( awful.spawn.easy_async_with_shell(
"cat ~/.config/awesome/src/assets/rules.txt", "cat ~/.config/awesome/src/assets/cache/rules.txt",
function(stdout) function(stdout)
for class in stdout:gmatch("%a+") do for class in stdout:gmatch("%a+") do
ruled.client.append_rule { ruled.client.append_rule {

View File

@@ -4,15 +4,13 @@
-- Awesome Libs -- Awesome Libs
local awful = require("awful") local awful = require("awful")
local Gio = require("lgi").Gio
local dpi = require("beautiful").xresources.apply_dpi local dpi = require("beautiful").xresources.apply_dpi
local desktop_parser = require("src.tools.desktop_parser")
local gears = require("gears") local gears = require("gears")
local wibox = require("wibox") local wibox = require("wibox")
return function() return function()
local desktop_files = desktop_parser.Get_all_visible_desktop()
local application_grid = wibox.widget { local application_grid = wibox.widget {
homogenous = true, homogenous = true,
expand = false, expand = false,
@@ -36,8 +34,12 @@ return function()
---@return table widgets Unsorted widget table ---@return table widgets Unsorted widget table
local function get_applications_from_file() local function get_applications_from_file()
local list = {} local list = {}
for _, file in ipairs(desktop_files) do --for _, file in ipairs(desktop_files) do
if not file.nodisplay then local app_info = Gio.AppInfo
local apps = app_info.get_all()
for _, app in ipairs(apps) do
if app.should_show(app) then -- check no display
local desktop_app_info = Gio.DesktopAppInfo.new(app_info.get_id(app))
local app_widget = wibox.widget { local app_widget = wibox.widget {
{ {
{ {
@@ -46,7 +48,9 @@ return function()
{ -- Icon { -- Icon
valign = "center", valign = "center",
halign = "center", halign = "center",
image = xdg_icon_lookup:find_icon(file.icon, 64) or "/home/crylia/Bilder/yes.png", --[[ image = xdg_icon_lookup:find_icon(Gio.DesktopAppInfo.get_string(desktop_app_info, "Icon"), 64) or
awful.util.getdir("config") .. "src/assets/icons/fallback.svg", -- fallback icon ]]
image = Get_gicon_path(app_info.get_icon(app)),
resize = true, resize = true,
widget = wibox.widget.imagebox widget = wibox.widget.imagebox
}, },
@@ -57,7 +61,7 @@ return function()
}, },
{ {
{ -- Name { -- Name
text = file.name, text = app_info.get_name(app),
align = "center", align = "center",
valign = "center", valign = "center",
widget = wibox.widget.textbox widget = wibox.widget.textbox
@@ -77,12 +81,12 @@ return function()
margins = dpi(10), margins = dpi(10),
widget = wibox.container.margin widget = wibox.container.margin
}, },
name = file.name, name = app_info.get_name(app),
comment = file.comment, comment = Gio.DesktopAppInfo.get_string(desktop_app_info, "Comment") or "",
exec = file.exec, exec = Gio.DesktopAppInfo.get_string(desktop_app_info, "Exec"),
keywords = file.keywords, keywords = Gio.DesktopAppInfo.get_string(desktop_app_info, "Keywords") or "",
categories = file.categories, categories = Gio.DesktopAppInfo.get_string(desktop_app_info, "Cathegory") or "",
terminal = file.terminal, terminal = Gio.DesktopAppInfo.get_string(desktop_app_info, "Terminal") == "true",
border_color = Theme_config.application_launcher.application.border_color, border_color = Theme_config.application_launcher.application.border_color,
border_width = Theme_config.application_launcher.application.border_width, border_width = Theme_config.application_launcher.application.border_width,
bg = Theme_config.application_launcher.application.bg, bg = Theme_config.application_launcher.application.bg,
@@ -100,7 +104,7 @@ return function()
1, 1,
nil, nil,
function() function()
awful.spawn.with_shell(file.exec) awful.spawn.with_shell(app_widget.exec)
awesome.emit_signal("application_launcher::show") awesome.emit_signal("application_launcher::show")
end end
) )
@@ -207,8 +211,8 @@ return function()
awesome.connect_signal( awesome.connect_signal(
"update::application_list", "update::application_list",
function(filter) function(f)
application_grid = get_applications(filter) application_grid = get_applications(f)
end end
) )
@@ -219,9 +223,10 @@ return function()
local selected_widget = application_grid:get_widgets_at(curser.y, curser.x)[1] local selected_widget = application_grid:get_widgets_at(curser.y, curser.x)[1]
if selected_widget.terminal then if selected_widget.terminal then
awful.spawn.with_shell(selected_widget.exec) awful.spawn(User_config.terminal .. " -e " .. selected_widget.exec)
else else
awful.spawn(selected_widget.exec) print(selected_widget.exec)
awful.spawn.with_shell(selected_widget.exec)
end end
end end
) )

View File

@@ -156,7 +156,7 @@ return function(s)
{ {
step = dpi(50), step = dpi(50),
spacing = dpi(10), spacing = dpi(10),
layout = wibox.layout.overflow.vertical, layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0, scrollbar_width = 0,
id = "connected_device_list" id = "connected_device_list"
}, },
@@ -184,7 +184,7 @@ return function(s)
{ {
spacing = dpi(10), spacing = dpi(10),
step = dpi(50), step = dpi(50),
layout = wibox.layout.overflow.vertical, layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0, scrollbar_width = 0,
id = "discovered_device_list" id = "discovered_device_list"
}, },

View File

@@ -147,7 +147,7 @@ return function(s)
{ {
{ {
spacing = dpi(10), spacing = dpi(10),
layout = wibox.layout.overflow.vertical, layout = require("src.lib.overflow_widget.overflow").vertical,
scrollbar_width = 0, scrollbar_width = 0,
step = dpi(50), step = dpi(50),
id = "volume_device_list", id = "volume_device_list",
@@ -179,7 +179,7 @@ return function(s)
{ {
{ {
spacing = dpi(10), spacing = dpi(10),
layout = wibox.layout.overflow.vertical, layout = require("src.lib.overflow_widget.overflow").vertical,
id = "volume_device_list", id = "volume_device_list",
scrollbar_width = 0, scrollbar_width = 0,
step = dpi(50), step = dpi(50),

View File

@@ -0,0 +1,16 @@
local lgi = require("lgi")
local Gtk = lgi.require("Gtk", "3.0")
local gtk_theme = Gtk.IconTheme.new()
Gtk.IconTheme.set_custom_theme(gtk_theme, User_config.icon_theme)
function Get_gicon_path(app)
local icon_info = gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
local path = icon_info:get_filename()
if path then
return path
end
end
return ""
end