diff --git a/better-clock/README.md b/better-clock/README.md new file mode 100644 index 00000000..a2a82b18 --- /dev/null +++ b/better-clock/README.md @@ -0,0 +1,26 @@ +# Better Clock + +A minimal digital clock desktop widget for Noctalia with customizable time and date format strings. + +## Plugin + +| Field | Value | +| --- | --- | +| ID | `yugaaank/better-clock` | +| Entries | Desktop widget: `clock` | + +## Usage + +The Better Clock plugin adds a desktop widget that displays the current time and optionally the date below it. The widget updates every 30 seconds and uses Noctalia's built-in `formatTime()` function for locale-aware formatting. + +### Desktop Widget + +Add the widget to your widget order in Noctalia settings to display it on your desktop. + +## Settings + +| Setting | Type | Default | Description | +| --- | --- | --- | --- | +| `time_format` | `string` | `{:%H:%M}` | Luau date format for time, e.g. `{:%H:%M}` or `{:%I:%M %p}` | +| `date_format` | `string` | `{:%A, %B %d}` | Luau date format for date, e.g. `{:%A, %B %d}` | +| `show_date` | `bool` | `true` | Display the date below the time | diff --git a/better-clock/plugin.toml b/better-clock/plugin.toml new file mode 100644 index 00000000..0cb6d7d3 --- /dev/null +++ b/better-clock/plugin.toml @@ -0,0 +1,35 @@ +id = "yugaaank/better-clock" +name = "Better Clock" +version = "1.0.0" +plugin_api = 19 +author = "yugaaank" +license = "MIT" +dependencies = [] +icon = "clock" +description = "A minimal digital clock desktop widget with customizable format." +tags = ["desktop", "clock", "time", "utility"] + +[[setting]] +key = "time_format" +type = "string" +label_key = "settings.time_format.label" +description_key = "settings.time_format.description" +default = "{:%H:%M}" + +[[setting]] +key = "date_format" +type = "string" +label_key = "settings.date_format.label" +description_key = "settings.date_format.description" +default = "{:%A, %B %d}" + +[[setting]] +key = "show_date" +type = "bool" +label_key = "settings.show_date.label" +description_key = "settings.show_date.description" +default = true + +[[desktop_widget]] +id = "clock" +entry = "widget.luau" diff --git a/better-clock/thumbnail.webp b/better-clock/thumbnail.webp new file mode 100644 index 00000000..6f9ea910 Binary files /dev/null and b/better-clock/thumbnail.webp differ diff --git a/better-clock/translations/en.json b/better-clock/translations/en.json new file mode 100644 index 00000000..90c69471 --- /dev/null +++ b/better-clock/translations/en.json @@ -0,0 +1,16 @@ +{ + "settings": { + "time_format": { + "label": "Time Format", + "description": "Luau date format for time, e.g. {:%H:%M} or {:%I:%M %p}" + }, + "date_format": { + "label": "Date Format", + "description": "Luau date format for date, e.g. {:%A, %B %d}" + }, + "show_date": { + "label": "Show Date", + "description": "Display the date below the time" + } + } +} diff --git a/better-clock/widget.luau b/better-clock/widget.luau new file mode 100644 index 00000000..1de76a19 --- /dev/null +++ b/better-clock/widget.luau @@ -0,0 +1,36 @@ +local settings = noctalia.settings +local root = ui.box({ direction = "column", hAlign = "center", vAlign = "center", spacing = 0 }) + +local time_label = ui.label({ + text = "", + font = "monospace", + fontSize = 14, + color = "primary" +}) + +local date_label = ui.label({ + text = "", + font = "monospace", + fontSize = 10, + color = "on_surface_variant" +}) + +local function update() + time_label.text = noctalia.formatTime(settings.time_format) + if settings.show_date then + date_label.text = noctalia.formatTime(settings.date_format) + date_label.visible = true + else + date_label.visible = false + end +end + +noctalia.createTimer(30000, function() + update() +end) + +update() +root:append(time_label) +root:append(date_label) + +return root