diff options
author | streetturtle <streetturtle@gmail.com> | 2017-02-03 22:15:16 -0500 |
---|---|---|
committer | streetturtle <streetturtle@gmail.com> | 2017-02-03 22:15:16 -0500 |
commit | 52590602d91d705c9a356359b56f45c55cb4d9d8 (patch) | |
tree | f4a185265c806459cf8e9a225730d1877eca42c3 | |
parent | 78fa8e629da7ea64ed54a2a8d6d08857b83e4324 (diff) |
improve widget rendering and use wibox.widget wrapper
-rw-r--r-- | battery-widget/battery.lua | 30 | ||||
-rw-r--r-- | brightness-widget/br-wid-1.png | bin | 1701 -> 1355 bytes | |||
-rw-r--r-- | brightness-widget/brightness.lua | 11 | ||||
-rw-r--r-- | screenshot.png | bin | 6764 -> 6287 bytes | |||
-rw-r--r-- | volume-widget/vol-widget-1.png | bin | 817 -> 824 bytes | |||
-rw-r--r-- | volume-widget/volume.lua | 52 |
6 files changed, 60 insertions, 33 deletions
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua index b2c78e7..2633ba2 100644 --- a/battery-widget/battery.lua +++ b/battery-widget/battery.lua @@ -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 diff --git a/brightness-widget/br-wid-1.png b/brightness-widget/br-wid-1.png Binary files differindex cb11b55..f9200eb 100644 --- a/brightness-widget/br-wid-1.png +++ b/brightness-widget/br-wid-1.png diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua index 59977d7..f003eca 100644 --- a/brightness-widget/brightness.lua +++ b/brightness-widget/brightness.lua @@ -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, diff --git a/screenshot.png b/screenshot.png Binary files differindex 4e26e4b..21d371c 100644 --- a/screenshot.png +++ b/screenshot.png diff --git a/volume-widget/vol-widget-1.png b/volume-widget/vol-widget-1.png Binary files differindex ba03630..6f09cce 100644 --- a/volume-widget/vol-widget-1.png +++ b/volume-widget/vol-widget-1.png diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 90251a6..c403dfd 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -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 - - 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 - +local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -volume_icon = wibox.widget.imagebox() +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 +} -mytimer = timer({ timeout = 0.2 }) -mytimer:connect_signal("timeout", function () update_volume() end) -mytimer:start()
\ No newline at end of file +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 +)
\ No newline at end of file |