【问题标题】:Awesome naughty notifications令人敬畏的顽皮通知
【发布时间】:2021-03-06 15:07:37
【问题描述】:

我正在基于 playerctl 为 Awesome 创建一个小部件。 当我使用 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

我收到一条显示通知 “状态” 艺术家的歌曲,没有图像或图标。

谢谢

【问题讨论】:

    标签: lua notifications awesome-wm


    【解决方案1】:

    我认为这是 Lua 版本的问题。我不知道具体细节,但它在 Lua 5.3 和 5.4 上运行良好——而在 LuaJIT、Lua 5.1 和 5.2 中,你会看到你提到的同样缺乏艺术家和歌曲艺术。您是否碰巧知道您的 AwesomeWM 是针对哪个版本的 Lua 编译的?

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

    编辑:

    您的单词列表中的条目比预期的要多。过滤掉空白条目。

    【讨论】:

    • 我检查了..$ 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
    • 询问更多信息应在 cmets 中完成。除非您确实在回答问题,否则请不要发布答案。在不解释差异的情况下发布大量代码也不是很有效率,特别是对于将来发现这个问题的其他人。
    • @MohammedGaber 在提供其他信息时,最好编辑您的原始问题,以便其他尝试提供帮助的用户可以更快地看到新信息。
    【解决方案2】:

    我终于设法解决了这个问题。 问题是由塑造通知的 Widget 模板引起的,并且配置错误,删除模板修复了它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-10
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 2017-08-14
      • 1970-01-01
      • 2015-12-17
      相关资源
      最近更新 更多