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

Feature: Support variables and importing conf with source keyword to enable sharing definitions with hyprland conf #82

Open
timblaktu opened this issue Aug 11, 2023 · 1 comment

Comments

@timblaktu
Copy link

timblaktu commented Aug 11, 2023

Adding support for variables and the source keyword would enable a DRY hyprland/paper config. Instead of having to write magic strings more than once in the config files, e.g. the wallpaper file paths as shown in the example in the readme, the example could look like this:

Example:

If your wallpapers are stored in ~/Pictures, then make sure you have already preloaded the desired wallpapers in hyprpaper.conf.

Hyperpaper supports sourcing variables just like hyprland, enabling sharing common variables and a DRY config.

~/.config/hypr/variables.conf

$w1 = ~/Pictures/myepicpng.png
$w2 = ~/Pictures/myepicpngToo.png
$w3 = ~/Pictures/myepicpngAlso.png
#... continue as desired, but be mindful of the impact on memory.

~/.config/hypr/hyprpaper.conf

source ~/.config/hypr/variables.conf
preload = $w1
preload = $w2
preload = $w3
#... continue as desired, but be mindful of the impact on memory.

The Hyprland config can sourced these shared variables, and use them in defining new variables for ease of reading and to be used as shortcuts in the bind command.:

~/.config/hypr/hyprland.conf

source ~/.config/hypr/variables.conf
$wc1 = hyprctl hyprpaper wallpaper "DP-1,$w1" 
$wc2 = hyprctl hyprpaper wallpaper "DP-1,$w2" 
$wc3 = hyprctl hyprpaper wallpaper "DP-1,$w3" 
# yes, use quotes around desired monitor and wallpaper
#... continued with desired amount

With the variables created we can now "exec" the actions.

Remember in Hyprland we can bind more than one action to a key so in the case where we'd like to change the wallpaper when we switch workspace we have to ensure that the actions are bound to the same key such as...

~/.config/hypr/hyprland.conf

bind=SUPER,1,workspace,1  #Superkey + 1 switches to workspace 1
bind=SUPER,1,exec,$wc1    #SuperKey + 1 switches to wallpaper $w1 on DP-1 as defined in the variable

bind=SUPER,2,workspace,2  #Superkey + 2 switches to workspace 2
bind=SUPER,2,exec,$wc2    #SuperKey + 2 switches to wallpaper $w2 on DP-1 as defined in the variable

bind=SUPER,3,workspace,3  #Superkey + 3 switches to workspace 3
bind=SUPER,3,exec,$wc3    #SuperKey + 3 switches to wallpaper $w3 on DP-1 as defined in the variable

#... and so on 

Because the default behavior in Hyprland is to also switch the workspace whenever movetoworkspace is used to move a window to another workspace you may want to include the following:

bind=SUPERSHIFT,1,movetoworkspace,1  #Superkey + Shift + 1 moves windows and switches to workspace 1
bind=SUPERSHIFT,1,exec,$wc1          #SuperKey + Shift + 1 switches to wallpaper $w1 on DP-1 as defined in the variable

#... and so on 
@timblaktu timblaktu changed the title Feature: Support importing conf with source keyword to enable sharing definitions with hyprland conf Feature: Support variables and importing conf with source keyword to enable sharing definitions with hyprland conf Aug 11, 2023
@luravoid
Copy link

luravoid commented Aug 28, 2024

Can we get some feedback on this? It seems like a really reasonable feature request, especially the part about sourcing other parts of the config in the same way as in hyprland.conf. This would make it easier for third-party applications, such as GUI wallpaper setters, to permanently set a wallpaper. Having a separate config files for preloading and setting wallpapers would be much more manageable for programs to edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants