Skip to content

Allow one or more format to be used#2182

Open
bim9262 wants to merge 1 commit into
greshake:masterfrom
bim9262:multi_format_config
Open

Allow one or more format to be used#2182
bim9262 wants to merge 1 commit into
greshake:masterfrom
bim9262:multi_format_config

Conversation

@bim9262

@bim9262 bim9262 commented Jul 29, 2025

Copy link
Copy Markdown
Collaborator

Currently this has only been applied to the time block, but any block that doesn't have formats for specific states/conditions could use this do allow one or more format, while still being able to continue using format and format_alt. (This could work as a fix to #2163)

One drawback about this is that I was unable to figure out how to be able to keep the deny_unknown_fields on the Config

This will allow configs to be specified in any of these ways:

[[block]]
block = "time"
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

[[block]]
block = "time"
format = " $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %z') "
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

[[block]]
block = "time"
format = " $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %z') "
format_alt = " $icon $timestamp.datetime(f:long, l:en-u-ca-hebrew-hc-h23)"
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

[[block]]
block = "time"
format = [" $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %z') ", " $icon $timestamp.datetime(f:long, l:en-u-ca-hebrew-hc-h23)"]
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

[[block]]
block = "time"
[[block.format]]
full = " $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %z') "
[[block.format]]
full = " $icon $timestamp.datetime(f:long, l:en-u-ca-hebrew-hc-h23)"
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

[[block]]
block = "time"
testing = true
[block.format]
full = " $icon $timestamp.datetime(f:'%a %Y-%m-%d %R %z') "
[[block.click]]
button = "left"
action = "next_format"
[[block.click]]
button = "right"
action = "prev_format"

@bim9262 bim9262 linked an issue Jul 29, 2025 that may be closed by this pull request
@bim9262 bim9262 force-pushed the multi_format_config branch from e40fc6d to 327d47e Compare August 1, 2025 03:42
@bim9262

bim9262 commented Aug 1, 2025

Copy link
Copy Markdown
Collaborator Author

One drawback about this is that I was unable to figure out how to be able to keep the deny_unknown_fields on the Config

I fount that we can have deny_unknown_fields on the MaybeMultiConfig instead.

@bim9262

bim9262 commented Aug 12, 2025

Copy link
Copy Markdown
Collaborator Author

@MaxVerevkin any thoughts on this approach to allow one or more format (either as how formats are currently configured, or as a list of format configs)?

@bim9262

bim9262 commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

@ammgws, any concerns with this approach? I only added support to the time block, but it could be added to other blocks. For blocks that already support format_alt, I'd suggest deprecating the action toggle_format for next_format and prev_format.

@bim9262 bim9262 force-pushed the multi_format_config branch from 8cffbdd to 1a9b169 Compare June 24, 2026 22:41
@ammgws

ammgws commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

On phone now but just to double check before going further, are the examples in your parent comment still the same?

@bim9262

bim9262 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

@ammgws , yes the example config works as before (well except the last time block, which fails on purpose)

The change I made the other day was to keep the behavior that the first format keeps the default_full, default_short for the first format instead of filling it with "". This would only matter in the case that you wanted to set only the first format's short/full format. This is consistent with the behavior today.

Your question did raise an issue for me, what if a block does specify a default for format_alt? Today the only block that does this is the privacy block, all others' format_alt default to "". I think that adding with_default_formats to MaybeMultiConfig would probably be the most ergonomic option.

@bim9262 bim9262 force-pushed the multi_format_config branch from 1a9b169 to 00e1d7b Compare June 28, 2026 20:32
@bim9262

bim9262 commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

I've added support in two other blocks as examples: privacy and weather

@bim9262 bim9262 force-pushed the multi_format_config branch from 00e1d7b to 325e9b4 Compare June 28, 2026 20:37
@ammgws

ammgws commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Sorry I keep forgetting to come back to this except when out on phone

I think this is fine though

@bim9262 bim9262 force-pushed the multi_format_config branch from c19924a to 71af3f4 Compare July 2, 2026 17:48
@bim9262

bim9262 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Verify MaybeMultiConfig is not given an empty list of configs while deserializing

The toggle_format action has been deprecated in favor of next_format and prev_format

Implemented for the following blocks:

  • amd_gpu
  • cpu
  • disk_space
  • memory
  • music
    • Note: prev_format action is not tied to a button by default as right clicking is already assigned to next_player.
  • net
  • privacy
  • sound
    • Note: prev_format action is not tied to a button by default as right clicking is already assigned to toggle_mute.
  • temperature
  • time
    • Note: neither next_format nor prev_format are tied to buttons by default as left and right clicking are already assigned to next_timezone and prev_timezone respectively.
  • weather

@bim9262 bim9262 force-pushed the multi_format_config branch 2 times, most recently from e51c0bf to 70b953e Compare July 2, 2026 23:08
Verify MaybeMultiConfig is not given an empty list of configs while deserializing

The `toggle_format` action has been deprecated in favor of `next_format` and `prev_format`

Implemented for the following blocks:

* `amd_gpu`
* `cpu`
* `disk_space`
* `memory`
* `music`
  * Note: `prev_format` action is not tied to a button by default as right clicking is already assigned to `next_player`.
* `net`
* `privacy`
* `sound`
  * Note: `prev_format` action is not tied to a button by default as right clicking is already assigned to `toggle_mute`.
* `temperature`
* `time`
  * Note: neither `next_format` nor `prev_format` are tied to buttons by default as left and right clicking are already assigned to `next_timezone` and `prev_timezone` respectively.
* `weather`
@bim9262 bim9262 force-pushed the multi_format_config branch from 70b953e to e2d3aec Compare July 4, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format_alt not avaible for time module.

2 participants