【问题标题】:How to set a custom icon of any client for the tasklist in awesomeWM v3.5.6?如何在 awesomeWM v3.5.6 中为任务列表设置任何客户端的自定义图标?
【发布时间】:2015-06-08 16:40:02
【问题描述】:
if (c.class == "Google-chrome") then
     c.icon = capi.image ( "/home/art-attack/.config/awesome/icons/chrome.png" )
end

我试过了,但总是出错,即尝试调用字段“图像”(一个零值)

{ rule = { class = "Google-chrome" },
  properties = { icon = beautiful.icon_chrome } },

然后我找到了另一种方法来使用可怕的规则中的属性 icon 并且它有效但没有更改图标而是禁用了该客户端的图标。

【问题讨论】:

    标签: lua awesome-wm


    【解决方案1】:

    要修复您的第一次尝试,请尝试以下操作:

    if c.class == "Google-chrome" then
        local icon = gears.surface("path/to/chrome.png")
        c.icon = icon._native
        icon:finish()
    end
    

    icon:finish() 的行不是必需的,但它的存在是为了确保您不优化此代码。那里有一些你不想知道的黑暗垃圾收集避免魔法,但简短的故事是:永远不要使用_native,除非你已经将表面本身保存在一个变量中。

    【讨论】:

    • 我仍然遇到错误尝试索引全局“齿轮”(零值)
    • ohh.. 抱歉,我忘了在开头添加 local gears = require("gears") 非常感谢它运行良好,但显示错误,即 /usr/share/lua/5.1/lgi/record.lua:62: C 栈溢出
    【解决方案2】:
    if c.class == "Google-chrome" then
        local icon = gears.surface("path/to/chrome.png")
        return text, bg, bg_image, icon
    end
    

    在前面加上这段代码

    if capi.client.focus == c then
    

    【讨论】:

    • 它工作正常.. 但是文本无效 !IMAGE
    • 似乎文本无法自行初始化..所以我在此行之前使用了这段代码return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil,其中文本首先初始化并且它没有任何问题......谢谢你的回复
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 2014-02-06
    • 2015-09-26
    相关资源
    最近更新 更多