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

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

Open
2 tasks done
ShadowKing345 opened this issue Jan 21, 2021 · 6 comments
Open
2 tasks done

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

ShadowKing345 opened this issue Jan 21, 2021 · 6 comments

Comments

@ShadowKing345
Copy link

Before creating a feature request

  • I checked the next branch to see if the feature has already been
    implemented

  • I searched existing reports to see if it is already requested.

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

It does and I understand.

AndreasNasman added a commit to AndreasNasman/.config that referenced this issue Dec 23, 2022
Environment variables have to be used for now as global variables don't
work with `calc` in Rofi.
davatorium/rofi#1258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants