reworked Get_icon and some other fixes
This commit is contained in:
@@ -304,9 +304,10 @@ return function(s)
|
||||
awesome.connect_signal(
|
||||
"module::powermenu:show",
|
||||
function()
|
||||
powermenu_container.visible = false
|
||||
powermenu_container.visible = true
|
||||
powermenu_keygrabber:start()
|
||||
if s == mouse.screen then
|
||||
powermenu_container.visible = true
|
||||
powermenu_keygrabber:start()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
@@ -60,19 +60,6 @@ local create_click_events = function(c)
|
||||
return buttons
|
||||
end
|
||||
|
||||
local createresize_click_events = function(c)
|
||||
local buttons = gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
function()
|
||||
c:activate { context = 'titlebar', action = 'mouse_resize' }
|
||||
end
|
||||
)
|
||||
)
|
||||
return buttons
|
||||
end
|
||||
|
||||
local create_titlebar = function(c, bg, size)
|
||||
local titlebar = awful.titlebar(c, {
|
||||
position = "left",
|
||||
@@ -191,55 +178,8 @@ local create_titlebar_dialog = function(c, bg, size)
|
||||
Hover_signal(titlebar.main.margin.spacing.minimizebutton, color["Green200"])
|
||||
end
|
||||
|
||||
local create_titlebar_borderhack = function(c, bg, position)
|
||||
local borderhack = awful.titlebar(c, {
|
||||
position = position,
|
||||
bg = bg,
|
||||
size = "4"
|
||||
})
|
||||
borderhack:setup {
|
||||
{
|
||||
bg = bg,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
{
|
||||
buttons = createresize_click_events(c),
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
nil,
|
||||
layout = wibox.layout.align.vertical
|
||||
}
|
||||
|
||||
local old_wibox, old_cursor
|
||||
borderhack:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
local w = mouse.current_client
|
||||
if w then
|
||||
old_cursor, old_wibox = w.cursor, w
|
||||
w.cursor = "hand1"
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
borderhack:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
local draw_titlebar = function(c)
|
||||
if c.type == 'normal' and not c.requests_no_titlebar then
|
||||
create_titlebar_borderhack(c, "#121212AA", "right")
|
||||
create_titlebar_borderhack(c, "#121212AA", "top")
|
||||
create_titlebar_borderhack(c, "#121212AA", "bottom")
|
||||
|
||||
if c.class == 'Firefox' then
|
||||
create_titlebar(c, '#121212AA', 35)
|
||||
elseif c.name == "Steam" then
|
||||
@@ -253,15 +193,6 @@ local draw_titlebar = function(c)
|
||||
end
|
||||
elseif c.type == 'dialog' then
|
||||
create_titlebar_dialog(c, '#121212AA', 35)
|
||||
create_titlebar_borderhack(c, "#121212AA", "right")
|
||||
create_titlebar_borderhack(c, "#121212AA", "top")
|
||||
create_titlebar_borderhack(c, "#121212AA", "bottom")
|
||||
elseif c.type == 'modal' then
|
||||
else
|
||||
create_titlebar_borderhack(c, "#121212AA", "right")
|
||||
create_titlebar_borderhack(c, "#121212AA", "top")
|
||||
create_titlebar_borderhack(c, "#121212AA", "bottom")
|
||||
create_titlebar_borderhack(c, "#121212AA", "left")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -313,9 +244,6 @@ client.connect_signal(
|
||||
awful.titlebar.hide(c, 'bottom')
|
||||
else
|
||||
awful.titlebar.show(c, 'left')
|
||||
awful.titlebar.show(c, 'right')
|
||||
awful.titlebar.show(c, 'top')
|
||||
awful.titlebar.show(c, 'bottom')
|
||||
end
|
||||
else
|
||||
awful.titlebar.hide(c, 'left')
|
||||
|
||||
@@ -42,7 +42,7 @@ user_vars = {
|
||||
},
|
||||
|
||||
-- This is your default Terminal
|
||||
terminal = "alacritty -o font.size=14",
|
||||
terminal = "alacritty",
|
||||
|
||||
-- This is the modkey 'mod4' = Super/Mod/WindowsKey, 'mod3' = alt...
|
||||
modkey = "Mod4",
|
||||
@@ -68,22 +68,24 @@ user_vars = {
|
||||
-- Add your programs exactly like in this example.
|
||||
-- First entry has to be how you would start the program in the terminal (just try it if you dont know yahoo it)
|
||||
-- Second can be what ever the fuck you want it to be (will be the displayed name if you hover over it)
|
||||
-- For steam games please use this format {"394360", "Name", true} true will tell the func that it's a steam game
|
||||
-- TODO: Add appimage support
|
||||
-- Theoretically you can put the appimage path as the first argument and it *should* work
|
||||
-- For steam games please use this format (look in .local/share/applications for the .desktop file, that will contain the number you need)
|
||||
-- {"394360", "Name", true} true will tell the func that it's a steam game
|
||||
-- Use xprop | grep WM_CLASS and use the *SECOND* string
|
||||
-- { WM_CLASS, program, name, isSteam }
|
||||
dock_programs = {
|
||||
{ "alacritty", "Alacritty" },
|
||||
{ "firefox", "Firefox" },
|
||||
{ "discord", "Discord" },
|
||||
{ "flatpak run com.spotify.Client", "Spotify" },
|
||||
{ "code", "Visual Studio Code" },
|
||||
{ "arduino", "Arduino IDE" },
|
||||
{ "zoom", "Zoom" },
|
||||
{ "thunderbird", "Thunderbird" },
|
||||
{ "mattermost-desktop", "Mattermost" },
|
||||
{ "blender", "Blender" },
|
||||
{ "steam", "Steams" },
|
||||
{ "freecad", "Freecad" },
|
||||
{ "nemo", "Dateien" }
|
||||
{ "Alacritty", "alacritty", "Alacritty" },
|
||||
{ "firefox", "firefox", "Firefox" },
|
||||
{ "discord", "discord", "Discord" },
|
||||
{ "Spotify", "flatpak run com.spotify.Client", "Spotify" },
|
||||
{ "Code", "code", "Visual Studio Code" },
|
||||
{ "processing-app-Base", "arduino", "Arduino IDE" },
|
||||
{ "zoom", "zoom", "Zoom" },
|
||||
{ "Thunderbird", "thunderbird", "Thunderbird" },
|
||||
{ "Mattermost", "mattermost-desktop", "Mattermost" },
|
||||
{ "Blender", "blender", "Blender" },
|
||||
{ "Steam", "steam", "Steams" },
|
||||
{ "FreeCAD", "freecad", "Freecad" },
|
||||
{ "Nemo", "nemo", "Dateien" },
|
||||
{ "Paradox Launcher", "394360", "Hearts of Iron 4", true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,95 @@
|
||||
-----------------------------------------------------
|
||||
-- Helper to get icons from a program/program name --
|
||||
-----------------------------------------------------
|
||||
local naughty = require("naughty")
|
||||
local icon_cache = {}
|
||||
|
||||
-- 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 ~= nil and c ~= nil then
|
||||
function Get_icon(theme, client, program_string, class_string, is_steam)
|
||||
|
||||
client = client or nil
|
||||
program_string = program_string or nil
|
||||
class_string = class_string or nil
|
||||
is_steam = is_steam or nil
|
||||
|
||||
if theme and (client or program_string or class_string) then
|
||||
local clientName
|
||||
if type(c) == "string" then
|
||||
if c:match("com.*%a") ~= nil then
|
||||
c = c:gsub("com.", ""):gsub(".Client", ""):gsub("flatpak", ""):gsub("run", ""):gsub(" ", "")
|
||||
end
|
||||
end
|
||||
if is_steam then
|
||||
clientName = "steam_icon_" .. tostring(c) .. ".svg"
|
||||
else
|
||||
if c.class ~= nil then
|
||||
clientName = string.lower(c.class) .. ".svg"
|
||||
elseif c.name ~= nil then
|
||||
clientName = string.lower(c.name) .. ".svg"
|
||||
elseif type(c) == "string" then
|
||||
clientName = c .. ".svg"
|
||||
clientName = "steam_icon_" .. tostring(client) .. ".svg"
|
||||
elseif client then
|
||||
if client.class then
|
||||
clientName = string.lower(client.class) .. ".svg"
|
||||
elseif client.name then
|
||||
clientName = string.lower(client.name) .. ".svg"
|
||||
elseif type(client) == "string" then
|
||||
clientName = client .. ".svg"
|
||||
else
|
||||
return
|
||||
if client.icon == nil then
|
||||
return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg"
|
||||
else
|
||||
return client.icon
|
||||
end
|
||||
end
|
||||
else
|
||||
if program_string then
|
||||
clientName = program_string .. ".svg"
|
||||
else
|
||||
clientName = class_string .. ".svg"
|
||||
end
|
||||
end
|
||||
|
||||
for index, icon in ipairs(icon_cache) do
|
||||
if icon:match(clientName) then
|
||||
return icon
|
||||
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/"
|
||||
local ioStream = io.open(iconDir .. clientName, "r")
|
||||
if ioStream ~= nil then
|
||||
icon_cache[#icon_cache + 1] = iconDir .. clientName
|
||||
return iconDir .. clientName
|
||||
else
|
||||
clientName = clientName:gsub("^%l", string.upper)
|
||||
iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/"
|
||||
ioStream = io.open(iconDir .. clientName, "r")
|
||||
if ioStream ~= nil then
|
||||
icon_cache[#icon_cache + 1] = iconDir .. clientName
|
||||
return iconDir .. clientName
|
||||
elseif type(c) ~= type("") then
|
||||
if pcall(
|
||||
function()
|
||||
if c:Get_icon(1) then
|
||||
error("icon error")
|
||||
else
|
||||
return c:Get_icon(1)
|
||||
end
|
||||
end
|
||||
) then
|
||||
return nil
|
||||
else
|
||||
clientName = class_string .. ".svg"
|
||||
iconDir = "/usr/share/icons/" .. theme .. "/" .. res .. "/apps/"
|
||||
ioStream = io.open(iconDir .. clientName, "r")
|
||||
if ioStream ~= nil then
|
||||
icon_cache[#icon_cache + 1] = iconDir .. clientName
|
||||
return iconDir .. clientName
|
||||
else
|
||||
return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if c.icon == nil then
|
||||
return "/usr/share/icons/Papirus-Dark/128x128/apps/application-default-icon.svg"
|
||||
else
|
||||
return c.icon
|
||||
if client then
|
||||
return client:Get_icon(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--———————————No swiches?———————————
|
||||
--⠀⣞⢽⢪⢣⢣⢣⢫⡺⡵⣝⡮⣗⢷⢽⢽⢽⣮⡷⡽⣜⣜⢮⢺⣜⢷⢽⢝⡽⣝
|
||||
--⠸⡸⠜⠕⠕⠁⢁⢇⢏⢽⢺⣪⡳⡝⣎⣏⢯⢞⡿⣟⣷⣳⢯⡷⣽⢽⢯⣳⣫⠇
|
||||
--⠀⠀⢀⢀⢄⢬⢪⡪⡎⣆⡈⠚⠜⠕⠇⠗⠝⢕⢯⢫⣞⣯⣿⣻⡽⣏⢗⣗⠏⠀
|
||||
--⠀⠪⡪⡪⣪⢪⢺⢸⢢⢓⢆⢤⢀⠀⠀⠀⠀⠈⢊⢞⡾⣿⡯⣏⢮⠷⠁⠀⠀
|
||||
--⠀⠀⠀⠈⠊⠆⡃⠕⢕⢇⢇⢇⢇⢇⢏⢎⢎⢆⢄⠀⢑⣽⣿⢝⠲⠉⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⠀⡿⠂⠠⠀⡇⢇⠕⢈⣀⠀⠁⠡⠣⡣⡫⣂⣿⠯⢪⠰⠂⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⡦⡙⡂⢀⢤⢣⠣⡈⣾⡃⠠⠄⠀⡄⢱⣌⣶⢏⢊⠂⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⢝⡲⣜⡮⡏⢎⢌⢂⠙⠢⠐⢀⢘⢵⣽⣿⡿⠁⠁⠀⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⠨⣺⡺⡕⡕⡱⡑⡆⡕⡅⡕⡜⡼⢽⡻⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⣼⣳⣫⣾⣵⣗⡵⡱⡡⢣⢑⢕⢜⢕⡝⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⣴⣿⣾⣿⣿⣿⡿⡽⡑⢌⠪⡢⡣⣣⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⡟⡾⣿⢿⢿⢵⣽⣾⣼⣘⢸⢸⣞⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
--⠀⠀⠀⠀⠁⠇⠡⠩⡫⢿⣝⡻⡮⣒⢽⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
--—————————————————————————————
|
||||
|
||||
@@ -60,8 +60,7 @@ return function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[
|
||||
SINK="$(pacmd stat | awk -F": " '/^Default sink name: /{print $2}')"
|
||||
|
||||
echo $(pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'$SINK'>"} /^\s+volume: / && indefault {print $5; exit}')
|
||||
echo $(pacmd list-sinks | awk '/^\s+name: /{indefault = $2 == "<'$SINK'>"} /^\s+volume: / && indefault {print $5; exit}')
|
||||
]],
|
||||
function(stdout)
|
||||
local icon = icondir .. "volume"
|
||||
|
||||
@@ -7,7 +7,6 @@ local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
require("src.core.signals")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user