AwesomeWM 中的颜色和值在进度条和其他 wibox 小部件中不会更新。

huangapple go评论51阅读模式
英文:

AwesomeWM colors and values in progressbar and other wibox widgets do not update

问题

I set up signals and functions to update colors of my container.background widgets and also one to update progressbar value and color according to battery level, but it doesnt work, any manipulations with widgets seems not working except changing text in text widgets.

I've tried many other's people solutions found on github. None of them worked.
I've set up signals for monitoring wifi connection and battery, also functions that called to update status bars for sound and brightness but none of it works. But text fields update just fine.
OS - Arch installed awesome from pacman. Here's my code of battery progress bar:

local battery_progress_bar = {
	color = beautiful.cred,
	max_value     = 100,
	value = 50,
	forced_width = 100,
	widget        = wibox.widget.progressbar,
}
local update_battery_bar = function(charge)
	battery_progress_bar.color = beautiful.cgreen
    -- Color doesn't change for some reason
	battery_progress_bar.value = charge
	text_bl_icon.text = charge 
    -- I've set this text widget just to see if right value is passed from my script
    -- this value changes and works perfectly, but progressbar doesn't
end

local function battery_emit()
  awful.spawn.easy_async_with_shell(
    battery_script, function(stdout)
    local level     = string.match(stdout:match('(%d+)'), '(%d+)')
    local level_int = tonumber(level) -- integer
    awesome.emit_signal('signal::battery', level_int)
  end)
end

-- Refreshing
-------------
gears.timer {
  timeout   = 20,
  call_now  = true,
  autostart = true,
  callback  = function()
    battery_emit()
  end
}

awesome.connect_signal("signal::battery", function(value)
	update_battery_bar(value)
end)

Also i'm sure that cgreen color that i use is defined and working if i will assign it to progress bar color at its initialization. Signal is actually emitting and triggering update function because the number in text field changes.

英文:

I set up signals and functions to update colors of my container.background widgets and also one to update progressbar value and color according to battery level, but it doesnt work, any manipulations with widgets seems not working except changing text in text widgets.

I've tried many other's people solutions found on github. None of them worked.
I've set up signals for monitoring wifi connection and battery, also functions that called to update status bars for sound and brightness but none of it works. But text fields update just fine.
OS - Arch installed awesome from pacman. Here's my code of battery progress bar:

local battery_progress_bar = {
	color = beautiful.cred,
	max_value     = 100,
	value = 50,
	forced_width = 100,
	widget        = wibox.widget.progressbar,
}
local update_battery_bar = function(charge)
	battery_progress_bar.color = beautiful.cgreen
        -- Color doesn't change for some reason
	battery_progress_bar.value = charge
	text_bl_icon.text = charge 
    -- ive set this text widget just to see if right value is passed from my script
    -- this value changes and works perfectly, but progressbar doesnt
end

local function battery_emit()
  awful.spawn.easy_async_with_shell(
    battery_script, function(stdout)
    local level     = string.match(stdout:match('(%d+)'), '(%d+)')
    local level_int = tonumber(level) -- integer
    awesome.emit_signal('signal::battery', level_int)
  end)
end

-- Refreshing
-------------
gears.timer {
  timeout   = 20,
  call_now  = true,
  autostart = true,
  callback  = function()
    battery_emit()
  end
}

awesome.connect_signal("signal::battery", function(value)
	update_battery_bar(value)
end)

Also i'm sure that cgreen color that i use is defined and working if i will asign it to progress bar color at its initialization. Signal is actually emitting and triggering update function because number in text field changes.

答案1

得分: 1

解决方案是,我在提供的代码中使用了表格,但为了动态更改值,我需要将它们转换为小部件。

local battery_progress_bar = wibox.widget {
    color = beautiful.cred,
    max_value     = 100,
    value = 50,
    forced_width = 100,
    widget        = wibox.widget.progressbar,
}

而且,所有我的文本框小部件都被转换了,这就是为什么它们有效而其他东西都不起作用的原因。希望这会帮助那些可能会因为什么都不起作用,不知道如何修复或甚至搜索不到相关信息而几乎放弃使用 awesome wm 的人。

英文:

The solution was that i'm using tables in provided code, but in order to change the values dynamically i need to convert them to widgets

local battery_progress_bar = wibox.widget {
    color = beautiful.cred,
    max_value     = 100,
    value = 50,
    forced_width = 100,
    widget        = wibox.widget.progressbar,
}

And also, all of my textbox widgets were converted, that's why they worked while nothing other is. Hope this will help someone who otherwise would probably give up on idea of using awesome wm because nothing works, and don't know how to fix it or even google it.

huangapple
  • 本文由 发表于 2023年6月8日 04:32:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76426927.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定