summaryrefslogtreecommitdiff
path: root/text-clock-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2020-11-26 10:51:12 -0500
committerstreetturtle <streetturtle@gmail.com>2020-11-26 10:51:12 -0500
commit8ea89bb70617f112415e1c569395e6534c360586 (patch)
treef12e72b70b00c56d630635318a52ee9f229d075a /text-clock-widget
parenta8876145f08a2d33f78b4b65612e9294dffbf992 (diff)
[word-clock] rename text-clock to word-clock
Diffstat (limited to 'text-clock-widget')
-rw-r--r--text-clock-widget/README.md66
-rw-r--r--text-clock-widget/screenshots/halfpastthree.pngbin2291 -> 0 bytes
-rw-r--r--text-clock-widget/screenshots/halfpastthree_color.pngbin2274 -> 0 bytes
-rw-r--r--text-clock-widget/screenshots/testpasttwentyone.pngbin2926 -> 0 bytes
-rw-r--r--text-clock-widget/screenshots/twentythreepastnine.pngbin3234 -> 0 bytes
-rw-r--r--text-clock-widget/screenshots/twentythreepasttwentyone.pngbin3959 -> 0 bytes
-rw-r--r--text-clock-widget/text-clock.lua137
7 files changed, 0 insertions, 203 deletions
diff --git a/text-clock-widget/README.md b/text-clock-widget/README.md
deleted file mode 100644
index c4c6281..0000000
--- a/text-clock-widget/README.md
+++ /dev/null
@@ -1,66 +0,0 @@
-# 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 |
-
-## Installation
-
-Clone repo, include widget and use it in **rc.lua**:
-
-```lua
-local text_clock = require("awesome-wm-widgets.text-clock-widget.text-clock")
-...
-s.mytasklist, -- Middle widget
- { -- Right widgets
- layout = wibox.layout.fixed.horizontal,
- ...
- text_clock(),
- ...
-```
-
-# 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
deleted file mode 100644
index af9e0d9..0000000
--- a/text-clock-widget/screenshots/halfpastthree.png
+++ /dev/null
Binary files differ
diff --git a/text-clock-widget/screenshots/halfpastthree_color.png b/text-clock-widget/screenshots/halfpastthree_color.png
deleted file mode 100644
index 3c2cdd7..0000000
--- a/text-clock-widget/screenshots/halfpastthree_color.png
+++ /dev/null
Binary files differ
diff --git a/text-clock-widget/screenshots/testpasttwentyone.png b/text-clock-widget/screenshots/testpasttwentyone.png
deleted file mode 100644
index 41d266f..0000000
--- a/text-clock-widget/screenshots/testpasttwentyone.png
+++ /dev/null
Binary files differ
diff --git a/text-clock-widget/screenshots/twentythreepastnine.png b/text-clock-widget/screenshots/twentythreepastnine.png
deleted file mode 100644
index 7d18e22..0000000
--- a/text-clock-widget/screenshots/twentythreepastnine.png
+++ /dev/null
Binary files differ
diff --git a/text-clock-widget/screenshots/twentythreepasttwentyone.png b/text-clock-widget/screenshots/twentythreepasttwentyone.png
deleted file mode 100644
index 8a8218f..0000000
--- a/text-clock-widget/screenshots/twentythreepasttwentyone.png
+++ /dev/null
Binary files differ
diff --git a/text-clock-widget/text-clock.lua b/text-clock-widget/text-clock.lua
deleted file mode 100644
index fc4a5b5..0000000
--- a/text-clock-widget/text-clock.lua
+++ /dev/null
@@ -1,137 +0,0 @@
--------------------------------------------------
--- 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