summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2020-11-25 09:33:35 -0500
committerstreetturtle <streetturtle@gmail.com>2020-11-25 09:33:35 -0500
commit5e0030094446cd064fd2ca79dc69e9a6efab4712 (patch)
treee1c8af3d1306badefc157273206c57ba49f1464a
parent6e83c1ff92c0be6e04ba6adcb0a0a9059dc4107f (diff)
[text-clock] update readme
-rw-r--r--text-clock-widget/README.md51
-rw-r--r--text-clock-widget/screenshots/halfpastthree.pngbin0 -> 2291 bytes
-rw-r--r--text-clock-widget/screenshots/halfpastthree_color.pngbin0 -> 2274 bytes
-rw-r--r--text-clock-widget/screenshots/testpasttwentyone.pngbin0 -> 2926 bytes
-rw-r--r--text-clock-widget/screenshots/twentythreepastnine.pngbin0 -> 3234 bytes
-rw-r--r--text-clock-widget/screenshots/twentythreepasttwentyone.pngbin0 -> 3959 bytes
-rw-r--r--text-clock-widget/text-clock.lua48
7 files changed, 80 insertions, 19 deletions
diff --git a/text-clock-widget/README.md b/text-clock-widget/README.md
new file mode 100644
index 0000000..0c07507
--- /dev/null
+++ b/text-clock-widget/README.md
@@ -0,0 +1,51 @@
+# Text 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 |
+
+# Screenshots
+
+```lua
+ text_clock{
+ font = 'Carter One 12',
+ accent_color = '#ff79c6',
+ main_color = '#8be9fd',
+ is_human_readable = true,
+}
+```
+![](./screenshots/halfpastthree_color.png)
+
+
+```lua
+text_clock{
+ font = 'Carter One 12',
+ is_human_readable = true,
+}
+```
+![](./screenshots/twentythreepastnine.png)
+
+
+```lua
+text_clock{
+ font = 'Carter One 12',
+ is_human_readable = true,
+ military_time = true
+}
+```
+![](./screenshots/twentythreepasttwentyone.png)
+
+
diff --git a/text-clock-widget/screenshots/halfpastthree.png b/text-clock-widget/screenshots/halfpastthree.png
new file mode 100644
index 0000000..af9e0d9
--- /dev/null
+++ b/text-clock-widget/screenshots/halfpastthree.png
Binary files differ
diff --git a/text-clock-widget/screenshots/halfpastthree_color.png b/text-clock-widget/screenshots/halfpastthree_color.png
new file mode 100644
index 0000000..3c2cdd7
--- /dev/null
+++ b/text-clock-widget/screenshots/halfpastthree_color.png
Binary files differ
diff --git a/text-clock-widget/screenshots/testpasttwentyone.png b/text-clock-widget/screenshots/testpasttwentyone.png
new file mode 100644
index 0000000..41d266f
--- /dev/null
+++ b/text-clock-widget/screenshots/testpasttwentyone.png
Binary files differ
diff --git a/text-clock-widget/screenshots/twentythreepastnine.png b/text-clock-widget/screenshots/twentythreepastnine.png
new file mode 100644
index 0000000..7d18e22
--- /dev/null
+++ b/text-clock-widget/screenshots/twentythreepastnine.png
Binary files differ
diff --git a/text-clock-widget/screenshots/twentythreepasttwentyone.png b/text-clock-widget/screenshots/twentythreepasttwentyone.png
new file mode 100644
index 0000000..8a8218f
--- /dev/null
+++ b/text-clock-widget/screenshots/twentythreepasttwentyone.png
Binary files differ
diff --git a/text-clock-widget/text-clock.lua b/text-clock-widget/text-clock.lua
index a22b8a1..4eef69a 100644
--- a/text-clock-widget/text-clock.lua
+++ b/text-clock-widget/text-clock.lua
@@ -62,10 +62,13 @@ local function worker(args)
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 mode = args.mode or 'human' -- human /
+ 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 {
{
@@ -78,7 +81,7 @@ local function worker(args)
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>'
+ 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
@@ -91,29 +94,36 @@ local function worker(args)
callback = function()
local time = os.date((military_time and '%H' or '%I') .. ':%M')
local h,m = time:match('(%d+):(%d+)')
+ h = 3
+ m = 30
local min = tonumber(m)
local hour = tonumber(h)
- if mode == 'human' then
- 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
+ if is_human_readable then
- local to_past
-
- if min < 31 then
- to_past = 'past'
+ if min == 0 then
+ text_clock:set_text(convertNumberToName(hour) .. " o'clock")
else
- to_past = 'to'
- hour = hour + 1
+ 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
-
- text_clock:set_text(mm .. ' ' .. to_past .. ' ' .. convertNumberToName(hour))
else
text_clock:set_text(convertNumberToName(hour) .. ' ' .. convertNumberToName(min))
end