hyprwm / hyprlang

The official implementation library for the hypr config language.
https://wiki.hyprland.org/Hypr-Ecosystem/hyprlang/
GNU Lesser General Public License v3.0
137 stars 16 forks source link

Feature request: include variable expansion in source command. #32

Closed haydonryan closed 7 months ago

haydonryan commented 7 months ago

I'm trying to write a cross machine configuration file so that both my laptop and desktop are able to use the same base hyprland config. My Desktop has a very different keyboard to my laptop, and i need to swap the control and caps lock on the laptop. My Desktop also has multiple monitors, one which is portrait.

What I'm trying to do is use the $HOSTNAME environment variable in the hyperlang config to call machine specific something like the following:

source=~/.config/hypr/machine-{$HOSTNAME}.conf

I know it's possible in bash, but would be super awesome if it was possible to do something like this in hyprlang.

The dotfiles are all stored in git repos, and sync'ed via an update script.

Would it be possible to pull in more than a static source file?

vaxerski commented 7 months ago

that should be already working, though?

haydonryan commented 7 months ago

In bash this works, but in hyprlang it doesn't. I get an error. I've tried a bunch of variations, and there's nothing in the wiki about being able to do this.

vaxerski commented 7 months ago

what are you using to test this? are you sure $HOSTNAME is set at the time of parsing?

haydonryan commented 7 months ago

Good point on the $HOSTNAME not being set. I need to do some more testing.

How I tested was I moved the exec-once waybar to the $HOSTNAME.yaml.

What is the correct syntax of hyrpang to use $HOSTNAME? Are there any examples in the wiki / or you can provide.

vaxerski commented 7 months ago

wdym to use $HOSTNAME?

It has to either be an env var, or be defined with $HOSTNAME = deez nuts

haydonryan commented 7 months ago

In the hyrlang.conf file - Which line should work?

source=~/.config/hypr/machine-{$HOSTNAME}.conf
source=~/.config/hypr/machine-$HOSTNAME.conf
vaxerski commented 7 months ago

what? both will work provided the variable is defined - one will put {} around it, the other wont