Потрясающие непослушные уведомления

Я создаю виджет для Awesome на основе playerctl. Когда я тестирую awesomeclient, он работает нормально.

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});

'

Однако, когда я помещаю код в rc.lua, значок не появляется, я проверил, и мой код работает, как предполагалось, и файл изображения передается в 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 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

Я получаю уведомление, отображающее Статусную песню по исполнителю без изображения или значка.

Спасибо


person Gabe    schedule 23.11.2020    source источник


Ответы (2)


Я думаю, что это проблема версии Lua. Я не знаю подробностей, но он отлично работает на Lua 5.3 и 5.4, тогда как в LuaJIT, Lua 5.1 и 5.2 вы видите то же отсутствие артиста и обложки песни, о которой вы упоминаете. Вы случайно не знаете, для какой версии Lua скомпилирован ваш AwesomeWM?

#! /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  }  )

Изменить:

Он помещает больше записей в ваш список слов, чем ожидалось. Отфильтруйте пустые записи.

person Doyousketch2    schedule 23.11.2020
comment
Я проверил.. $ 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 - person Gabe; 24.11.2020
comment
Запрашивать дополнительную информацию следует в комментариях. Пожалуйста, не публикуйте ответы, если вы на самом деле не отвечаете на вопрос. Публикация больших кусков кода без объяснения различий также не очень продуктивна, особенно для других, которые найдут этот вопрос в будущем. - person DarkWiiPlayer; 24.11.2020
comment
@MohammedGaber При предоставлении дополнительной информации часто лучше отредактировать исходный вопрос, чтобы другие пользователи, пытающиеся помочь, могли быстрее увидеть новую информацию. - person DarkWiiPlayer; 24.11.2020

Наконец-то мне удалось разобраться в этом. Проблема была вызвана тем, что шаблон виджета, который формирует уведомление, был неправильно настроен, удаление шаблона устранило проблему.

person Gabe    schedule 25.11.2020