mirror of
https://github.com/elkowar/eww.git
synced 2024-10-03 22:48:31 +03:00
Compare commits
9 Commits
0138dbaf8e
...
b5df269bd4
Author | SHA1 | Date | |
---|---|---|---|
|
b5df269bd4 | ||
|
8661abf2bf | ||
|
bb916c652b | ||
|
bd09b881af | ||
|
b3dbfadfb2 | ||
|
20fb331368 | ||
|
31ab23cd83 | ||
|
f03aebf0dd | ||
|
09fbdde6c9 |
@ -21,6 +21,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
|||||||
- Add scss support for the `:style` widget property (By: ovalkonia)
|
- Add scss support for the `:style` widget property (By: ovalkonia)
|
||||||
- Add `min` and `max` function calls to simplexpr (By: ovalkonia)
|
- Add `min` and `max` function calls to simplexpr (By: ovalkonia)
|
||||||
- Add `flip-x`, `flip-y`, `vertical` options to the graph widget to determine its direction
|
- Add `flip-x`, `flip-y`, `vertical` options to the graph widget to determine its direction
|
||||||
|
- Add `transform-origin-x`/`transform-origin-y` properties to transform widget (By: mario-kr)
|
||||||
|
|
||||||
## [0.6.0] (21.04.2024)
|
## [0.6.0] (21.04.2024)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ macro_rules! define_builtin_vars {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 { <name>: temperature }
|
// @prop { <name>: temperature }
|
||||||
"EWW_TEMPS" [2] => || Ok(DynVal::from(get_temperatures())),
|
"EWW_TEMPS" [2] => || Ok(DynVal::from(get_temperatures())),
|
||||||
|
|
||||||
@ -81,17 +81,17 @@ macro_rules! define_magic_constants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
define_magic_constants! { eww_paths,
|
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()),
|
"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(
|
"EWW_CMD" => DynVal::from_string(
|
||||||
format!("\"{}\" --config \"{}\"",
|
format!("\"{}\" --config \"{}\"",
|
||||||
std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()),
|
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()
|
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(
|
"EWW_EXECUTABLE" => DynVal::from_string(
|
||||||
std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()),
|
std::env::current_exe().map(|x| x.to_string_lossy().into_owned()).unwrap_or_else(|_| "eww".to_string()),
|
||||||
),
|
),
|
||||||
|
@ -33,7 +33,6 @@ pub fn initialize_server<B: DisplayBackend>(
|
|||||||
log::info!("Loading paths: {}", &paths);
|
log::info!("Loading paths: {}", &paths);
|
||||||
|
|
||||||
let read_config = config::read_from_eww_paths(&paths);
|
let read_config = config::read_from_eww_paths(&paths);
|
||||||
|
|
||||||
let eww_config = match read_config {
|
let eww_config = match read_config {
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -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())?;
|
cleanup_log_dir(paths.get_log_dir())?;
|
||||||
|
|
||||||
if should_daemonize {
|
if should_daemonize {
|
||||||
|
@ -17,6 +17,12 @@ pub struct TransformPriv {
|
|||||||
#[property(get, set, nick = "Rotate", blurb = "The Rotation", minimum = f64::MIN, maximum = f64::MAX, default = 0f64)]
|
#[property(get, set, nick = "Rotate", blurb = "The Rotation", minimum = f64::MIN, maximum = f64::MAX, default = 0f64)]
|
||||||
rotate: RefCell<f64>,
|
rotate: RefCell<f64>,
|
||||||
|
|
||||||
|
#[property(get, set, nick = "Transform-Origin X", blurb = "X coordinate (%/px) for the Transform-Origin", default = None)]
|
||||||
|
transform_origin_x: RefCell<Option<String>>,
|
||||||
|
|
||||||
|
#[property(get, set, nick = "Transform-Origin Y", blurb = "Y coordinate (%/px) for the Transform-Origin", default = None)]
|
||||||
|
transform_origin_y: RefCell<Option<String>>,
|
||||||
|
|
||||||
#[property(get, set, nick = "Translate x", blurb = "The X Translation", default = None)]
|
#[property(get, set, nick = "Translate x", blurb = "The X Translation", default = None)]
|
||||||
translate_x: RefCell<Option<String>>,
|
translate_x: RefCell<Option<String>>,
|
||||||
|
|
||||||
@ -37,6 +43,8 @@ impl Default for TransformPriv {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
TransformPriv {
|
TransformPriv {
|
||||||
rotate: RefCell::new(0.0),
|
rotate: RefCell::new(0.0),
|
||||||
|
transform_origin_x: RefCell::new(None),
|
||||||
|
transform_origin_y: RefCell::new(None),
|
||||||
translate_x: RefCell::new(None),
|
translate_x: RefCell::new(None),
|
||||||
translate_y: RefCell::new(None),
|
translate_y: RefCell::new(None),
|
||||||
scale_x: RefCell::new(None),
|
scale_x: RefCell::new(None),
|
||||||
@ -57,6 +65,14 @@ impl ObjectImpl for TransformPriv {
|
|||||||
self.rotate.replace(value.get().unwrap());
|
self.rotate.replace(value.get().unwrap());
|
||||||
self.obj().queue_draw(); // Queue a draw call with the updated value
|
self.obj().queue_draw(); // Queue a draw call with the updated value
|
||||||
}
|
}
|
||||||
|
"transform-origin-x" => {
|
||||||
|
self.transform_origin_x.replace(value.get().unwrap());
|
||||||
|
self.obj().queue_draw(); // Queue a draw call with the updated value
|
||||||
|
}
|
||||||
|
"transform-origin-y" => {
|
||||||
|
self.transform_origin_y.replace(value.get().unwrap());
|
||||||
|
self.obj().queue_draw(); // Queue a draw call with the updated value
|
||||||
|
}
|
||||||
"translate-x" => {
|
"translate-x" => {
|
||||||
self.translate_x.replace(value.get().unwrap());
|
self.translate_x.replace(value.get().unwrap());
|
||||||
self.obj().queue_draw(); // Queue a draw call with the updated value
|
self.obj().queue_draw(); // Queue a draw call with the updated value
|
||||||
@ -128,6 +144,15 @@ impl WidgetImpl for TransformPriv {
|
|||||||
|
|
||||||
cr.save()?;
|
cr.save()?;
|
||||||
|
|
||||||
|
let transform_origin_x = match &*self.transform_origin_x.borrow() {
|
||||||
|
Some(rcx) => NumWithUnit::from_str(rcx)?.pixels_relative_to(total_width as i32) as f64,
|
||||||
|
None => 0.0,
|
||||||
|
};
|
||||||
|
let transform_origin_y = match &*self.transform_origin_y.borrow() {
|
||||||
|
Some(rcy) => NumWithUnit::from_str(rcy)?.pixels_relative_to(total_height as i32) as f64,
|
||||||
|
None => 0.0,
|
||||||
|
};
|
||||||
|
|
||||||
let translate_x = match &*self.translate_x.borrow() {
|
let translate_x = match &*self.translate_x.borrow() {
|
||||||
Some(tx) => NumWithUnit::from_str(tx)?.pixels_relative_to(total_width as i32) as f64,
|
Some(tx) => NumWithUnit::from_str(tx)?.pixels_relative_to(total_width as i32) as f64,
|
||||||
None => 0.0,
|
None => 0.0,
|
||||||
@ -148,9 +173,10 @@ impl WidgetImpl for TransformPriv {
|
|||||||
None => 1.0,
|
None => 1.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
cr.scale(scale_x, scale_y);
|
cr.translate(transform_origin_x, transform_origin_y);
|
||||||
cr.rotate(perc_to_rad(rotate));
|
cr.rotate(perc_to_rad(rotate));
|
||||||
cr.translate(translate_x, translate_y);
|
cr.translate(translate_x - transform_origin_x, translate_y - transform_origin_y);
|
||||||
|
cr.scale(scale_x, scale_y);
|
||||||
|
|
||||||
// Children widget
|
// Children widget
|
||||||
if let Some(child) = &*self.content.borrow() {
|
if let Some(child) = &*self.content.borrow() {
|
||||||
|
@ -312,7 +312,8 @@ fn build_gtk_combo_box_text(bargs: &mut BuilderArgs) -> Result<gtk::ComboBoxText
|
|||||||
|
|
||||||
const WIDGET_NAME_EXPANDER: &str = "expander";
|
const WIDGET_NAME_EXPANDER: &str = "expander";
|
||||||
/// @widget 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> {
|
fn build_gtk_expander(bargs: &mut BuilderArgs) -> Result<gtk::Expander> {
|
||||||
let gtk_widget = gtk::Expander::new(None);
|
let gtk_widget = gtk::Expander::new(None);
|
||||||
|
|
||||||
@ -1188,6 +1189,10 @@ fn build_transform(bargs: &mut BuilderArgs) -> Result<Transform> {
|
|||||||
def_widget!(bargs, _g, w, {
|
def_widget!(bargs, _g, w, {
|
||||||
// @prop rotate - the percentage to rotate
|
// @prop rotate - the percentage to rotate
|
||||||
prop(rotate: as_f64) { w.set_property("rotate", rotate); },
|
prop(rotate: as_f64) { w.set_property("rotate", rotate); },
|
||||||
|
// @prop transform-origin-x - x coordinate of origin of transformation (px or %)
|
||||||
|
prop(transform_origin_x: as_string) { w.set_property("transform-origin-x", transform_origin_x) },
|
||||||
|
// @prop transform-origin-y - y coordinate of origin of transformation (px or %)
|
||||||
|
prop(transform_origin_y: as_string) { w.set_property("transform-origin-y", transform_origin_y) },
|
||||||
// @prop translate-x - the amount to translate in the x direction (px or %)
|
// @prop translate-x - the amount to translate in the x direction (px or %)
|
||||||
prop(translate_x: as_string) { w.set_property("translate-x", translate_x); },
|
prop(translate_x: as_string) { w.set_property("translate-x", translate_x); },
|
||||||
// @prop translate-y - the amount to translate in the y direction (px or %)
|
// @prop translate-y - the amount to translate in the y direction (px or %)
|
||||||
|
@ -40,6 +40,7 @@ Supported currently are the following features:
|
|||||||
- some function calls:
|
- some function calls:
|
||||||
- `round(number, decimal_digits)`: Round a number to the given amount of decimals
|
- `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**
|
- `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
|
- `degtorad(number)`: Converts a number from degrees to radians
|
||||||
- `radtodeg(number)`: Converts a number from radians to degrees
|
- `radtodeg(number)`: Converts a number from radians to degrees
|
||||||
- `replace(string, regex, replacement)`: Replace matches of a given regex in a string
|
- `replace(string, regex, replacement)`: Replace matches of a given regex in a string
|
||||||
|
@ -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.
|
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!
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
* {
|
* {
|
||||||
all: unset; //Unsets everything so you can style everything from scratch
|
all: unset; // Unsets everything so you can style everything from scratch
|
||||||
}
|
}
|
||||||
|
|
||||||
//Global Styles
|
// Global Styles
|
||||||
.bar {
|
.bar {
|
||||||
background-color: #3a3a3a;
|
background-color: #3a3a3a;
|
||||||
color: #b0b4bc;
|
color: #b0b4bc;
|
||||||
@ -22,6 +22,7 @@
|
|||||||
color: #000000;
|
color: #000000;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metric scale trough {
|
.metric scale trough {
|
||||||
all: unset;
|
all: unset;
|
||||||
background-color: #4e4e4e;
|
background-color: #4e4e4e;
|
||||||
@ -31,24 +32,11 @@
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
.metric scale trough highlight {
|
|
||||||
all: unset;
|
|
||||||
background-color: #D35D6E;
|
|
||||||
color: #000000;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
.metric scale trough {
|
|
||||||
all: unset;
|
|
||||||
background-color: #4e4e4e;
|
|
||||||
border-radius: 50px;
|
|
||||||
min-height: 3px;
|
|
||||||
min-width: 50px;
|
|
||||||
margin-left: 10px;
|
|
||||||
margin-right: 20px;
|
|
||||||
}
|
|
||||||
.label-ram {
|
.label-ram {
|
||||||
font-size: large;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
|
||||||
.workspaces button:hover {
|
.workspaces button:hover {
|
||||||
color: #D35D6E;
|
color: #D35D6E;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user