From 83376adcfa67d16f073e883f116116dd0efb7a0a Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 22 Feb 2020 13:19:01 -0500 Subject: [battery-widget] make path to the icons customizable (#102) --- battery-widget/README.md | 24 ++++++++++++++++++++---- battery-widget/battery.lua | 10 +++++----- battery-widget/spaceman.jpg | Bin 0 -> 16738 bytes 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 battery-widget/spaceman.jpg (limited to 'battery-widget') diff --git a/battery-widget/README.md b/battery-widget/README.md index 710f8b2..d5eb233 100644 --- a/battery-widget/README.md +++ b/battery-widget/README.md @@ -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 diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua index ae7f9e7..b1a322c 100644 --- a/battery-widget/battery.lua +++ b/battery-widget/battery.lua @@ -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$", "") diff --git a/battery-widget/spaceman.jpg b/battery-widget/spaceman.jpg new file mode 100644 index 0000000..73ddaf3 Binary files /dev/null and b/battery-widget/spaceman.jpg differ -- cgit v1.2.3