0

In my 'rc.lua' file I currently have the following code:

naughty.notify({                                                                           
    preset = naughty.config.presets.info,                                               
    text = "MPC: Play!",                                                                   
    icon = "/home/user/.config/awesome/icons/mpd.png",                                                              
    icon_size = 20,                                                                       
    }) 

How can make the following icon path work, instead?

icon = "~/.config/awesome/icons/mpd.png",
King110
  • 122
  • 8

1 Answers1

3

If awesome-wm does not have direct support for this, use

icon = os.getenv("HOME").."/.config/awesome/icons/mpd.png"

or

icon = string.gsub("~/.config/awesome/icons/mpd.png", "~", os.getenv("HOME"))
lhf
  • 70,581
  • 9
  • 108
  • 149
  • Any reason why `string.gsub` would be better than the direct `os.getenv("HOME")` approach? Expanding ~ in the middle of a path is wrong and I think the first version is more readable. – Uli Schlachter May 07 '17 at 08:22
  • 1
    @UliSchlachter, I had things like this in mind: `path = ~/one/path:~/another/path`, but for an `icon` this is overkill. – lhf May 07 '17 at 11:08