Updated docs to comply with new map syntax

This commit is contained in:
Leonardo Gibrowski Faé 2022-04-19 22:05:42 -03:00
parent 2b103b7acd
commit 4c4a20d835
9 changed files with 138 additions and 159 deletions

View file

@ -68,8 +68,8 @@ bar:
content: content:
map: map:
conditions: conditions:
(activated == false): {empty: {}} ~activated: {empty: {}}
(activated == true): activated:
- string: {text: "{app-id}: {title}"} - string: {text: "{app-id}: {title}"}
``` ```

View file

@ -104,7 +104,7 @@ bar:
map: map:
default: {string: {text: "{name}"}} default: {string: {text: "{name}"}}
conditions: conditions:
(state == focused): {string: {text: "{name}*"}} state == focused: {string: {text: "{name}*"}}
current: { string: {text: "{application}: {title}"}} current: { string: {text: "{application}: {title}"}}
``` ```

View file

@ -75,11 +75,11 @@ bar:
content: content:
map: map:
conditions: conditions:
(mounted == false): ~mounted:
string: string:
on-click: udisksctl mount -b {device} on-click: udisksctl mount -b {device}
text: "{label}" text: "{label}"
(mounted == true): mounted:
string: string:
on-click: udisksctl unmount -b {device} on-click: udisksctl unmount -b {device}
text: "{label}" text: "{label}"

View file

@ -80,8 +80,8 @@ bar:
content: content:
map: map:
conditions: conditions:
(occupied == false): {empty: {}} ~occupied: {empty: {}}
(occupied == true): occupied:
string: string:
margin: 5 margin: 5
text: "{id}: {state}" text: "{id}: {state}"

View file

@ -134,8 +134,8 @@ bar:
content: content:
map: map:
conditions: conditions:
(status == Paused): {empty: {}} status == Paused: {empty: {}}
(status == Playing): status == Playing:
content: {string: {text: "{artist} - {title}"}} content: {string: {text: "{artist} - {title}"}}
``` ```

View file

@ -69,16 +69,16 @@ in red.
content: content:
map: map:
conditions: conditions:
(carrier == false): {empty: {}} ~carrier: {empty: {}}
(carrier == true): carrier:
map: map:
default: {string: {text: , font: *awesome, foreground: ffffff66}} default: {string: {text: , font: *awesome, foreground: ffffff66}}
conditions: conditions:
(state == up): state == up:
map: map:
default: {string: {text: , font: *awesome}} default: {string: {text: , font: *awesome}}
conditions: conditions:
(ipv4 == ""): {string: {text: , font: *awesome, foreground: ffffff66}} ipv4 == "": {string: {text: , font: *awesome, foreground: ffffff66}}
``` ```
## Use yaml anchors ## Use yaml anchors

View file

@ -208,10 +208,14 @@ content:
# MAP # MAP
This particle maps the values of a specific tag to different This particle maps the values of a specific tag to different
particles based on conditions. A condition takes the form of: particles based on conditions. A condition takes either the form of:
<tag> <operation> <value> <tag> <operation> <value>
Or, for boolean tags:
<tag>
Where <tag> is the tag you would like to map, <operation> is one of: Where <tag> is the tag you would like to map, <operation> is one of:
[- == [- ==
@ -221,22 +225,11 @@ Where <tag> is the tag you would like to map, <operation> is one of:
:- <= :- <=
:- < :- <
and <value> is the value you would like to compare it to. Conditions and <value> is the value you would like to compare it to.
may be chained together using either '&&' or '||':
<condition1> && <condition2> For boolean tags, negation is done with a preceding '~':
You may surround the *whole expression* with parenthesis to make it ~<tag>
more readable:
(<condition1> && <condition2>)
Note that "nested" conditions are *NOT* supported. That is, something
like (<condition1> && (<condition2> || <condition3>)) will *NOT* work.
Furthermore, *conditions are evaluated with a strcmp*. This means
some odd behaviour may arise if prefixes (such as zeroes) are added
to numerical constants.
In addition to explicit tag values, you can also specify a In addition to explicit tag values, you can also specify a
default/fallback particle. default/fallback particle.
@ -264,9 +257,8 @@ content:
default: default:
string: string:
text: this is the default particle; the tag's value is now {tag_name} text: this is the default particle; the tag's value is now {tag_name}
# Note, below, how the parenthesis are optional
conditions: conditions:
(tag == one_value): tag == one_value:
string: string:
text: tag's value is now one_value text: tag's value is now one_value
tag == another_value: tag == another_value:
@ -275,6 +267,20 @@ content:
``` ```
For a boolean tag:
```
content:
map:
conditions:
tag:
string:
text: tag is true
~tag:
string:
text: tag is false
```
# RAMP # RAMP
This particle uses a range tag to index into an array of This particle uses a range tag to index into an array of

View file

@ -46,73 +46,65 @@ bar:
foreground: 000000ff foreground: 000000ff
deco: {stack: [background: {color: bc2b3fff}, <<: *std_underline]} deco: {stack: [background: {color: bc2b3fff}, <<: *std_underline]}
- map: &i3_mode - map: &i3_mode
tag: mode
default: default:
- string: - string:
margin: 5 margin: 5
text: "{mode}" text: "{mode}"
deco: {background: {color: cc421dff}} deco: {background: {color: cc421dff}}
- empty: {right-margin: 7} - empty: {right-margin: 7}
values: conditions:
default: {empty: {}} mode == default: {empty: {}}
content: content:
"": "":
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*default, *focused]}}
focused: {string: {<<: [*default, *focused]}} state == unfocused: {string: {<<: *default}}
unfocused: {string: {<<: *default}} state == invisible: {string: {<<: [*default, *invisible]}}
invisible: {string: {<<: [*default, *invisible]}} state == urgent: {string: {<<: [*default, *urgent]}}
urgent: {string: {<<: [*default, *urgent]}}
main: main:
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*main, *focused]}}
focused: {string: {<<: [*main, *focused]}} state == unfocused: {string: {<<: *main}}
unfocused: {string: {<<: *main}} state == invisible: {string: {<<: [*main, *invisible]}}
invisible: {string: {<<: [*main, *invisible]}} state == urgent: {string: {<<: [*main, *urgent]}}
urgent: {string: {<<: [*main, *urgent]}}
surfing: surfing:
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*surfing, *focused]}}
focused: {string: {<<: [*surfing, *focused]}} state == unfocused: {string: {<<: *surfing}}
unfocused: {string: {<<: *surfing}} state == invisible: {string: {<<: [*surfing, *invisible]}}
invisible: {string: {<<: [*surfing, *invisible]}} state == urgent: {string: {<<: [*surfing, *urgent]}}
urgent: {string: {<<: [*surfing, *urgent]}}
misc: misc:
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*misc, *focused]}}
focused: {string: {<<: [*misc, *focused]}} state == unfocused: {string: {<<: *misc}}
unfocused: {string: {<<: *misc}} state == invisible: {string: {<<: [*misc, *invisible]}}
invisible: {string: {<<: [*misc, *invisible]}} state == urgent: {string: {<<: [*misc, *urgent]}}
urgent: {string: {<<: [*misc, *urgent]}}
mail: mail:
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*mail, *focused]}}
focused: {string: {<<: [*mail, *focused]}} state == unfocused: {string: {<<: *mail}}
unfocused: {string: {<<: *mail}} state == invisible: {string: {<<: [*mail, *invisible]}}
invisible: {string: {<<: [*mail, *invisible]}} state == urgent: {string: {<<: [*mail, *urgent]}}
urgent: {string: {<<: [*mail, *urgent]}}
music: music:
map: map:
tag: state conditions:
values: state == focused: {string: {<<: [*music, *focused]}}
focused: {string: {<<: [*music, *focused]}} state == unfocused: {string: {<<: *music}}
unfocused: {string: {<<: *music}} state == invisible: {string: {<<: [*music, *invisible]}}
invisible: {string: {<<: [*music, *invisible]}} state == urgent: {string: {<<: [*music, *urgent]}}
urgent: {string: {<<: [*music, *urgent]}}
- foreign-toplevel: - foreign-toplevel:
content: content:
map: map:
tag: activated conditions:
values: ~activated: {empty: {}}
false: {empty: {}} activated:
true:
- string: {text: "{app-id}", foreground: ffa0a0ff} - string: {text: "{app-id}", foreground: ffa0a0ff}
- string: {text: ": {title}"} - string: {text: ": {title}"}
center: center:
@ -123,32 +115,28 @@ bar:
spacing: 0 spacing: 0
items: items:
- map: - map:
tag: state conditions:
values: state == playing: {string: {text: "{artist}"}}
playing: {string: {text: "{artist}"}} state == paused: {string: {text: "{artist}", foreground: ffffff66}}
paused: {string: {text: "{artist}", foreground: ffffff66}}
- string: {text: " | ", foreground: ffffff66} - string: {text: " | ", foreground: ffffff66}
- map: - map:
tag: state conditions:
values: state == playing: {string: {text: "{album}"}}
playing: {string: {text: "{album}"}} state == paused: {string: {text: "{album}", foreground: ffffff66}}
paused: {string: {text: "{album}", foreground: ffffff66}}
- string: {text: " | ", foreground: ffffff66} - string: {text: " | ", foreground: ffffff66}
- map: - map:
tag: state conditions:
values: state == playing: {string: {text: "{title}", foreground: ffa0a0ff}}
playing: {string: {text: "{title}", foreground: ffa0a0ff}} state == paused: {string: {text: "{title}", foreground: ffffff66}}
paused: {string: {text: "{title}", foreground: ffffff66}}
content: content:
map: map:
margin: 10 margin: 10
tag: state conditions:
values: state == offline: {string: {text: offline, foreground: ff0000ff}}
offline: {string: {text: offline, foreground: ff0000ff}} state == stopped: {string: {text: stopped}}
stopped: {string: {text: stopped}} state == paused: {list: *artist_album_title}
paused: {list: *artist_album_title} state == playing: {list: *artist_album_title}
playing: {list: *artist_album_title}
right: right:
- removables: - removables:
@ -158,24 +146,21 @@ bar:
spacing: 5 spacing: 5
content: content:
map: map:
tag: mounted conditions:
values: ~mounted:
false:
map: map:
tag: optical
on-click: udisksctl mount -b {device} on-click: udisksctl mount -b {device}
values: conditions:
false: [{string: *drive}, {string: {text: "{label}"}}] ~optical: [{string: *drive}, {string: {text: "{label}"}}]
true: [{string: *optical}, {string: {text: "{label}"}}] optical: [{string: *optical}, {string: {text: "{label}"}}]
true: mounted:
map: map:
tag: optical
on-click: udisksctl unmount -b {device} on-click: udisksctl unmount -b {device}
values: conditions:
false: ~optical:
- string: {<<: *drive, deco: *std_underline} - string: {<<: *drive, deco: *std_underline}
- string: {text: "{label}"} - string: {text: "{label}"}
true: optical:
- string: {<<: *optical, deco: *std_underline} - string: {<<: *optical, deco: *std_underline}
- string: {text: "{label}"} - string: {text: "{label}"}
- sway-xkb: - sway-xkb:
@ -187,36 +172,31 @@ bar:
name: enp1s0 name: enp1s0
content: content:
map: map:
tag: carrier conditions:
values: ~carrier: {empty: {}}
false: {empty: {}} carrier:
true:
map: map:
tag: state
default: {string: {text: , font: *awesome, foreground: ffffff66}} default: {string: {text: , font: *awesome, foreground: ffffff66}}
values: conditions:
up: state == up:
map: map:
tag: ipv4
default: {string: {text: , font: *awesome}} default: {string: {text: , font: *awesome}}
values: conditions:
"": {string: {text: , font: *awesome, foreground: ffffff66}} ipv4 == "": {string: {text: , font: *awesome, foreground: ffffff66}}
- network: - network:
name: wlp2s0 name: wlp2s0
content: content:
map: map:
tag: state
default: {string: {text: , font: *awesome, foreground: ffffff66}} default: {string: {text: , font: *awesome, foreground: ffffff66}}
values: conditions:
down: {string: {text: , font: *awesome, foreground: ff0000ff}} state == down: {string: {text: , font: *awesome, foreground: ff0000ff}}
up: state == up:
map: map:
tag: ipv4
default: default:
- string: {text: , font: *awesome} - string: {text: , font: *awesome}
- string: {text: "{ssid}"} - string: {text: "{ssid}"}
values: conditions:
"": ipv4 == "":
- string: {text: , font: *awesome, foreground: ffffff66} - string: {text: , font: *awesome, foreground: ffffff66}
- string: {text: "{ssid}", foreground: ffffff66} - string: {text: "{ssid}", foreground: ffffff66}
- alsa: - alsa:
@ -224,16 +204,14 @@ bar:
mixer: Master mixer: Master
content: content:
map: map:
tag: online conditions:
values: ~online: {string: {text: , font: *awesome, foreground: ff0000ff}}
false: {string: {text: , font: *awesome, foreground: ff0000ff}} online:
true:
map: map:
on-click: /bin/sh -c "amixer -q sset Speaker unmute && amixer -q sset Headphone unmute && amixer -q sset Master toggle" on-click: /bin/sh -c "amixer -q sset Speaker unmute && amixer -q sset Headphone unmute && amixer -q sset Master toggle"
tag: muted conditions:
values: muted: {string: {text: , font: *awesome, foreground: ffffff66}}
true: {string: {text: , font: *awesome, foreground: ffffff66}} ~muted:
false:
ramp: ramp:
tag: volume tag: volume
items: items:
@ -266,19 +244,18 @@ bar:
- string: {text: "{capacity}% {estimate}"} - string: {text: "{capacity}% {estimate}"}
content: content:
map: map:
tag: state conditions:
values: state == unknown:
unknown:
<<: *discharging <<: *discharging
discharging: state == discharging:
<<: *discharging <<: *discharging
charging: state == charging:
- string: {text: , foreground: 00ff00ff, font: *awesome} - string: {text: , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}% {estimate}"} - string: {text: "{capacity}% {estimate}"}
full: state == full:
- string: {text: , foreground: 00ff00ff, font: *awesome} - string: {text: , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}% full"} - string: {text: "{capacity}% full"}
not charging: state == not charging:
- ramp: - ramp:
tag: capacity tag: capacity
items: items:

View file

@ -16,16 +16,15 @@ bar:
- base: &river_base - base: &river_base
left-margin: 10 left-margin: 10
right-margin: 13 right-margin: 13
tag: id
default: {string: {text: , font: *hack}} default: {string: {text: , font: *hack}}
values: conditions:
1: {string: {text: ﳐ, font: *hack}} id == 1: {string: {text: ﳐ, font: *hack}}
2: {string: {text: , font: *hack}} id == 2: {string: {text: , font: *hack}}
3: {string: {text: , font: *hack}} id == 3: {string: {text: , font: *hack}}
4: {string: {text: , font: *hack}} id == 4: {string: {text: , font: *hack}}
5: {string: {text: , font: *hack}} id == 5: {string: {text: , font: *hack}}
10: {string: {text: "scratchpad", font: *hack}} id == 10: {string: {text: "scratchpad", font: *hack}}
11: {string: {text: "work", font: *hack}} id == 11: {string: {text: "work", font: *hack}}
content: content:
map: map:
@ -33,28 +32,25 @@ bar:
left: sh -c "riverctl set-focused-tags $((1 << ({id} - 1)))" left: sh -c "riverctl set-focused-tags $((1 << ({id} - 1)))"
right: sh -c "riverctl toggle-focused-tags $((1 << ({id} -1)))" right: sh -c "riverctl toggle-focused-tags $((1 << ({id} -1)))"
middle: sh -c "riverctl toggle-view-tags $((1 << ({id} -1)))" middle: sh -c "riverctl toggle-view-tags $((1 << ({id} -1)))"
tag: state conditions:
values: state == urgent:
urgent:
map: map:
<<: *river_base <<: *river_base
deco: {background: {color: D08770ff}} deco: {background: {color: D08770ff}}
focused: state == focused:
map: map:
<<: *river_base <<: *river_base
deco: *bg_default deco: *bg_default
visible: state == visible:
map: map:
tag: occupied conditions:
values: ~occupied: {map: {<<: *river_base}}
false: {map: {<<: *river_base}} occupied: {map: {<<: *river_base, deco: *bg_default}}
true: {map: {<<: *river_base, deco: *bg_default}} state == unfocused:
unfocused:
map: map:
<<: *river_base <<: *river_base
invisible: state == invisible:
map: map:
tag: occupied conditions:
values: ~occupied: {empty: {}}
false: {empty: {}} occupied: {map: {<<: *river_base, deco: {underline: {size: 3, color: ea6962ff}}}}
true: {map: {<<: *river_base, deco: {underline: {size: 3, color: ea6962ff}}}}