davatorium / rofi

Rofi: A window switcher, application launcher and dmenu replacement
https://davatorium.github.io/rofi/
Other
13.04k stars 609 forks source link

[REQUEST] Ability to use variables in calc functions. #1258

Open ShadowKing345 opened 3 years ago

ShadowKing345 commented 3 years ago

Before creating a feature request

What is the user problem or growth opportunity you want to see solved?

When creating a theme, you cannot pass user defined variables to the calc function. Being allowed to use user defined variables to calculate would be nice to have.

How do you know that this problem exists today? Why is this important?

When you attempt to pass a variable and open rofi, the error "syntax error, unexpected Reference, expected Integer number or Floating-point number or "Parent left ('(')" ".

Example code

* {
     variable-amount: 30px;
}

listview {
     padding: calc(10px + @variable-amount);
}

Who will benefit from it?

In theory, anyone who uses themes and variables to dynamically change the way output looks.

Version

Output of rofi -v " Version: 1.6.1 "

Configuration

https://gist.github.com/ShadowKing345/b1b6f0d26edf8bd8e0828035504027d9

Additional details: I am trying to create a dmenu options script that i want to dynamically changes the padding based on the number of elements provided. While i have managed to get the basic padding working for 5 elements i don't want to create a copy of the theme and alter the variables for 2 or n number of elements.

Gist of theme file for power options. https://gist.github.com/ShadowKing345/f939c19bedefb55db4e6a1e24fa0e13f

DaveDavenport commented 3 years ago

This not possible in the current implementation and would require significant effort (I think ) to get implemented right. Currently a variable replaces the full 'right hand side' of the assignment, and cannot be partial.

ShadowKing345 commented 3 years ago

I understand. I will keep this in mind for now and find alternative methods of reducing redundancy. I am not sure if I should close this request or just leave it in case one day it will be completed.

DaveDavenport commented 3 years ago

Lets leave it open.

What is supported atm is environment variables, those can be mixed at any point. (it is handled in the tokonizer)

ShadowKing345 commented 3 years ago

So I can specify a environment variable and it can be used in a calc function without issue. Lovely. I will look through the docks to see how they are done then do some prototyping. Thank you.

DaveDavenport commented 3 years ago

Never tested this, but I think it should work. I would like to add some more flexibility to the parser (like implementing this feature request) but I do not have the time atm. (I first want to get rid of the multiple older configuration options and 'backwards' compatibility.)

ShadowKing345 commented 3 years ago

It does and I understand.