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

Modularize config #49

Open
ziQ opened this issue Jul 20, 2021 · 7 comments
Open

Modularize config #49

ziQ opened this issue Jul 20, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@ziQ
Copy link

ziQ commented Jul 20, 2021

openSUSEway looks beautiful, but seems a bit too opinionated to me.

It'd be nice to have the presentation separated from the function. It'd also be nice to define settings in one spot and then use (and re-use) them wherever needed. For example, have a central $lock_screen definition that gets re-used in all lockscreen keybindings and swayidle calls.

I suggest splitting the config into several files and use individual include instead of the blanket .../*.conf:

  • .config/sway/openSUSEway/theme.conf
    set $wallpaper /usr/share/wallpapers/default-1920x1080.jpg
    set $bgcolor 061c2a
    (...)
    output * bg $wallpaper fill
    
  • .config/sway/openSUSEway/definitions.conf
    set $lock_screen_timeout 300
    set $blank_screen_timeout 600
    
    set $lock_screen swaylock \
        --daemonize \
        --color $bgcolor \
        --layout-bg-color $bgcolor \
        --inside-color $bgcolor \
        --indicator-caps-lock \
        --image $wallpaper \
        --scaling fill
    
    (...)
    
  • .config/sway/openSUSEway/behavior.conf
    exec swayidle -w \
             timeout $lock_screen_timeout $lock_screen \
             timeout $blank_screen_timeout 'swaymsg "output * dpms off"' \
                  resume 'swaymsg "output * dpms on"' \
             before-sleep $lock_screen
    
    (...)
    
@denisok
Copy link
Contributor

denisok commented Jul 20, 2021

I agree, recently I tried Manjaro Sway build, and it has something similar. Quite a lot complicated, but I would think it is a right way to go.
https://github.com/Manjaro-Sway/manjaro-sway

Mind to submit some PRs with modifications?

@denisok denisok added the enhancement New feature or request label Jul 20, 2021
@FilippoBonazziSUSE
Copy link
Collaborator

I have been thinking about how to achieve this. Splitting configuration up in a few files rather than a single one is simple enough - as a matter of fact, that's what I have in my user configuration:
https://github.com/FilippoBonazziSUSE/dotfiles/tree/master/private_dot_config/sway/config.d

As long as the user configuration is loaded after the system one (which it is in openSUSEway), all definitions and bindsyms can be overridden. This works fine. I could easily submit a PR to achieve this.

It becomes trickier when one wants to override the exec[_always] sections in the system configuration. Right now this is a real annoyance for me, e.g. because I have a custom swayidle/swaylock configuration in my configuration and it results in two instances of swayidle being executed, one with the default openSUSEway configuration and one with my user configuration.
Of course I could nuke the openSUSEway system configuration and replicate everything in my user configuration, but that's not practical and beside the point.

I am at a loss on how to solve this in a constructive way. Suggestions?

@ziQ
Copy link
Author

ziQ commented Jan 19, 2023

Maybe something along the lines of:

  • Define defaults (as variables) in head of systemwide config /etc/sway/config (or split into .../config.pre and .../config.post)
  • Include some locations (/etc/sway/openSUSEway/default.conf, /etc/sway/openSUSEway/default.conf, /etc/sway/config.local, ~/.config/sway/openSUSEway/theme.conf, ...)
  • Override variables in included files where desirable
  • Use variables at the very bottom of /etc/sway/config

@FilippoBonazziSUSE
Copy link
Collaborator

Ok, I have tried this by having this structure:

/etc/sway/config:

...
include /etc/sway/config.d/*.conf

/etc/sway/config.d/50-openSUSE.conf still contains everything (definitions, bindsyms, ...) except exec and exec_always entries:

set $idle_handler swayidle -w ...
set $wob wob --config ...
set $notification_handler swaync --style ...

/etc/sway/config.d/90-user.conf includes the user configuration, allowing definitions to be overridden:

include ~/.config/sway/config.d/*

/etc/sway/config.d/95-exec.conf contains the exec and exec_always entries which were in 50-openSUSE.conf, modified to use the (possibly overridden) definitions:

exec_always {
    ...
    exec $notification_handler
}

exec $idle_handler
...

@FilippoBonazziSUSE
Copy link
Collaborator

I still would like to move as many of these exec[_always] as possible into systemd --user services, rather than have them executed by the window manager. Certainly swayidle, swaync and wob.

I will continue looking into how to provide openSUSEway configuration parameters to systemd --user services by default, while still allowing them to be overridden by the user. That seems quite tricky.

@denisok
Copy link
Contributor

denisok commented Feb 15, 2023

@FilippoBonazziSUSE I agree with you - systemd is the right way to go.

One problem with that - everything that is related to the user space (services, user .config dir) losks like is out of our control.

I see couple of ways to overcome this so far:

second one might be in pair with new sway of immutable OS and desktop in a container.

@FilippoBonazziSUSE
Copy link
Collaborator

Not sure I understand what you have in mind. I will do some more research of my own when I have time and come back to this

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

No branches or pull requests

3 participants