令人惊叹的淘气通知
2020-11-25 15:33:6
收藏:0
阅读:133
评论:2
我正在为 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 版本
$ awesome --version
awesome v4.3-895-g538586c17-dirty (太长)
• 编译Lua 5.3.6(运行Lua 5.3)
• API级别:4
• D-Bus支持:有
• xcb-errors支持:有
• execinfo支持:有
• xcb-randr版本:1.6
• LGI版本:0.9.2
• 透明度启用:有
• 自定义搜索路径:无
我得到了一个显示“状态”、“歌曲”和“艺术家”的通知,但没有图像或图标。
感谢
点赞
用户10700322
我终于成功解决了这个问题。
问题是由于告知形状的小部件模板被错误配置所引起的,移除该模板后问题得到了修复。
2020-11-25 21:09:29
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

我认为这是 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 })编辑:
它在单词列表中放入了比预期更多的条目。过滤掉空条目。