1

I'm creating a widget for Awesome based on playerctl. When i test with awesomeclient it works fine.

awesome-client '

local stdout = "Playing;Eurythmics;Miracle of Love;file:///home/mgaber/Workbench/awesome/stags1.7/testing/173308_26.png"

local words = {}
for w in stdout:gmatch("([^;]*)") do
    print(w)
    table.insert(words, w)
end

mpdstatus = words[1]
current_song = words[2]
artist = words[3]
song_art = words[4]

a,b,c = 1, 2, 3

local song_art = string.sub( song_art,8, -1)

local awful = require("awful");
local gears = require("gears")
local naughty= require("naughty"); 
local bubble =function(cr, w, h)
        return gears.shape.infobubble(cr, w, h, 20, 10, w/2 - 30)
    end
naughty.notification(
{
margin = 15,
position = "top_left",
width = 640,
height = 160,
title = mpdstatus,
text=current_song .. " By " .. artist .. a .. c,
image = song_art});

'

However when i put the code in rc.lua the icon doesn't appear, I tested and my code works as supposed to and the image file is passed to naughty.notification..

    local function show_MPD_status()
        spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _)
            -- notification = naughty.notification {
            naughty.notification {
                margin = 10,
                timeout = 5,
                hover_timeout = 0.5,
                width = auto,
                height = auto,
                title = mpdstatus,
                text = current_song .. " by " .. artist,
                image = artUr
            }
        end)
    end

Awesome Version

$ awesome --version             
awesome v4.3-895-g538586c17-dirty (Too long)
 • Compiled against Lua 5.3.6 (running with Lua 5.3)
 • API level: 4
 • D-Bus support: yes
 • xcb-errors support: yes
 • execinfo support: yes
 • xcb-randr version: 1.6
 • LGI version: 0.9.2
 • Transparency enabled: yes
 • Custom search paths: no

I get a notification displaying "Status" Song by Artist with no image or icon.

Thanks

Gabe
  • 91
  • 1
  • 7

2 Answers2

1

I think it's a Lua version issue. I don't know the specifics, but it runs fine on Lua 5.3 and 5.4 - wheras within LuaJIT, Lua 5.1 and 5.2 you see the same lack of artist and song art that you mention. Do you happen to know what version of Lua your AwesomeWM is compiled against?

#! /usr/bin/env lua
print( _VERSION )

local stdout  = 'Playing;Eurythmics;Miracle of Love;file:///home/mgaber/Workbench/awesome/stags1.7/testing/173308_26.png'

local words  = {}
for w in stdout :gmatch( '([^;]*)' ) do
    if #w > 0 then
        print( w )
        words [#words +1] = w
    end
end

local mpdstatus  = words[1]     ; print( mpdstatus )
local current_song  = words[2]    ; print( current_song )
local artist  = words[3]            ; print( artist )
local song_art  = words[4] :sub( 8 )  ; print( song_art )

local awful  = require('awful')
local gears  = require('gears')
local naughty  = require('naughty')

local bubble  = function( cr, w, h )
    return gears .shape .infobubble( cr, w, h, 20, 10, w /2 -30 )
end

naughty .notification(  {
    margin  = 15,
    position  = 'top_left',
    width  = 640,
    height  = 160,
    title  = mpdstatus,
    text  = current_song ..' By ' ..artist,
    image  = song_art  }  )

Edit:

It's putting more entries in your words list than expected. Filter out blank entries.

Doyousketch2
  • 2,060
  • 1
  • 11
  • 11
  • I checked .. `$ awesome --version awesome v4.3-895-g538586c17-dirty (Too long) • Compiled against Lua 5.3.6 (running with Lua 5.3) • API level: 4 • D-Bus support: yes • xcb-errors support: yes • execinfo support: yes • xcb-randr version: 1.6 • LGI version: 0.9.2 • Transparency enabled: yes • Custom search paths: no` – Gabe Nov 23 '20 at 22:08
  • 1
    Asking for additional information should be done in comments. Please don't post answers unless you're actually answering the question. Posting large chunks of code without explaining the differences is also not very productive, specially for others finding this question in the future. – DarkWiiPlayer Nov 24 '20 at 07:10
  • @MohammedGaber When providing additional information, it's often better to edit your original question, so other users trying to help can more quickly see the new information. – DarkWiiPlayer Nov 24 '20 at 07:18
0

I finally managed to sort this out. The problem was caused by a Widget template that shapes the notification and was misconfigured, removing the template fixed it

Gabe
  • 91
  • 1
  • 7