fixed some widgets not displaying (simple fix: use tonumber())

This commit is contained in:
elena 2018-12-24 18:46:07 +02:00
parent 612ec52998
commit c737f4291c
3 changed files with 9 additions and 14 deletions

View file

@ -29,17 +29,16 @@ local battery_bar = wibox.widget{
}
local function update_widget(bat)
battery_bar.value = bat
battery_bar.value = tonumber(bat)
end
local bat_script = [[
bash -c '
upower -i $(upower -e | grep BAT) | grep percentage
']]
bash -c "
upower -i $(upower -e | grep BAT) | grep percentage | awk '{print $2}'
"]]
awful.widget.watch(bat_script, update_interval, function(widget, stdout)
local bat = stdout:match(':%s*(.*)..')
-- bat = string.gsub(bat, '^%s*(.-)%s*$', '%1')
local bat = stdout:gsub("%%", "")
update_widget(bat)
end)

View file

@ -29,7 +29,7 @@ local temperature_bar = wibox.widget{
}
local function update_widget(temp)
temperature_bar.value = temp
temperature_bar.value = tonumber(temp)
end
local temp_script = [[
@ -39,7 +39,6 @@ local temp_script = [[
awful.widget.watch(temp_script, update_interval, function(widget, stdout)
local temp = stdout
temp = string.gsub(temp, '^%s*(.-)%s*$', '%1')
update_widget(temp)
end)

View file

@ -7,6 +7,8 @@ local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
-- local xresources = require("beautiful.xresources")
-- local xrdb = xresources.get_current_theme()
-- Set colors
local active_color = beautiful.volume_bar_active_color or "#5AA3CC"
@ -46,18 +48,13 @@ local function update_widget()
fill_color = active_color
bg_color = active_background_color
end
volume_bar.value = volume
volume_bar.value = tonumber(volume)
volume_bar.color = fill_color
volume_bar.background_color = bg_color
end
)
end
-- Signals
-- volume_bar:connect_signal("mouse::enter", function ()
-- update_widget()
-- end)
update_widget()
-- Sleeps until pactl detects an event (volume up/down/toggle mute)