mirror of
https://github.com/elkowar/eww.git
synced 2024-08-18 00:00:38 +03:00
add get_env function to yuck (#779)
* added basic get_env function to yuck * added get_env to changelog * added get_env to docs * changed key to string in doc * changed suggested code * credit myself in CHANGELOG.md
This commit is contained in:
parent
4ce42455a4
commit
f1ec00a1c9
@ -15,6 +15,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
|||||||
- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows`
|
- Remove `eww windows` command, replace with `eww active-windows` and `eww list-windows`
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
- Add `get_env` function (By: RegenJacob)
|
||||||
- Add `:namespace` window option
|
- Add `:namespace` window option
|
||||||
- Default to building with x11 and wayland support simultaneously
|
- Default to building with x11 and wayland support simultaneously
|
||||||
- Add `truncate-left` property on `label` widgets (By: kawaki-san)
|
- Add `truncate-left` property on `label` widgets (By: kawaki-san)
|
||||||
|
@ -313,6 +313,13 @@ impl SimplExpr {
|
|||||||
|
|
||||||
fn call_expr_function(name: &str, args: Vec<DynVal>) -> Result<DynVal, EvalError> {
|
fn call_expr_function(name: &str, args: Vec<DynVal>) -> Result<DynVal, EvalError> {
|
||||||
match name {
|
match name {
|
||||||
|
"get_env" => match args.as_slice() {
|
||||||
|
[var_name] => {
|
||||||
|
let var = std::env::var(var_name.as_string()?).unwrap_or_default();
|
||||||
|
Ok(DynVal::from(var))
|
||||||
|
}
|
||||||
|
_ => Err(EvalError::WrongArgCount(name.to_string())),
|
||||||
|
},
|
||||||
"round" => match args.as_slice() {
|
"round" => match args.as_slice() {
|
||||||
[num, digits] => {
|
[num, digits] => {
|
||||||
let num = num.as_f64()?;
|
let num = num.as_f64()?;
|
||||||
|
@ -51,11 +51,12 @@ Supported currently are the following features:
|
|||||||
- `arraylength(value)`: Gets the length of the array
|
- `arraylength(value)`: Gets the length of the array
|
||||||
- `objectlength(value)`: Gets the amount of entries in the object
|
- `objectlength(value)`: Gets the amount of entries in the object
|
||||||
- `jq(value, jq_filter_string)`: run a [jq](https://stedolan.github.io/jq/manual/) style command on a json value. (Uses [jaq](https://crates.io/crates/jaq) internally).
|
- `jq(value, jq_filter_string)`: run a [jq](https://stedolan.github.io/jq/manual/) style command on a json value. (Uses [jaq](https://crates.io/crates/jaq) internally).
|
||||||
- `formattime(unix_timestamp, format_str, timezone)`: Gets the time in a given format from UNIX timestamp.
|
- `get_env(string)`: Gets the specified enviroment variable
|
||||||
Check [chrono's documentation](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) for more
|
- `formattime(unix_timestamp, format_str, timezone)`: Gets the time in a given format from UNIX timestamp.
|
||||||
information about format string and [chrono-tz's documentation](https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)
|
Check [chrono's documentation](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) for more
|
||||||
for available time zones.
|
information about format string and [chrono-tz's documentation](https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)
|
||||||
- `formattime(unix_timestamp, format_str)`: Gets the time in a given format from UNIX timestamp.
|
for available time zones.
|
||||||
Same as other `formattime`, but does not accept timezone. Instead, it uses system's local timezone.
|
- `formattime(unix_timestamp, format_str)`: Gets the time in a given format from UNIX timestamp.
|
||||||
Check [chrono's documentation](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) for more
|
Same as other `formattime`, but does not accept timezone. Instead, it uses system's local timezone.
|
||||||
information about format string.
|
Check [chrono's documentation](https://docs.rs/chrono/latest/chrono/format/strftime/index.html) for more
|
||||||
|
information about format string.
|
||||||
|
Loading…
Reference in New Issue
Block a user