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:
map:
conditions:
(activated == false): {empty: {}}
(activated == true):
~activated: {empty: {}}
activated:
- string: {text: "{app-id}: {title}"}
```

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -208,10 +208,14 @@ content:
# MAP
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>
Or, for boolean tags:
<tag>
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
may be chained together using either '&&' or '||':
and <value> is the value you would like to compare it to.
<condition1> && <condition2>
For boolean tags, negation is done with a preceding '~':
You may surround the *whole expression* with parenthesis to make it
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.
~<tag>
In addition to explicit tag values, you can also specify a
default/fallback particle.
@ -264,9 +257,8 @@ content:
default:
string:
text: this is the default particle; the tag's value is now {tag_name}
# Note, below, how the parenthesis are optional
conditions:
(tag == one_value):
tag == one_value:
string:
text: tag's value is now one_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
This particle uses a range tag to index into an array of

View file

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

View file

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