From 09fbdde6c99a4c4c8af39b76496878f99a28d568 Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 30 Aug 2024 00:57:40 +0300 Subject: [PATCH 1/9] Export magic constants during server initialization --- crates/eww/src/server.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index 57af1e5c..84185440 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -33,7 +33,6 @@ pub fn initialize_server( log::info!("Loading paths: {}", &paths); let read_config = config::read_from_eww_paths(&paths); - let eww_config = match read_config { Ok(config) => config, Err(err) => { @@ -42,6 +41,10 @@ pub fn initialize_server( } }; + for (name, definition) in config::inbuilt::get_magic_constants(&paths) { + std::env::set_var(name.0, definition.initial_value.0); + } + cleanup_log_dir(paths.get_log_dir())?; if should_daemonize { From f03aebf0dd2fba10c67c608f72570c230d0eb8ea Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 30 Aug 2024 17:01:35 +0300 Subject: [PATCH 2/9] `docs`: add `magic constants` descriptions (or at least try) --- crates/eww/src/config/inbuilt.rs | 6 +++--- docs/src/magic-vars.md | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/eww/src/config/inbuilt.rs b/crates/eww/src/config/inbuilt.rs index ba299395..82446f9b 100644 --- a/crates/eww/src/config/inbuilt.rs +++ b/crates/eww/src/config/inbuilt.rs @@ -81,17 +81,17 @@ macro_rules! define_magic_constants { } } define_magic_constants! { eww_paths, - // @desc EWW_CONFIG_DIR - Path to the eww configuration of the current process + // @desc EWW_CONFIG_DIR (Magic constant) - Path to the eww configuration of the current process "EWW_CONFIG_DIR" => DynVal::from_string(eww_paths.get_config_dir().to_string_lossy().into_owned()), - // @desc EWW_CMD - eww command running in the current configuration, useful in event handlers. I.e.: `:onclick "${EWW_CMD} update foo=bar"` + // @desc EWW_CMD (Magic constant) - eww command running in the current configuration, useful in event handlers. I.e.: `:onclick "${EWW_CMD} update foo=bar"` "EWW_CMD" => DynVal::from_string( format!("\"{}\" --config \"{}\"", std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()), eww_paths.get_config_dir().to_string_lossy().into_owned() ) ), - // @desc EWW_EXECUTABLE - Full path of the eww executable + // @desc EWW_EXECUTABLE (Magic constant) - Full path of the eww executable "EWW_EXECUTABLE" => DynVal::from_string( std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()), ), diff --git a/docs/src/magic-vars.md b/docs/src/magic-vars.md index aed7637d..7a13fff6 100644 --- a/docs/src/magic-vars.md +++ b/docs/src/magic-vars.md @@ -4,3 +4,6 @@ These are variables that are always there, without you having to import them. The delay between all the updating variables except `EWW_TIME` is 2s, for `EWW_TIME` it is 1s. +There are also `magic constants`, marked with `(Magic constant)` after the variable's name. As the name implies, they do not change. +You can also get them from within your scripts since they are automatically exported as environmental variables! + From 31ab23cd833a2a72d7c779b8bc1c6fa3d027bc07 Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 30 Aug 2024 17:19:14 +0300 Subject: [PATCH 3/9] `docs`: add `min` and `max` simplexpr functions entries --- docs/src/expression_language.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/expression_language.md b/docs/src/expression_language.md index 15dfc6ed..1c493e01 100644 --- a/docs/src/expression_language.md +++ b/docs/src/expression_language.md @@ -40,6 +40,7 @@ Supported currently are the following features: - some function calls: - `round(number, decimal_digits)`: Round a number to the given amount of decimals - `sin(number)`, `cos(number)`, `tan(number)`, `cot(number)`: Calculate the trigonometric value of a given number in **radians** + - `min(a, b)`, `max(a, b)`: Get the smaller or bigger number out of two given numbers - `degtorad(number)`: Converts a number from degrees to radians - `radtodeg(number)`: Converts a number from radians to degrees - `replace(string, regex, replacement)`: Replace matches of a given regex in a string From 20fb33136858ed9949506714ac122b93a671acbc Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 30 Aug 2024 17:21:06 +0300 Subject: [PATCH 4/9] `docs`: `expander` should contain single child --- crates/eww/src/widgets/widget_definitions.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs index 4cfd7621..a90faf89 100644 --- a/crates/eww/src/widgets/widget_definitions.rs +++ b/crates/eww/src/widgets/widget_definitions.rs @@ -312,7 +312,8 @@ fn build_gtk_combo_box_text(bargs: &mut BuilderArgs) -> Result Result { let gtk_widget = gtk::Expander::new(None); From b3dbfadfb2143cc0d3e2e21c0cf43ed0a96a53cf Mon Sep 17 00:00:00 2001 From: ovalkonia <60359793+ovalkonia@users.noreply.github.com> Date: Fri, 30 Aug 2024 17:34:13 +0300 Subject: [PATCH 5/9] Update docs/src/magic-vars.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Wölfchen --- docs/src/magic-vars.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/magic-vars.md b/docs/src/magic-vars.md index 7a13fff6..ecf97f64 100644 --- a/docs/src/magic-vars.md +++ b/docs/src/magic-vars.md @@ -5,5 +5,5 @@ These are variables that are always there, without you having to import them. The delay between all the updating variables except `EWW_TIME` is 2s, for `EWW_TIME` it is 1s. There are also `magic constants`, marked with `(Magic constant)` after the variable's name. As the name implies, they do not change. -You can also get them from within your scripts since they are automatically exported as environmental variables! +You can also access them in your scripts since they are automatically exported as environmental variables! From bd09b881af8a81d0feb63960129c520839e1cec6 Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 30 Aug 2024 17:47:02 +0300 Subject: [PATCH 6/9] `docs`: fix the heat units typo --- crates/eww/src/config/inbuilt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eww/src/config/inbuilt.rs b/crates/eww/src/config/inbuilt.rs index 82446f9b..d462d5ae 100644 --- a/crates/eww/src/config/inbuilt.rs +++ b/crates/eww/src/config/inbuilt.rs @@ -30,7 +30,7 @@ macro_rules! define_builtin_vars { } define_builtin_vars! { - // @desc EWW_TEMPS - Heat of the components in Celcius + // @desc EWW_TEMPS - Heat of the components in degree Celsius // @prop { : temperature } "EWW_TEMPS" [2] => || Ok(DynVal::from(get_temperatures())), From c322a51e6fe293f8695c5f8acc7a6d4a67b3d3c7 Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 6 Sep 2024 22:36:45 +0300 Subject: [PATCH 7/9] Revert "Export magic constants during server initialization" This reverts commit 09fbdde6c99a4c4c8af39b76496878f99a28d568. --- crates/eww/src/server.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/eww/src/server.rs b/crates/eww/src/server.rs index 84185440..57af1e5c 100644 --- a/crates/eww/src/server.rs +++ b/crates/eww/src/server.rs @@ -33,6 +33,7 @@ pub fn initialize_server( log::info!("Loading paths: {}", &paths); let read_config = config::read_from_eww_paths(&paths); + let eww_config = match read_config { Ok(config) => config, Err(err) => { @@ -41,10 +42,6 @@ pub fn initialize_server( } }; - for (name, definition) in config::inbuilt::get_magic_constants(&paths) { - std::env::set_var(name.0, definition.initial_value.0); - } - cleanup_log_dir(paths.get_log_dir())?; if should_daemonize { From ae02881562a3280075b5865d5c3528e45d69d95d Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 6 Sep 2024 22:37:14 +0300 Subject: [PATCH 8/9] Revert "Update docs/src/magic-vars.md" This reverts commit b3dbfadfb2143cc0d3e2e21c0cf43ed0a96a53cf. --- docs/src/magic-vars.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/magic-vars.md b/docs/src/magic-vars.md index ecf97f64..7a13fff6 100644 --- a/docs/src/magic-vars.md +++ b/docs/src/magic-vars.md @@ -5,5 +5,5 @@ These are variables that are always there, without you having to import them. The delay between all the updating variables except `EWW_TIME` is 2s, for `EWW_TIME` it is 1s. There are also `magic constants`, marked with `(Magic constant)` after the variable's name. As the name implies, they do not change. -You can also access them in your scripts since they are automatically exported as environmental variables! +You can also get them from within your scripts since they are automatically exported as environmental variables! From 14d505129e92361e54d5ae40085432292d6874b1 Mon Sep 17 00:00:00 2001 From: ovalkonia Date: Fri, 6 Sep 2024 22:37:51 +0300 Subject: [PATCH 9/9] Revert "`docs`: add `magic constants` descriptions (or at least try)" This reverts commit f03aebf0dd2fba10c67c608f72570c230d0eb8ea. --- crates/eww/src/config/inbuilt.rs | 6 +++--- docs/src/magic-vars.md | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/eww/src/config/inbuilt.rs b/crates/eww/src/config/inbuilt.rs index d462d5ae..687fb057 100644 --- a/crates/eww/src/config/inbuilt.rs +++ b/crates/eww/src/config/inbuilt.rs @@ -81,17 +81,17 @@ macro_rules! define_magic_constants { } } define_magic_constants! { eww_paths, - // @desc EWW_CONFIG_DIR (Magic constant) - Path to the eww configuration of the current process + // @desc EWW_CONFIG_DIR - Path to the eww configuration of the current process "EWW_CONFIG_DIR" => DynVal::from_string(eww_paths.get_config_dir().to_string_lossy().into_owned()), - // @desc EWW_CMD (Magic constant) - eww command running in the current configuration, useful in event handlers. I.e.: `:onclick "${EWW_CMD} update foo=bar"` + // @desc EWW_CMD - eww command running in the current configuration, useful in event handlers. I.e.: `:onclick "${EWW_CMD} update foo=bar"` "EWW_CMD" => DynVal::from_string( format!("\"{}\" --config \"{}\"", std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()), eww_paths.get_config_dir().to_string_lossy().into_owned() ) ), - // @desc EWW_EXECUTABLE (Magic constant) - Full path of the eww executable + // @desc EWW_EXECUTABLE - Full path of the eww executable "EWW_EXECUTABLE" => DynVal::from_string( std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()), ), diff --git a/docs/src/magic-vars.md b/docs/src/magic-vars.md index 7a13fff6..aed7637d 100644 --- a/docs/src/magic-vars.md +++ b/docs/src/magic-vars.md @@ -4,6 +4,3 @@ These are variables that are always there, without you having to import them. The delay between all the updating variables except `EWW_TIME` is 2s, for `EWW_TIME` it is 1s. -There are also `magic constants`, marked with `(Magic constant)` after the variable's name. As the name implies, they do not change. -You can also get them from within your scripts since they are automatically exported as environmental variables! -