简体   繁体   English

为什么 conky 中的 execbar 不使用变量

[英]Why is execbar in conky not working with a variable

execbar in conky does not seem to be working properly. conky 中的 execbar 似乎无法正常工作。

So if I do in a bash script (named myscript.sh)所以如果我在 bash 脚本中做(名为 myscript.sh)

# moc or mocp is Music on Console
totalsec=$(mocp --info | grep "TotalSec" | cut -d: -f2 | sed 's/^ //g' | sed 's/ $//g')
cursec=$(mocp --info | grep "CurrentSec" | cut -d: -f2 | sed 's/^ //g' | sed 's/ $//g')
progress=$(echo "(${cursec}*100/${totalsec})" | bc)
echo "\${execbar echo ${progress}}"
echo "${progress}" # This works and shows be the value of the integer variable.

and then call the bash script from conky using然后使用 conky 调用 bash 脚本

conky.text = [[${execpi 3 ./myscript.sh}]];

then progress bar is not shown.然后不显示进度条。 Only a white rectangle.只有一个白色的矩形。

However, if the same bash script is changed to但是,如果将相同的 bash 脚本更改为

progress=23
echo "\${execbar echo ${progress}}"

then it works and shows a constant bar of 23 .然后它工作并显示23的恒定条。 Don't know why passing a integer variable is not working.不知道为什么传递整数变量不起作用。 Any help to solve this problem will be appreciated.解决此问题的任何帮助将不胜感激。

It turns out that execbar in a bash script can be made to work.事实证明,可以使 bash 脚本中的execbar起作用。 Sort of.有点。

To focus the problem on just the variable issue, I made a little script (myscript2.sh) that just gets the seconds from the current time for display in the bar...为了将问题集中在变量问题上,我制作了一个小脚本(myscript2.sh),它只获取当前时间的秒数以显示在栏中......

#!/bin/bash
progress=$(date --date='now' +%S)
echo \${execbar echo ${progress}}

...and was able to get a periodically updated bar showing the seconds using this conky config file... ...并且能够使用这个 conky 配置文件定期更新显示秒数的栏...

conky.config = {
    alignment = 'top_left',
    minimum_width = 300,
    own_window = true,
    own_window_hints = 'below',
    own_window_type = 'desktop',
    own_window_argb_visual=true,
    own_window_transparent = true,
    update_interval = 2.0,
}

conky.text = [[
${execpi 3 ./myscript2.sh}
]]

However, conky alternates bewteen showing the bar filled to the proper extent and showing the bar empty.但是,conky 在显示条形图填充到适当程度和显示条形图空之间交替出现。 In other words, the display of the bar contents blinks on and off.换句话说,栏内容的显示闪烁。 Yuck.呸。

As an alternative, by using a script (myscript3.sh) to simply return the value to be displayed in the bar...作为替代方案,通过使用脚本 (myscript3.sh) 简单地返回要在栏中显示的值...

#!/bin/bash
progress=$(date --date='now' +%S)
echo $progress

...and changing the conky config file to use execibar rather than execpi ... ...并更改 conky 配置文件以使用execibar而不是execpi ...

conky.config = {
    alignment = 'top_left',
    minimum_width = 300,
    own_window = true,
    own_window_hints = 'below',
    own_window_type = 'desktop',
    own_window_argb_visual=true,
    own_window_transparent = true,
    update_interval = 2.0,
}

conky.text = [[
${execibar 3 ./myscript3.sh}
]]

...it appears to work as intended, without any blinking. ...它似乎按预期工作,没有任何闪烁。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM