Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some docs updates #1179

Merged
merged 9 commits into from
Oct 11, 2024
6 changes: 3 additions & 3 deletions crates/eww/src/config/inbuilt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \"{}\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
format!("\"{}\" --config \"{}\"",
format!("{} --config {}",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's what I thought, BUT. Try cloning eww into a folder named eww with spaces for example. It doesn't work for me. The path is just cut from the first space to the end. These are kind of things that make want not to deal with bash ever again(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah true, i forgot about that, nvm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use single quotes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problems as with double quotes

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()),
),
Expand Down
5 changes: 4 additions & 1 deletion crates/eww/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub fn initialize_server<B: DisplayBackend>(
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) => {
Expand All @@ -42,6 +41,10 @@ pub fn initialize_server<B: DisplayBackend>(
}
};

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 {
Expand Down
3 changes: 2 additions & 1 deletion crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ fn build_gtk_combo_box_text(bargs: &mut BuilderArgs) -> Result<gtk::ComboBoxText

const WIDGET_NAME_EXPANDER: &str = "expander";
/// @widget expander
/// @desc A widget that can expand and collapse, showing/hiding it's children.
/// @desc A widget that can expand and collapse, showing/hiding it's children. Should contain
/// exactly one child.
fn build_gtk_expander(bargs: &mut BuilderArgs) -> Result<gtk::Expander> {
let gtk_widget = gtk::Expander::new(None);

Expand Down
1 change: 1 addition & 0 deletions docs/src/expression_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/src/magic-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
ovalkonia marked this conversation as resolved.
Show resolved Hide resolved

Loading