leftwm / leftwm

A tiling window manager for Adventurers
http://leftwm.org
MIT License
2.84k stars 185 forks source link

Theme configuration is not being applied #951

Closed zeerooth closed 1 year ago

zeerooth commented 1 year ago

Describe the bug

I have the following command in my theme's up script: leftwm command "LoadTheme $SCRIPTPATH/theme.ron" With the theme.ron contents being

(border_width: 5,
margin: 5,
workspace_margin: Some(5),
default_border_color: "#7C7F93",
floating_border_color: "#EA76CB",
focused_border_color: "#9ED4FB",
)

Yet, when I reload leftwm, the default settings are being applied instead. (border 1, margin 10 etc.)

All of this happens both in my custom theme and when I use the basic_polybar example . Any ideas? ><

Expected behavior (optional)

No response

Steps to reproduce (optional)

No response

Relevant log output (optional)

No response

OS / Distro

Linux 5.15.62 #1-NixOS x86_64

Additional System Information (optional)

No response

LeftWM Check

:: LeftWM version: 0.4.0
:: LeftWM git hash: NONE
:: Loading configuration . . .
[leftwm/src/bin/leftwm-check.rs:118] &config_filename = "/home/radek/.config/leftwm/config.ron"
[leftwm/src/bin/leftwm-check.rs:122] &contents = .....
    -> Configuration loaded OK
[leftwm/src/bin/leftwm-check.rs:68] &config = Config {
    modkey: "Mod4",
    mousekey: Some(
        Single(
            "Mod4",
        ),
    ),
    workspaces: Some(
        [],
    ),
    tags: Some(
        [
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
        ],
    ),
    max_window_width: None,
    layouts: [
        LeftWiderRightStack,
        MainAndDeck,
        MainAndVertStack,
        MainAndHorizontalStack,
        GridHorizontal,
        EvenHorizontal,
        EvenVertical,
        Fibonacci,
        CenterMain,
        CenterMainBalanced,
        Monocle,
        RightWiderLeftStack,
    ],
    layout_mode: Workspace,
    insert_behavior: Bottom,
    scratchpad: Some(
        [],
    ),
    window_rules: Some(
        [],
    ),
    disable_current_tag_swap: false,
    disable_tile_drag: false,
    disable_window_snap: true,
    focus_behaviour: Sloppy,
    focus_new_windows: true,
    sloppy_mouse_follows_focus: true,
    keybind: [
        .....
    ],
    state_path: None,
    theme_setting: ThemeSetting {
        border_width: 1,
        margin: Int(
            10,
        ),
        workspace_margin: Some(
            Int(
                10,
            ),
        ),
        default_width: Some(
            1000,
        ),
        default_height: Some(
            700,
        ),
        always_float: Some(
            false,
        ),
        gutter: None,
        default_border_color: "#000000",
        floating_border_color: "#000000",
        focused_border_color: "#FF0000",
        on_new_window_cmd: None,
    },
}
Checking if mousekey is set.
Mousekey is set.
Mousekey is okay.
Checking config for valid workspace definitions.
:: Checking keybinds . . .
    .....
    -> All keybinds OK
:: Checking environment . . .
:: XDG_RUNTIME_DIR: /run/user/1000, LOGINCTL OKAY
    -> Environment OK
:: Checking theme . . .
Found symlink `current`, pointing to theme folder: "/home/radek/.config/leftwm/themes/catppuccin"
Found: /home/radek/.config/leftwm/themes/current/theme.ron
The theme file looks OK.
Found `/home/radek/.config/leftwm/themes/current/down` with executable permissions: true
Found `/home/radek/.config/leftwm/themes/current/up` with executable permissions: true
    -> Theme OK
0323pin commented 1 year ago

Did you symlink your theme to current? ls -a .config/leftwm/themes?

VuiMuich commented 1 year ago

Is your build from a recent git version, or from the stable release? It's odd, that nix seems to strip the git hash info from the build.

We had a recent change to theme files, but this currently requires #![enable(implicit_some)] at the top of the theme.ron for the parser to work.

A fix is being worked on, but maybe we push a quick hotfix for this early on and refactor it with a cleaner solution in a follow up.

zeerooth commented 1 year ago

Did you symlink your theme to current? ls -a .config/leftwm/themes?

Yes, the theme is symlinked correctly, I can see it being applied + leftwm-check outputs:

:: Checking theme . . .
Found symlink `current`, pointing to theme folder: "/home/radek/.config/leftwm/themes/catppuccin"

Is your build from a recent git version, or from the stable release? It's odd, that nix seems to strip the git hash info from the build.

It's from 0.4.0 release included in nixpkgs

We had a recent change to theme files, but this currently requires #![enable(implicit_some)] at the top of the theme.ron for the parser to work.

I know, but all it changes is that you don't need to wrap some values in Some(...) isn't it? And I did that with workspace_margin: Some(5) in my theme - so it should still work like that.

Eskaan commented 1 year ago

Not only some, but most options (including the colors) are now options. I would recommend adding the #![enable(implicit_some)] line and trying if it works with that.

zeerooth commented 1 year ago

I changed the theme.ron to

#![enable(implicit_some)]
(border_width: 5,
margin: 5,
workspace_margin: 5,
default_border_color: "#7C7F93",
floating_border_color: "#EA76CB",
focused_border_color: "#9ED4FB",
)

Yet, it still doesn't apply and leftwm-check --verbose outputs:

:: LeftWM version: 0.4.0
:: LeftWM git hash: NONE
:: Loading configuration . . .
[leftwm/src/bin/leftwm-check.rs:118] &config_filename = "/home/radek/.config/leftwm/config.ron"
[leftwm/src/bin/leftwm-check.rs:122] &contents = ....
    -> Configuration loaded OK
[leftwm/src/bin/leftwm-check.rs:68] &config = Config {
    modkey: "Mod4",
    mousekey: Some(
        Single(
            "Mod4",
        ),
    ),
    workspaces: Some(
        [],
    ),
    tags: Some(
        [
            "1",
            "2",
            "3",
            "4",
            "5",
            "6",
        ],
    ),
    max_window_width: None,
    layouts: [
        LeftWiderRightStack,
        MainAndDeck,
        MainAndVertStack,
        MainAndHorizontalStack,
        GridHorizontal,
        EvenHorizontal,
        EvenVertical,
        Fibonacci,
        CenterMain,
        CenterMainBalanced,
        Monocle,
        RightWiderLeftStack,
    ],
    layout_mode: Workspace,
    insert_behavior: Bottom,
    scratchpad: Some(
        [],
    ),
    window_rules: Some(
        [],
    ),
    disable_current_tag_swap: false,
    disable_tile_drag: false,
    disable_window_snap: true,
    focus_behaviour: Sloppy,
    focus_new_windows: true,
    sloppy_mouse_follows_focus: true,
    keybind: [
        ....
    ],
    state_path: None,
    theme_setting: ThemeSetting {
        border_width: 1,
        margin: Int(
            10,
        ),
        workspace_margin: Some(
            Int(
                10,
            ),
        ),
        default_width: Some(
            1000,
        ),
        default_height: Some(
            700,
        ),
        always_float: Some(
            false,
        ),
        gutter: None,
        default_border_color: "#000000",
        floating_border_color: "#000000",
        focused_border_color: "#FF0000",
        on_new_window_cmd: None,
    },
}
Checking if mousekey is set.
Mousekey is set.
Mousekey is okay.
Checking config for valid workspace definitions.
:: Checking keybinds . . .
.....
    -> All keybinds OK
:: Checking environment . . .
:: XDG_RUNTIME_DIR: /run/user/1000, LOGINCTL OKAY
    -> Environment OK
:: Checking theme . . .
Found symlink `current`, pointing to theme folder: "/home/radek/.config/leftwm/themes/catppuccin"
Found: /home/radek/.config/leftwm/themes/current/theme.ron
The theme file looks OK.
Found `/home/radek/.config/leftwm/themes/current/down` with executable permissions: true
Found `/home/radek/.config/leftwm/themes/current/up` with executable permissions: true
    -> Theme OK
Eskaan commented 1 year ago

~~Is your theme file being called in your theme's up script? There should be a line like~~

leftwm-command "LoadTheme $SCRIPTPATH/theme.ron

Edit: It may be that your up script is calling the old toml file

VuiMuich commented 1 year ago

Is your theme file being called in your theme's up script?

There should be a line like


leftwm-command "LoadTheme $SCRIPTPATH/theme.ron

Yeah, they said so in the very beginning.

zeerooth commented 1 year ago

Okay, I think I kinda found out the source of the issue - I should've looked into journalctl -e: xsession[74103]: Error: ERROR: Couldn't find command-0.pipe Now the question is why does that happen?

Edit: I tried going back to the old echo "LoadTheme $SCRIPTPATH/theme.ron" > $XDG_RUNTIME_DIR/leftwm/command-0.pipe

But the theme still isn't applied (and there are no errors either in leftwm-check or journalctl).

Interestinly, if I migrate the theme back to toml, so: echo "LoadTheme $SCRIPTPATH/theme.toml" > $XDG_RUNTIME_DIR/leftwm/command-0.pipe

With theme.toml

border_width = 4
margin = 5
workspace_margin = 5 
default_border_color = '#7C7F93'
floating_border_color = '#EA76CB'
focused_border_color = '#9ED4FB'

It actually loads correctly again! Why?

VuiMuich commented 1 year ago

Can you please ls $XDG_RUNTIME_DIR/left*? There was some reports on discord about an issue with some weird artifact files in XDG_RUNDTIME_DIR, but it was kind of random and not reproducible. If the content of that dir (the lefthk one should be ok anyways) looks weird, you can try exit the xorg session, remove everything in $XDG_RUNTIME_DIR/leftwm/ and start leftwm again.

Do you have a chance to try the latest git release? Not sure how that works on NixOs, do you clone and then build from the flake.nix?

(The echo method is generally still ok, and basically leftwm-command is just a wraper to use "the right command pipe" if there are multiple sessions, like in case of a Xephyr instance of leftwm).

zeerooth commented 1 year ago

Can you please ls $XDG_RUNTIME_DIR/left*? There was some reports on discord about an issue with some weird artifact files in XDG_RUNDTIME_DIR, but it was kind of random and not reproducible. If the content of that dir (the lefthk one should be ok anyways) looks weird, you can try exit the xorg session, remove everything in $XDG_RUNTIME_DIR/leftwm/ and start leftwm again.

❯ ls $XDG_RUNTIME_DIR/left*
/run/user/1000/leftwm:
command-0.pipe  commands.pipe  current_state.sock

/run/user/1000/leftwm-lefthk:
command-0.pipe

i deleted the files, restarted the session and the files are the same (except for command-0.pipe missing from leftwm-lefthk dir)

Do you have a chance to try the latest git release? Not sure how that works on NixOs, do you clone and then build from the flake.nix?

(The echo method is generally still ok, and basically leftwm-command is just a wraper to use "the right command pipe" if there are multiple sessions, like in case of a Xephyr instance of leftwm).

I've tried the latest version from git ("main" branch) and yet the result is the same. The only change is that I needed to wrap all the values in theme.ron with Some(...) if not using #![enable(implicit_some) and I no longer get the error from using leftwm-command. Yet, the theme still doesn't work :/

VuiMuich commented 1 year ago
❯ ls $XDG_RUNTIME_DIR/left*
/run/user/1000/leftwm:
command-0.pipe  commands.pipe  current_state.sock

/run/user/1000/leftwm-lefthk:
command-0.pipe

i deleted the files, restarted the session and the files are the same (except for command-0.pipe missing from leftwm-lefthk dir)

The commands.pipe shouldn't be there, is it possible that there is somehow an older instance of leftwm that is trying to start? On my machine it looks like this:

~ >>> ls -l $XDG_RUNTIME_DIR/leftwm*
/run/user/1000/leftwm:
|rwx------ 0 vuimuich vuimuich 15 Nov 18:05  command-0.pipe
srwxr-xr-x 0 vuimuich vuimuich 11 Nov 13:04  current_state.sock

/run/user/1000/leftwm-lefthk:
|rwx------ 0 vuimuich vuimuich 11 Nov 13:04  command-0.pipe

I've tried the latest version from git ("main" branch) and yet the result is the same. The only change is that I needed to wrap all the values in theme.ron with Some(...) if not using #![enable(implicit_some) and I no longer get the error from using leftwm-command. Yet, the theme still doesn't work :/

This is also odd, for me and @Eskaan the hash [564bc32](https://github.com/leftwm/leftwm/commit/564bc327aba2ecc98cca474de75da858d334694c) doesn't require this anymore, can you post the hash you built off, please? Also have you checked logs if there is a hint why the theme fails?

0323pin commented 1 year ago

for me and @Eskaan the hash 564bc32 doesn't require this anymore

Can confirm this is the case, #![enable(implicit_some) is no longer required when using a build from the latest hash.

zeerooth commented 1 year ago

Whoops, sorry! Turns out I left services.xserver.windowManager.leftwm.enable = true in my configuration.nix so even when I was rebuilding leftwm from my local repo using the hash 564bc327aba2ecc98cca474de75da858d334694c that you mentioned above, the version 0.4.0 from nix repos was still being used.

Anyhow, after properly installing the newest version it still wasn't working, but after clearing $XDG_RUNTIME_DIR/leftwm/ dir again the issue was fixed and commands.pipe is indeed gone for good now.

I hope this might also help somebody in the future.

Thanks everybody for the help! ❤️