2
if (c.class == "Google-chrome") then
     c.icon = capi.image ( "/home/art-attack/.config/awesome/icons/chrome.png" )
end

I tried it but I always got an error i.e attempt to call field 'image' (a nil value)

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

Then I find another way to use properties icon in awful.rules and it worked but didn't change the icon instead it disabled the icon of that client.

talk2arpan
  • 23
  • 4

2 Answers2

5

To fix your first attempt, try this:

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

The line with icon:finish() is not necessary, but it exists to make sure you do not optimize this code. There is some dark garbage collection avoidance magic in there that you do not want to know, but the short story is: Never use _native unless you already have the surface itself saved in a variable.

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • still i got an error **attempt to index global 'gears' (a nil value)** – talk2arpan May 22 '15 at 06:30
  • ohh.. sory i forgot to add **local gears = require("gears")** at the beginning Thankx a lot it is working perfectly but an error is showing i.e **/usr/share/lua/5.1/lgi/record.lua:62: C stack overflow** – talk2arpan May 22 '15 at 06:35
0
if c.class == "Google-chrome" then
    local icon = gears.surface("path/to/chrome.png")
    return text, bg, bg_image, icon
end

Add this code before

if capi.client.focus == c then
  • it's working fine.. but text gets invalid **** ![IMAGE](http://oi60.tinypic.com/142gdbl.jpg) – talk2arpan Jun 10 '15 at 07:22
  • seems like text can't initialize itself.. so i took this code before this line `return text, bg, bg_image, not tasklist_disable_icon and c.icon or nil` where text initialized first and it worked without any issue... thkx for ur reply – talk2arpan Jun 10 '15 at 14:40