systray, dock, icon_handler some major revision
This commit is contained in:
@@ -1,13 +1,23 @@
|
||||
------------------------------
|
||||
-- This is the audio widget --
|
||||
------------------------------
|
||||
local naughty = require("naughty")
|
||||
local awful = require("awful")
|
||||
-----------------------------------------------------
|
||||
-- Helper to get icons from a program/program name --
|
||||
-----------------------------------------------------
|
||||
|
||||
function Get_icon(theme, c)
|
||||
-- tries to find a matching file name in /usr/share/icons/THEME/RESOLUTION/apps/ and if not found tried with first letter
|
||||
-- as uppercase, this should get almost all icons to work with the papirus theme atleast
|
||||
-- TODO: try with more icon themes
|
||||
function Get_icon(theme, c, is_steam)
|
||||
if theme and c then
|
||||
local clientName
|
||||
clientName = string.lower(c.class) .. ".svg"
|
||||
-- TODO: Access steamdb api to fetch the clienticon if there is no icon found in this theme
|
||||
if is_steam then
|
||||
clientName = "steam_icon_" .. tostring(c) .. ".svg"
|
||||
else
|
||||
if type(c) == type("") then
|
||||
clientName = string.lower(c) .. ".svg"
|
||||
else
|
||||
clientName = string.lower(c.class) .. ".svg"
|
||||
end
|
||||
end
|
||||
local resolutions = {"128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16"}
|
||||
for i, res in ipairs(resolutions) do
|
||||
local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .."/apps/"
|
||||
@@ -15,27 +25,29 @@ function Get_icon(theme, c)
|
||||
if ioStream ~= nil then
|
||||
return iconDir .. clientName
|
||||
else
|
||||
return c.icon
|
||||
clientName = clientName:gsub("^%l", string.upper)
|
||||
iconDir = "/usr/share/icons/" .. theme .. "/" .. res .."/apps/"
|
||||
ioStream = io.open(iconDir .. clientName, "r")
|
||||
if ioStream ~= nil then
|
||||
return iconDir .. clientName
|
||||
elseif type(c) ~= type("") then
|
||||
local naughty = require("naughty")
|
||||
if pcall(
|
||||
function ()
|
||||
if c:Get_icon(1) then
|
||||
error("icon error")
|
||||
else
|
||||
return c:Get_icon(1)
|
||||
end
|
||||
end
|
||||
) then
|
||||
return nil
|
||||
end
|
||||
return "/usr/share/icons/Papirus-Dark/128x128/apps/Zoom.svg"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return c:Get_icon(1)
|
||||
return nil
|
||||
end
|
||||
|
||||
function Get_icon_by_class_name(theme, c)
|
||||
if theme and c then
|
||||
local c_name = string.lower(c) .. ".svg"
|
||||
local resolutions = {"128x128", "96x96", "64x64", "48x48", "42x42", "32x32", "24x24", "16x16"}
|
||||
for i, res in ipairs(resolutions) do
|
||||
local iconDir = "/usr/share/icons/" .. theme .. "/" .. res .."/apps/"
|
||||
local ioStream = io.open(iconDir .. c_name, "r")
|
||||
if ioStream ~= nil then
|
||||
return iconDir .. c_name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Get_icon_by_desktop(theme, c)
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user