hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.5k stars 899 forks source link

allow hotreloading config variables from hyprctl/socket/dispatcher #2004

Open flick0 opened 1 year ago

flick0 commented 1 year ago

prolly something like:

hyprctl dispatch update var value
vaxerski commented 1 year ago

?

flick0 commented 1 year ago

like, if i have this in config image

and i run hyprctl dispatch update round 20, it updates that value and changes rounding of window to 20

bvr-yr commented 1 year ago

but hyprctl keyword decoration:rounding 30 do this? unless u have $round used somewhere else and u need exactly varchange

flick0 commented 1 year ago

yes, that was just an example i want to pass these variables in scripts and stuff and having them neatly configurable through socket will be helpful, for example control wofi rounding and window rounding with just one variable in config that can also be updated through socket

vaxerski commented 1 year ago

variables are not kept track of in the config in any way shape or form. They're a glorified copy+paste mechanism, so this is not possible atm, and I probably will not add it in the nearest future as it's stupid. You have very few vars to worry about in hl anyways.

bvr-yr commented 1 year ago

as of man 1 wofi u can't hotreload, u can just use another cfg with -c flag. This kinda approach works for me with eww, cause u can change runtime vars So i think the best way to get whatcha need is pepega shenanigans with rewriting cfg files and reloading whatever u need with appropriate commands In case of wofi it could come to a really wonky stuff like sed <wofi-cfg> && killall wofi && wofi [etc] As a suggestion for a launcher, u can try tofi u can start/restart with --key=value flags (i.e. read your desirable vars in script and reload both, launcher and hl cfg)

josser commented 1 year ago

There is one marginal case for this, maybe if var changing is not possible you can suggest something else Maybe this may looks weird or irrelevant, but please, read the whole story )

I want to reproduce osx behavior for hotkeys + layout switching on cmd + space. I.e use cmd+c, cmd+v for copy / pasting, and all common hotkeys are bind to cmd (win) key instead of ctrl. What I've made first was kb_options = grp:ctrl_space_toggle,ctrl:swap_lwin_lctl So, I've just swicted ctrl and cmd and everything looks good. but that's not enough, as there is terminal applications in terminal apps we want CTRL on real place, to able to use ctrl+c for SIGINT and all other hotkeys. i.e cmd+c in terminal should continue working as 'copy' but ctrl+c should work as SIGINT. So, for terminal we have to use kb_options grp:win_space_toggle

I've made a simple plugin which listen for activeWindow event and do something like:

 if (current_app_title == 'kitty') {
            if (current_app_title != prev_app_title) {
                HyprlandAPI::invokeHyprctlCommand("keyword", "input:kb_options grp:win_space_toggle");
            }
        } else {
            if (prev_app_title == 'kitty') {
                HyprlandAPI::invokeHyprctlCommand("keyword", "input:kb_options grp:ctrl_space_toggle,ctrl:swap_lwin_lctl");
            }
        } 

Fancy! But still not perfect. As we have $mainMod and for cli it should be SUPER but for gui it should be CTRL.

Maybe mainMod should be keyword?