[battery-widget] make path to the icons customizable (#102)

This commit is contained in:
streetturtle 2020-02-22 13:19:01 -05:00
parent 5e519648e1
commit 83376adcfa
3 changed files with 25 additions and 9 deletions

View File

@ -21,16 +21,32 @@ It is possible to customize widget by providing a table with all or some of the
| Name | Default | Description |
|---|---|---|
| `font` | Font | Play 8 |
| `font` | Play 8 | Fond |
| `path_to_icons` | `/usr/share/icons/Arc/status/symbolic/` | Path to the folder with icons* |
| `show_current_level`| false | Show current charge level |
| `margin_right`|0| the right margin of the widget|
| `margin_left`|0| the left margin of the widget|
| `margin_right`|0| The right margin of the widget|
| `margin_left`|0| The left margin of the widget|
| `notification` | `false` | Display a notification on mouseover |
| `notification_position` | `top_right` | The notification position |
| `warning_msg_title` | _Huston, we have a problem_ | Title of the warning popup |
| `warning_msg_text` | _Battery is dying_ | Text of the warning popup |
| `warning_msg_position` | `bottom_right` | Position of the warning popup |
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg | Icon of the warning popup |
| `warning_msg_icon` | ~/.config/awesome/awesome-wm-widgets/battery-widget/spaceman.jpg | Icon of the warning popup |
*Note: the widget expects following icons be present in the folder:
- battery-caution-charging-symbolic.svg
- battery-empty-charging-symbolic.svg
- battery-full-charged-symbolic.svg
- battery-full-symbolic.svg
- battery-good-symbolic.svg
- battery-low-symbolic.svg
- battery-caution-symbolic.svg
- battery-empty-symbolic.svg
- battery-full-charging-symbolic.svg
- battery-good-charging-symbolic.svg
- battery-low-charging-symbolic.svg
- battery-missing-symbolic.svg
## Installation

View File

@ -19,7 +19,6 @@ local dpi = require('beautiful').xresources.apply_dpi
-- 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/status/symbolic/"
local HOME = os.getenv("HOME")
local battery_widget = {}
@ -27,6 +26,7 @@ local function worker(args)
local args = args or {}
local font = args.font or 'Play 8'
local path_to_icons = args.path_to_icons or "/usr/share/icons/Arc/status/symbolic/"
local show_current_level = args.show_current_level or false
local margin_left = args.margin_left or 0
local margin_right = args.margin_right or 0
@ -39,10 +39,10 @@ local function worker(args)
local warning_msg_position = args.warning_msg_position or 'bottom_right'
local warning_msg_icon = args.warning_msg_icon or HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg'
if not gfs.dir_readable(PATH_TO_ICONS) then
if not gfs.dir_readable(path_to_icons) then
naughty.notify{
title = "Battery Widget",
text = "Folder with icons doesn't exist: " .. PATH_TO_ICONS,
text = "Folder with icons doesn't exist: " .. path_to_icons,
preset = naughty.config.presets.critical
}
end
@ -75,7 +75,7 @@ local function worker(args)
notification = naughty.notify{
text = stdout,
title = "Battery status",
icon = PATH_TO_ICONS .. batteryType .. ".svg",
icon = path_to_icons .. batteryType .. ".svg",
icon_size = dpi(16),
position = position,
timeout = 5, hover_timeout = 0.5,
@ -167,7 +167,7 @@ local function worker(args)
batteryType = string.format(batteryType, '')
end
widget.icon:set_image(PATH_TO_ICONS .. batteryType .. ".svg")
widget.icon:set_image(path_to_icons .. batteryType .. ".svg")
-- Update popup text
-- battery_popup.text = string.gsub(stdout, "\n$", "")

BIN
battery-widget/spaceman.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB