improve widget rendering and use wibox.widget wrapper
This commit is contained in:
parent
78fa8e629d
commit
52590602d9
|
@ -3,27 +3,37 @@ local awful = require("awful")
|
|||
local naughty = require("naughty")
|
||||
local watch = require("awful.widget.watch")
|
||||
|
||||
battery_widget = wibox.widget { widget = wibox.widget.imagebox }
|
||||
|
||||
-- acpi sample outputs
|
||||
-- Battery 0: Discharging, 75%, 01:51:38 remaining
|
||||
-- Battery 0: Charging, 53%, 00:57:43 until charged
|
||||
|
||||
local path_to_icons = "/usr/share/icons/Arc/panel/22/"
|
||||
battery_widget = wibox.widget {
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = false
|
||||
},
|
||||
layout = wibox.container.margin(brightness_icon, 0, 0, 3),
|
||||
set_image = function(self, path)
|
||||
self.icon.image = path
|
||||
end
|
||||
}
|
||||
|
||||
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
|
||||
|
||||
watch(
|
||||
"acpi", 10,
|
||||
function(widget, stdout, stderr, exitreason, exitcode)
|
||||
local batteryType
|
||||
local _, status, charge, time = string.match(stdout, '(.+): (%a+), (%d%d)%%, (.+)')
|
||||
local _, status, charge, time = string.match(stdout, '(.+): (%a+), (%d?%d%d)%%,? ?.*')
|
||||
charge = tonumber(charge)
|
||||
if (charge >= 0 and charge < 15) then
|
||||
batteryType="battery-empty"
|
||||
show_battery_warning()
|
||||
elseif (charge >= 15 and charge < 40) then batteryType="battery-caution"
|
||||
elseif (charge >= 40 and charge < 60) then batteryType="battery-low"
|
||||
elseif (charge >= 60 and charge < 80) then batteryType="battery-good"
|
||||
elseif (charge >= 80 and charge <= 100) then batteryType="battery-full"
|
||||
elseif (charge >= 15 and charge < 40) then batteryType="battery-caution-symbolic"
|
||||
elseif (charge >= 40 and charge < 60) then batteryType="battery-low-symbolic"
|
||||
elseif (charge >= 60 and charge < 80) then batteryType="battery-good-symbolic"
|
||||
elseif (charge >= 80 and charge <= 100) then batteryType="battery-full-symbolic"
|
||||
end
|
||||
if status == 'Charging' then
|
||||
batteryType = batteryType .. '-charging'
|
||||
|
@ -47,13 +57,15 @@ end
|
|||
|
||||
function show_battery_warning()
|
||||
naughty.notify{
|
||||
icon = "/home/pashik/.config/awesome/nichosi.png",
|
||||
icon_size=100,
|
||||
text = "Huston, we have a problem",
|
||||
title = "Battery is dying",
|
||||
timeout = 5, hover_timeout = 0.5,
|
||||
position = "bottom_right",
|
||||
bg = "#F06060",
|
||||
fg = "#EEE9EF",
|
||||
width = 200,
|
||||
width = 300,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -1,12 +1,19 @@
|
|||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
local watch = require("awful.widget.watch")
|
||||
|
||||
brightness_widget = wibox.widget.textbox()
|
||||
brightness_widget:set_font('Play 9')
|
||||
|
||||
brightness_icon = wibox.widget.imagebox()
|
||||
brightness_icon:set_image("/usr/share/icons/Arc/actions/22/object-inverse.png")
|
||||
brightness_icon = wibox.widget {
|
||||
{
|
||||
image = "/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
layout = wibox.container.margin(brightness_icon, 0, 0, 3)
|
||||
}
|
||||
|
||||
watch(
|
||||
"xbacklight -get", 1,
|
||||
|
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 817 B After Width: | Height: | Size: 824 B |
|
@ -1,26 +1,34 @@
|
|||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
local wibox = require("wibox")
|
||||
local watch = require("awful.widget.watch")
|
||||
local gears = require("gears")
|
||||
|
||||
function update_volume()
|
||||
awful.spawn.easy_async([[bash -c 'amixer -D pulse sget Master']],
|
||||
function(stdout, stderr, reason, exit_code)
|
||||
local volume = string.match(stdout, "(%d?%d?%d)%%")
|
||||
volume = tonumber(string.format("% 3d", volume))
|
||||
local volume_icon_name
|
||||
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
|
||||
|
||||
if (volume >= 0 and volume < 20) then volume_icon_name="audio-volume-none-panel"
|
||||
elseif (volume >= 20 and volume < 40) then volume_icon_name="audio-volume-zero-panel"
|
||||
elseif (volume >= 40 and volume < 60) then volume_icon_name="audio-volume-low-panel"
|
||||
elseif (volume >= 60 and volume < 80) then volume_icon_name="audio-volume-medium-panel"
|
||||
elseif (volume >= 80 and volume <= 100) then volume_icon_name="audio-volume-high-panel"
|
||||
end
|
||||
volume_icon:set_image("/usr/share/icons/Arc/panel/22/" .. volume_icon_name .. ".svg")
|
||||
end)
|
||||
end
|
||||
volume_widget = wibox.widget {
|
||||
{
|
||||
id = "icon",
|
||||
image = path_to_icons .. "audio-volume-muted-symbolic.svg",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
layout = wibox.container.margin(brightness_icon, 0, 0, 3),
|
||||
set_image = function(self, path)
|
||||
self.icon.image = path
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
volume_icon = wibox.widget.imagebox()
|
||||
|
||||
mytimer = timer({ timeout = 0.2 })
|
||||
mytimer:connect_signal("timeout", function () update_volume() end)
|
||||
mytimer:start()
|
||||
watch(
|
||||
'amixer -D pulse sget Master', 1,
|
||||
function(widget, stdout, stderr, reason, exit_code)
|
||||
local volume = string.match(stdout, "(%d?%d?%d)%%")
|
||||
volume = tonumber(string.format("% 3d", volume))
|
||||
local volume_icon_name
|
||||
if (volume >= 0 and volume < 25) then volume_icon_name="audio-volume-muted-symbolic"
|
||||
elseif (volume >= 25 and volume < 50) then volume_icon_name="audio-volume-low-symbolic"
|
||||
elseif (volume >= 50 and volume < 75) then volume_icon_name="audio-volume-medium-symbolic"
|
||||
elseif (volume >= 75 and volume <= 100) then volume_icon_name="audio-volume-high-symbolic"
|
||||
end
|
||||
volume_widget.image = path_to_icons .. volume_icon_name .. ".svg"
|
||||
end
|
||||
)
|
Loading…
Reference in New Issue