summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/FUNDING.yml1
-rw-r--r--README.md7
-rw-r--r--batteryarc-widget/README.md1
-rw-r--r--batteryarc-widget/batteryarc.lua48
-rw-r--r--bitbucket-widget/README.md16
-rw-r--r--calendar-widget/README.md4
-rw-r--r--calendar-widget/calendar.lua18
-rw-r--r--docker-widget/docker.lua118
-rw-r--r--docker-widget/icons/trash-btn.svg1
-rw-r--r--fs-widget/README.md27
-rw-r--r--fs-widget/fs-widget.lua5
-rw-r--r--fs-widget/out.gifbin103946 -> 0 bytes
-rw-r--r--fs-widget/screenshot.pngbin0 -> 20958 bytes
-rw-r--r--ram-widget/ram-widget.lua71
-rw-r--r--word-clock-widget/README.md74
-rw-r--r--word-clock-widget/screenshots/halfpastthree.pngbin0 -> 2291 bytes
-rw-r--r--word-clock-widget/screenshots/halfpastthree_color.pngbin0 -> 2274 bytes
-rw-r--r--word-clock-widget/screenshots/onetwentyseven.pngbin0 -> 2326 bytes
-rw-r--r--word-clock-widget/screenshots/testpasttwentyone.pngbin0 -> 2926 bytes
-rw-r--r--word-clock-widget/screenshots/twentythreepastnine.pngbin0 -> 3234 bytes
-rw-r--r--word-clock-widget/screenshots/twentythreepasttwentyone.pngbin0 -> 3959 bytes
-rw-r--r--word-clock-widget/word-clock.lua137
22 files changed, 428 insertions, 100 deletions
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..5bd55b0
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1 @@
+github: streetturtle
diff --git a/README.md b/README.md
index 6704489..075db43 100644
--- a/README.md
+++ b/README.md
@@ -57,3 +57,10 @@ Clone the repo under **~/.config/awesome/**, then follow an Installation section
# Stargazers
[![Stargazers over time](https://starchart.cc/streetturtle/awesome-wm-widgets.svg)](https://starchart.cc/streetturtle/awesome-wm-widgets)
+
+# Support
+
+If you find anything useful here, you can:
+ - star a repo - this really motivates me to work on this project
+ - or <a class="social-link" href="https://www.buymeacoffee.com/streetturtle"><img style="display:inline" src="https://img.shields.io/badge/-buy%20me%20a%20coffee-3B4252?style=flat&logo=Buy-Me-A-Coffee"></a>
+ - or even become a [sponsor](https://github.com/sponsors/streetturtle)
diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md
index 1a2a397..a257b2f 100644
--- a/batteryarc-widget/README.md
+++ b/batteryarc-widget/README.md
@@ -38,6 +38,7 @@ It is possible to customize widget by providing a table with all or some of the
| `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 |
| `enable_battery_warning` | `true` | Display low battery warning |
+| `show_notification_mode` | `on_hover` | How to trigger a notification with the battery status: `on_hover`, `on_click` or `off` |
## Requirements
diff --git a/batteryarc-widget/batteryarc.lua b/batteryarc-widget/batteryarc.lua
index 916c7b1..858d3b3 100644
--- a/batteryarc-widget/batteryarc.lua
+++ b/batteryarc-widget/batteryarc.lua
@@ -27,6 +27,7 @@ local function worker(args)
local show_current_level = args.show_current_level or false
local size = args.size or 18
local timeout = args.timeout or 10
+ local show_notification_mode = args.show_notification_mode or 'on_hover' -- on_hover / on_click
local main_color = args.main_color or beautiful.fg_color
local bg_color = args.bg_color or '#ffffff11'
@@ -67,6 +68,22 @@ local function worker(args)
local last_battery_check = os.time()
+ --[[ Show warning notification ]]
+ local function show_battery_warning()
+ naughty.notify {
+ icon = warning_msg_icon,
+ icon_size = 100,
+ text = warning_msg_text,
+ title = warning_msg_title,
+ timeout = 25, -- show the warning for a longer time
+ hover_timeout = 0.5,
+ position = warning_msg_position,
+ bg = "#F06060",
+ fg = "#EEE9EF",
+ width = 300,
+ }
+ end
+
local function update_widget(widget, stdout)
local charge = 0
local status
@@ -119,7 +136,7 @@ local function worker(args)
-- Popup with battery info
local notification
- function show_battery_status()
+ local function show_battery_status()
awful.spawn.easy_async([[bash -c 'acpi']],
function(stdout, _, _, _)
naughty.destroy(notification)
@@ -127,33 +144,18 @@ local function worker(args)
text = stdout,
title = "Battery status",
timeout = 5,
- hover_timeout = 0.5,
width = 200,
}
end)
end
- widget:connect_signal("mouse::enter", function()
- show_battery_status()
- end)
- widget:connect_signal("mouse::leave", function()
- naughty.destroy(notification)
- end)
-
- --[[ Show warning notification ]]
- function show_battery_warning()
- naughty.notify {
- icon = warning_msg_icon,
- icon_size = 100,
- text = warning_msg_text,
- title = warning_msg_title,
- timeout = 25, -- show the warning for a longer time
- hover_timeout = 0.5,
- position = warning_msg_position,
- bg = "#F06060",
- fg = "#EEE9EF",
- width = 300,
- }
+ if show_notification_mode == 'on_hover' then
+ widget:connect_signal("mouse::enter", function() show_battery_status() end)
+ widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
+ elseif show_notification_mode == 'on_click' then
+ widget:connect_signal('button::press', function(_, _, _, button)
+ if (button == 1) then show_battery_status() end
+ end)
end
return widget
diff --git a/bitbucket-widget/README.md b/bitbucket-widget/README.md
index a0cae0a..7f82e73 100644
--- a/bitbucket-widget/README.md
+++ b/bitbucket-widget/README.md
@@ -4,9 +4,9 @@ The widget shows the number of pull requests assigned to the user and when click
## How it works
-Widget uses cURL to query Bitbucket's [REST API](https://developer.atlassian.com/bitbucket/api/2/reference/). In order to be authenticated, widget uses a [netrc](https://ec.haxx.se/usingcurl/usingcurl-netrc) feature of the cURL, which is basically to store basic auth credentials in a .netrc file in home folder.
+Widget uses cURL to query Bitbucket's [REST API](https://developer.atlassian.com/bitbucket/api/2/reference/). In order to be authenticated, widget uses a [netrc](https://ec.haxx.se/usingcurl/usingcurl-netrc) feature of the cURL, which is basically allows storing basic auth credentials in a **.netrc** file in home folder.
-Bitbucket allows using [App Passwords](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html) (available in the account settings) - simply generate one for the widget and use it as password in .netrc file.
+Bitbucket allows using [App Passwords](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html) (available in the account settings) - simply generate one for the widget and use it as password in **.netrc** file.
## Customization
@@ -15,15 +15,19 @@ It is possible to customize widget by providing a table with all or some of the
| Name | Default | Description |
|---|---|---|
| `icon` | `~/.config/awesome/awesome-wm-widgets/bitbucket-widget/bitbucket-icon-gradient-blue.svg` | Path to the icon |
-| `host` | Required | Ex: _http://api.bitbucket.org_ |
-| `uuid` | Required | UUID |
+| `host` | Required | e.g _http://api.bitbucket.org_ |
+| `uuid` | Required | e.g _{123e4567-e89b-12d3-a456-426614174000}_ |
| `workspace` | Required | Workspace ID|
| `repo_slug` | Required | Repository slug |
| `timeout` | 60 | How often in seconds the widget refreshes |
+Note:
+ - host most likely should start with _api._
+ - to get your UUID you may call `curl -s -n 'https://api.bitbucket.org/2.0/user'`
+
## Installation
-Create a .netrc file in you home directory with following content:
+Create a **.netrc** file in you home directory with following content:
```bash
machine api.bitbucket.org
@@ -56,7 +60,7 @@ s.mytasklist, -- Middle widget
-- default
bitbucket_widget({
host = 'https://api.bitbucket.org',
- uuid = 'your-uuid',
+ uuid = '{123e4567-e89b-12d3-a456-426614174000}',
workspace = 'workspace',
repo_slug = 'slug'
diff --git a/calendar-widget/README.md b/calendar-widget/README.md
index c30fef6..77b8fe7 100644
--- a/calendar-widget/README.md
+++ b/calendar-widget/README.md
@@ -9,10 +9,11 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget.
| Name | Screenshot |
|---|---|
- |nord (default) | ![nord_theme](./nord.png) |
+ | nord (default) | ![nord_theme](./nord.png) |
| outrun | ![outrun_theme](./outrun.png) |
| light | ![outrun_theme](./light.png) |
| dark | ![outrun_theme](./dark.png) |
+ | naughty (default) | from local theme |
- setup widget placement
@@ -45,6 +46,7 @@ local cw = calendar_widget()
local cw = calendar_widget({
theme = 'outrun',
placement = 'bottom_right'
+ radius = 8
})
mytextclock:connect_signal("button::press",
function(_, _, _, button)
diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua
index e15d094..5cf97c8 100644
--- a/calendar-widget/calendar.lua
+++ b/calendar-widget/calendar.lua
@@ -68,7 +68,18 @@ local function worker(args)
weekday_fg = '#FD971F',
header_fg = '#F92672',
border = '#75715E'
+ },
+ naughty = {
+ bg = beautiful.notification_bg or beautiful.bg,
+ fg = beautiful.notification_fg or beautiful.fg,
+ focus_date_bg = beautiful.notification_fg or beautiful.fg,
+ focus_date_fg = beautiful.notification_bg or beautiful.bg,
+ weekend_day_bg = beautiful.bg_focus,
+ weekday_fg = beautiful.fg,
+ header_fg = beautiful.fg,
+ border = beautiful.border_normal
}
+
}
local args = args or {}
@@ -78,11 +89,12 @@ local function worker(args)
preset = naughty.config.presets.critical,
title = 'Calendar Widget',
text = 'Theme "' .. args.theme .. '" not found, fallback to default'})
- args.theme = 'nord'
+ args.theme = 'naughty'
end
- local theme = args.theme or 'nord'
+ local theme = args.theme or 'naughty'
local placement = args.placement or 'top'
+ local radius = args.radius or 8
local styles = {}
@@ -175,7 +187,7 @@ local function worker(args)
local popup = awful.popup {
ontop = true,
visible = false,
- shape = gears.shape.rounded_rect,
+ shape = rounded_shape(radius),
offset = { y = 5 },
border_width = 1,
border_color = calendar_themes[theme].border,
diff --git a/docker-widget/docker.lua b/docker-widget/docker.lua
index 6e04d8a..5bd5746 100644
--- a/docker-widget/docker.lua
+++ b/docker-widget/docker.lua
@@ -62,7 +62,6 @@ local parse_container = function(line)
else actual_status = status end
how_long = how_long:gsub('%s?%(.*%)%s?', '')
- -- if how_long:find('seconds') then how_long = 'less than a minute ago' end
local container = {
name = name,
@@ -122,20 +121,36 @@ local function worker(args)
if container.is_up() or container.is_exited() then
start_stop_button = wibox.widget {
{
- id = 'icon',
- image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
- opacity = 0.4,
- resize = false,
- widget = wibox.widget.imagebox
+ {
+ id = 'icon',
+ image = ICONS_DIR .. (container:is_up() and 'stop-btn.svg' or 'play-btn.svg'),
+ opacity = 0.4,
+ resize = false,
+ widget = wibox.widget.imagebox
+ },
+ left = 2,
+ right = 2,
+ layout = wibox.container.margin
},
- left = 2,
- right = 2,
- layout = wibox.container.margin
+ shape = gears.shape.circle,
+ bg = '#00000000',
+ widget = wibox.container.background
}
+ local old_cursor, old_wibox
start_stop_button:connect_signal("mouse::enter", function(c)
+ c:set_bg('#3B4252')
+
+ local wb = mouse.current_wibox
+ old_cursor, old_wibox = wb.cursor, wb
+ wb.cursor = "hand1"
c:get_children_by_id("icon")[1]:set_opacity(1)
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed') end)
start_stop_button:connect_signal("mouse::leave", function(c)
+ c:set_bg('#00000000')
+ if old_wibox then
+ old_wibox.cursor = old_cursor
+ old_wibox = nil
+ end
c:get_children_by_id("icon")[1]:set_opacity(0.4)
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
end)
@@ -148,7 +163,7 @@ local function worker(args)
status_icon:set_opacity(0.2)
status_icon:emit_signal('widget::redraw_needed')
- awful.spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
+ spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr)
if stderr ~= '' then show_warning(stderr) end
spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
rebuild_widget(stdout, stderr) end)
@@ -163,21 +178,36 @@ local function worker(args)
if container.is_up() then
pause_unpause_button = wibox.widget {
{
- id = 'icon',
- image = ICONS_DIR .. (container:is_paused() and 'unpause-btn.svg' or 'pause-btn.svg'),
- opacity = 0.4,
- resize = false,
- widget = wibox.widget.imagebox
+ {
+ id = 'icon',
+ image = ICONS_DIR .. (container:is_paused() and 'unpause-btn.svg' or 'pause-btn.svg'),
+ opacity = 0.4,
+ resize = false,
+ widget = wibox.widget.imagebox
+ },
+ left = 2,
+ right = 2,
+ layout = wibox.container.margin
},
- left = 2,
- right = 2,
- layout = wibox.container.margin
+ shape = gears.shape.circle,
+ bg = '#00000000',
+ widget = wibox.container.background
}
+ local old_cursor, old_wibox
pause_unpause_button:connect_signal("mouse::enter", function(c)
+ c:set_bg('#3B4252')
+ local wb = mouse.current_wibox
+ old_cursor, old_wibox = wb.cursor, wb
+ wb.cursor = "hand1"
c:get_children_by_id("icon")[1]:set_opacity(1)
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
end)
pause_unpause_button:connect_signal("mouse::leave", function(c)
+ c:set_bg('#00000000')
+ if old_wibox then
+ old_wibox.cursor = old_cursor
+ old_wibox = nil
+ end
c:get_children_by_id("icon")[1]:set_opacity(0.4)
c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
end)
@@ -200,6 +230,55 @@ local function worker(args)
pause_unpause_button = nil
end
+ local delete_button
+ if not container.is_up() then
+ delete_button = wibox.widget {
+ {
+ {
+ id = 'icon',
+ image = ICONS_DIR .. 'trash-btn.svg',
+ opacity = 0.4,
+ resize = false,
+ widget = wibox.widget.imagebox
+ },
+ margins = 4,
+ layout = wibox.container.margin
+ },
+ shape = gears.shape.circle,
+ bg = '#00000000',
+ widget = wibox.container.background
+ }
+ delete_button:buttons(
+ awful.util.table.join( awful.button({}, 1, function()
+ awful.spawn.easy_async('docker rm ' .. container['name'], function(stdout, stderr)
+ if stderr ~= '' then show_warning(stderr) end
+ spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr)
+ rebuild_widget(stdout, stderr) end)
+ end)
+ end)))
+
+ local old_cursor, old_wibox
+ delete_button:connect_signal("mouse::enter", function(c)
+ c:set_bg('#3B4252')
+ local wb = mouse.current_wibox
+ old_cursor, old_wibox = wb.cursor, wb
+ wb.cursor = "hand1"
+ c:get_children_by_id("icon")[1]:set_opacity(1)
+ c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
+ end)
+ delete_button:connect_signal("mouse::leave", function(c)
+ c:set_bg('#00000000')
+ if old_wibox then
+ old_wibox.cursor = old_cursor
+ old_wibox = nil
+ end
+ c:get_children_by_id("icon")[1]:set_opacity(0.4)
+ c:get_children_by_id("icon")[1]:emit_signal('widget::redraw_needed')
+ end)
+ else
+ delete_button = nil
+ end
+
local row = wibox.widget {
{
@@ -237,9 +316,10 @@ local function worker(args)
{
start_stop_button,
pause_unpause_button,
+ delete_button,
layout = wibox.layout.align.horizontal
},
- forced_width = 60,
+ forced_width = 90,
valign = 'center',
haligh = 'center',
layout = wibox.container.place,
diff --git a/docker-widget/icons/trash-btn.svg b/docker-widget/icons/trash-btn.svg
new file mode 100644
index 0000000..78d8035
--- /dev/null
+++ b/docker-widget/icons/trash-btn.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#BF616A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg> \ No newline at end of file
diff --git a/fs-widget/README.md b/fs-widget/README.md
index 5cda048..f134b05 100644
--- a/fs-widget/README.md
+++ b/fs-widget/README.md
@@ -1,10 +1,21 @@
# Filesystem Widget
-This widget shows disk usage. When clicked another widget appears with more detailed information. By default it monitors the "/" mount. It can be configured with a
-list of mounts to monitor though only the first will show in the wibar. To have
-multiple mounts displayed on the wibar simply define multiple `fs_widgets`
-with different mounts as arguments.
+This widget shows file system disk space usage which is based on the `df` output. When clicked another widget appears with more detailed information. By default it monitors the "/" mount. It can be configured with a list of mounts to monitor though only the first will show in the wibar. To have multiple mounts displayed on the wibar simply define multiple `fs_widgets` with different mounts as arguments.
+![](./screenshot.png)
+
+## Cusomizations
+
+It is possible to customize widget by providing a table with all or some of the following config parameters:
+
+| Name | Default | Description |
+|---|---|---|
+| `mounts` | `{'/'}` | Table with mounts to monitor, check the output from a `df` command for available options (column 'Mounted on') |
+| `timeout` | 60 | How often in seconds the widget refreshes |
+
+## Installation
+
+Clone/download repo and use the widget in **rc.lua**:
```lua
local fs_widget = require("awesome-wm-widgets.fs-widget.fs-widget")
@@ -13,12 +24,6 @@ with different mounts as arguments.
s.mytasklist, -- Middle widget
{ -- Right widgets
fs_widget(), --default
- wibox.widget.textbox(':'),
- fs_widget({ mounts = { '/', '/mnt/musicj' } }), -- multiple mounts
+ fs_widget({ mounts = { '/', '/mnt/music' } }), -- multiple mounts
...
-
```
-
-## Installation
-
-Please refer to the [installation](https://github.com/streetturtle/awesome-wm-widgets#installation) section of the repo.
diff --git a/fs-widget/fs-widget.lua b/fs-widget/fs-widget.lua
index 613c472..e920e47 100644
--- a/fs-widget/fs-widget.lua
+++ b/fs-widget/fs-widget.lua
@@ -17,7 +17,8 @@ local function worker(args)
forced_width = 35,
paddings = 1,
margins = 4,
- border_width = 0.5,
+ border_width = 1,
+ border_radius = 2,
border_color = beautiful.fg_normal,
background_color = beautiful.bg_normal,
bar_border_width = 1,
@@ -61,8 +62,6 @@ local function worker(args)
offset = { y = 5 },
widget = {}
}
- popup:connect_signal("mouse::enter", function(c) is_update = false end)
- popup:connect_signal("mouse::leave", function(c) is_update = true end)
storage_bar_widget:buttons(
awful.util.table.join(
diff --git a/fs-widget/out.gif b/fs-widget/out.gif
deleted file mode 100644
index 736f894..0000000
--- a/fs-widget/out.gif
+++ /dev/null
Binary files differ
diff --git a/fs-widget/screenshot.png b/fs-widget/screenshot.png
new file mode 100644
index 0000000..41e6ccc
--- /dev/null
+++ b/fs-widget/screenshot.png
Binary files differ
diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua
index 55b6fd7..66863f5 100644
--- a/ram-widget/ram-widget.lua
+++ b/ram-widget/ram-widget.lua
@@ -1,11 +1,14 @@
local awful = require("awful")
+local beautiful = require("beautiful")
+local gears = require("gears")
local watch = require("awful.widget.watch")
local wibox = require("wibox")
+
local ramgraph_widget = {}
-local function worker(args)
+local function worker(args)
local args = args or {}
local timeout = args.timeout or 1
@@ -13,7 +16,8 @@ local function worker(args)
ramgraph_widget = wibox.widget {
border_width = 0,
colors = {
- '#74aeab', '#26403f'
+ beautiful.bg_urgent, -- used
+ beautiful.fg_normal -- free
},
display_labels = false,
forced_width = 25,
@@ -21,26 +25,22 @@ local function worker(args)
}
--- Widget which is shown when user clicks on the ram widget
- local w = wibox {
- height = 200,
- width = 400,
- ontop = true,
- expand = true,
- bg = '#1e252c',
- max_widget_size = 500
- }
-
- w:setup {
- border_width = 0,
- colors = {
- '#5ea19d',
- '#55918e',
- '#4b817e',
- },
- display_labels = false,
- forced_width = 25,
- id = 'pie',
- widget = wibox.widget.piechart
+ local popup = awful.popup{
+ visible = false,
+ widget = {
+ widget = wibox.widget.piechart,
+ forced_height = 200,
+ forced_width = 400,
+ colors = {
+ beautiful.bg_urgent, -- used
+ beautiful.fg_normal, -- free
+ beautiful.border_color_active, -- buf_cache
+ },
+ },
+ shape = gears.shape.rounded_rect,
+ border_color = beautiful.border_color_active,
+ border_width = 1,
+ offset = { y = 5 },
}
local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap
@@ -54,13 +54,13 @@ local function worker(args)
total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap =
stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)')
- widget.data = { used, total-used } widget.data = { used, total-used }
+ widget.data = { used, total-used }
- if w.visible then
- w.pie.data_list = {
- {'used ' .. getPercentage(used + used_swap), used + used_swap},
- {'free ' .. getPercentage(free + free_swap), free + free_swap},
- {'buff_cache ' .. getPercentage(buff_cache), buff_cache}
+ if popup.visible then
+ popup:get_widget().data_list = {
+ {'used ' .. getPercentage(used + used_swap), used + used_swap},
+ {'free ' .. getPercentage(free + free_swap), free + free_swap},
+ {'buff_cache ' .. getPercentage(buff_cache), buff_cache}
}
end
end,
@@ -69,23 +69,26 @@ local function worker(args)
ramgraph_widget:buttons(
awful.util.table.join(
- awful.button({}, 1, function()
- awful.placement.top_right(w, { margins = {top = 25, right = 10}, parent = awful.screen.focused() })
- w.pie.data_list = {
+ awful.button({}, 1, function()
+ popup:get_widget().data_list = {
{'used ' .. getPercentage(used + used_swap), used + used_swap},
{'free ' .. getPercentage(free + free_swap), free + free_swap},
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
}
- w.pie.display_labels = true
- w.visible = not w.visible
+
+ if popup.visible then
+ popup.visible = not popup.visible
+ else
+ popup:move_next_to(mouse.current_widget_geometry)
+ end
end)
)
)
-
return ramgraph_widget
end
+
return setmetatable(ramgraph_widget, { __call = function(_, ...)
return worker(...)
end })
diff --git a/word-clock-widget/README.md b/word-clock-widget/README.md
new file mode 100644
index 0000000..9bf1032
--- /dev/null
+++ b/word-clock-widget/README.md
@@ -0,0 +1,74 @@
+# word clock widget
+
+Widget displaying current time using words:
+
+![screenshot](./screenshots/halfpastthree.png)
+
+## Customization
+
+It is possible to customize widget by providing a table with all or some of the following config parameters:
+
+| Name | Default | Description |
+|---|---|---|
+| main_color | `beautiful.fg_normal` | Color of the word on odd position |
+| accent_color | `beautiful.fg_urgent` | Color of the word on even position |
+| font | `beautiful.font` | Font (`Play 20`) |
+| is_human_readable | `false` | _nine fifteen_ or _fifteen past nine_ |
+| military_time | `false` | 12 or 24 time format |
+| with_spaces | `false` | Separate words with spaces |
+
+## Installation
+
+Clone repo, include widget and use it in **rc.lua**:
+
+```lua
+local word_clock = require("awesome-wm-widgets.word-clock-widget.word-clock")
+...
+s.mytasklist, -- Middle widget
+ { -- Right widgets
+ layout = wibox.layout.fixed.horizontal,
+ ...
+ word_clock(),
+ ...
+```
+
+# Screenshots
+
+```lua
+ word_clock{
+ font = 'Carter One 12',
+ accent_color = '#ff79c6',
+ main_color = '#8be9fd',
+ is_human_readable = true,
+}
+```
+![](./screenshots/halfpastthree_color.png)
+
+
+```lua
+word_clock{
+ font = 'Carter One 12',
+ is_human_readable = true,
+}
+```
+![](./screenshots/twentythreepastnine.png)
+
+
+```lua
+word_clock{
+ font = 'Carter One 12',
+ is_human_readable = true,
+ military_time = true
+}
+```
+![](./screenshots/twentythreepasttwentyone.png)
+
+
+```lua
+word_clock{
+ font = 'Carter One 12',
+ accent_color = '#f00',
+ main_color = '#0f0',
+}
+```
+![](./screenshots/onetwentyseven.png)
diff --git a/word-clock-widget/screenshots/halfpastthree.png b/word-clock-widget/screenshots/halfpastthree.png
new file mode 100644
index 0000000..af9e0d9
--- /dev/null
+++ b/word-clock-widget/screenshots/halfpastthree.png
Binary files differ
diff --git a/word-clock-widget/screenshots/halfpastthree_color.png b/word-clock-widget/screenshots/halfpastthree_color.png
new file mode 100644
index 0000000..3c2cdd7
--- /dev/null
+++ b/word-clock-widget/screenshots/halfpastthree_color.png
Binary files differ
diff --git a/word-clock-widget/screenshots/onetwentyseven.png b/word-clock-widget/screenshots/onetwentyseven.png
new file mode 100644
index 0000000..08e852c
--- /dev/null
+++ b/word-clock-widget/screenshots/onetwentyseven.png
Binary files differ
diff --git a/word-clock-widget/screenshots/testpasttwentyone.png b/word-clock-widget/screenshots/testpasttwentyone.png
new file mode 100644
index 0000000..41d266f
--- /dev/null
+++ b/word-clock-widget/screenshots/testpasttwentyone.png
Binary files differ
diff --git a/word-clock-widget/screenshots/twentythreepastnine.png b/word-clock-widget/screenshots/twentythreepastnine.png
new file mode 100644
index 0000000..7d18e22
--- /dev/null
+++ b/word-clock-widget/screenshots/twentythreepastnine.png
Binary files differ
diff --git a/word-clock-widget/screenshots/twentythreepasttwentyone.png b/word-clock-widget/screenshots/twentythreepasttwentyone.png
new file mode 100644
index 0000000..8a8218f
--- /dev/null
+++ b/word-clock-widget/screenshots/twentythreepasttwentyone.png
Binary files differ
diff --git a/word-clock-widget/word-clock.lua b/word-clock-widget/word-clock.lua
new file mode 100644
index 0000000..fc4a5b5
--- /dev/null
+++ b/word-clock-widget/word-clock.lua
@@ -0,0 +1,137 @@
+-------------------------------------------------
+-- Text Clock Widget for Awesome Window Manager
+-- Shows current time in words, e.g. 11.54 -> eleven fifty four
+-- More details could be found here:
+-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/text-clock-widget
+
+-- @author Pavel Makhov
+-- @copyright 2020 Pavel Makhov
+-------------------------------------------------
+
+local wibox = require("wibox")
+local beautiful = require("beautiful")
+local gears = require("gears")
+
+local function tablelength(T)
+ local count = 0
+ for _ in pairs(T) do count = count + 1 end
+ return count
+end
+
+local function split(string_to_split, separator)
+ if separator == nil then separator = "%s" end
+ local t = {}
+
+ for str in string.gmatch(string_to_split, "([^".. separator .."]+)") do
+ table.insert(t, str)
+ end
+
+ return t
+end
+
+local function convertNumberToName(num)
+ local lowNames = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
+ "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
+ "eighteen", "nineteen"};
+ local tensNames = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}
+ local tens, ones, result
+
+ if num < tablelength(lowNames) then
+ result = lowNames[num + 1];
+ else
+ tens = math.floor(num / 10);
+ ones = num % 10;
+ if (tens <= 9) then
+ result = tensNames[tens - 2 + 1];
+ if (ones > 0) then
+ result = result .. " " .. lowNames[ones + 1];
+ end
+ else
+ result = "unknown"
+ end
+ end
+ return result;
+end
+
+local text_clock = {}
+
+local function worker(args)
+
+ local args = args or {}
+
+ local main_color = args.main_color or beautiful.fg_normal
+ local accent_color = args.accent_color or beautiful.fg_urgent
+ local font = args.font or beautiful.font
+ local is_human_readable = args.is_human_readable
+ local military_time = args.military_time
+ local with_spaces = args.with_spaces
+
+ if military_time == nil then military_time = false end
+ if with_spaces == nil then with_spaces = false end
+ if is_human_readable == nil then is_human_readable = false end
+
+ text_clock = wibox.widget {
+ {
+ id = 'clock',
+ font = font,
+ widget = wibox.widget.textbox,
+ },
+ layout = wibox.layout.align.horizontal,
+ set_text = function(self, time)
+ local t = split(time)
+ local res = ''
+ for i, v in ipairs(t) do
+ res = res .. '<span color="' .. ((i % 2 == 0) and accent_color or main_color) .. '">' .. v .. '</span>' .. (with_spaces and ' ' or '')
+ end
+ self:get_children_by_id('clock')[1]:set_markup(res)
+ end
+ }
+
+ gears.timer {
+ timeout = 1,
+ call_now = true,
+ autostart = true,
+ callback = function()
+ local time = os.date((military_time and '%H' or '%I') .. ':%M')
+ local h,m = time:match('(%d+):(%d+)')
+ local min = tonumber(m)
+ local hour = tonumber(h)
+
+ if is_human_readable then
+
+ if min == 0 then
+ text_clock:set_text(convertNumberToName(hour) .. " o'clock")
+ else
+ local mm
+ if min == 15 or min == 45 then
+ mm = 'quater'
+ elseif min == 30 then
+ mm = 'half'
+ else
+ mm = convertNumberToName((min < 31) and min or 60 - min)
+ end
+
+ local to_past
+
+ if min < 31 then
+ to_past = 'past'
+ else
+ to_past = 'to'
+ hour = hour + 1
+ end
+
+ text_clock:set_text(mm .. ' ' .. to_past .. ' ' .. convertNumberToName(hour))
+ end
+ else
+ text_clock:set_text(convertNumberToName(hour) .. ' ' .. convertNumberToName(min))
+ end
+ end
+ }
+
+ return text_clock
+
+end
+
+return setmetatable(text_clock, { __call = function(_, ...)
+ return worker(...)
+end }) \ No newline at end of file