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

[BUG] Including themes (.rasi vs .rasinc extension) #2069

Closed
2 tasks done
flipsi opened this issue Jan 2, 2025 · 11 comments
Closed
2 tasks done

[BUG] Including themes (.rasi vs .rasinc extension) #2069

flipsi opened this issue Jan 2, 2025 · 11 comments
Labels
Milestone

Comments

@flipsi
Copy link

flipsi commented Jan 2, 2025

Rofi version (rofi -v)

1.7.6-dirty

Configuration

https://gist.github.com/flipsi/ecf442bdb71121830c5e7b22b99d55a0

Theme

https://gist.github.com/flipsi/d128959fa8ee6a5cb6a769657cf77e3c

Timing report

https://gist.github.com/flipsi/0d781e139b45cdcdfc56e8107242a42e

Launch command

rofi -show window

Step to reproduce

  • Have a custom theme in the user directory, like ~/.config/rofi/themes/gruvbox-dark-purple.rasi
  • In the custom theme file, include a global theme , like @import "gruvbox-common.rasi"
  • Run any rofi command

Expected behavior

The global theme is imported correctly in rofi version 1.7.5 (I upgrade the Arch Linux package from 1.7.5-3 to 1.7.6-4 and ran into this bug).

I expect the theme import to not fail when upgrading from 1.7.5 to 1.7.6.

Actual behavior

The import fails, leading to an almost unreadable UI (due to low contrast text) with the following error:

Failed to open theme: /home/flipsi/gruvbox-common.rasi
Error: No such file or directory

Additional information

Further investigation revealed that the global theme in /usr/share/rofi/themes changed its extension, presumably it's now some compiled version for performance reasons.

So I was able to workaround the issue by changing my config from

@import "gruvbox-common.rasi"

to

@import "gruvbox-common.rasinc"

I don't know what caused this, but the changelog hasn't been updated since a few versions, so as a user one is a little lost.

What makes the failure more confusing is the fact that the error message only prints the failed file loading attempt for the user's home directory (/home/flipsi and not /usr/share/rofi/themes). So this looks like something is wrong with the searched directories or relative/absolute paths.

Using wayland display server protocol

  • No, I don't use the wayland display server protocol

I've checked if the issue exists in the latest stable release

  • Yes, I have checked the problem exists in the latest stable version
@flipsi flipsi added the bug label Jan 2, 2025
flipsi added a commit to flipsi/dotfiles that referenced this issue Jan 2, 2025
@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Jan 2, 2025

Further investigation revealed that the global theme in /usr/share/rofi/themes changed its extension, presumably it's now some compiled version for performance reasons.

See for changelog here:
https://github.com/davatorium/rofi/releases/tag/1.7.6

I think this is the issue, in your custom theme:

@import "gruvbox-common.rasi"

I think that should have been:

@import "gruvbox-common"

I will test this.

@DaveDavenport
Copy link
Collaborator

Ok, it does not resolve it right.. Will fix, thanks for reporting.

@DaveDavenport DaveDavenport added this to the 1.7.7 milestone Jan 2, 2025
@DaveDavenport
Copy link
Collaborator

Above commit, should now correctly resolve rasinc if no extension is provided. (Was a TODO still in code).
This should make this behaviour more consistent.. Will also update themes to import without extension.

@DaveDavenport
Copy link
Collaborator

Further investigation revealed that the global theme in /usr/share/rofi/themes changed its extension, presumably it's now some compiled version for performance reasons.

This was requested so its easier to distinguish between a theme and shared files. No 'pre-compilation' happening.

DaveDavenport added a commit that referenced this issue Jan 2, 2025
Resolve both .rasi and .rasinc and what order

Issue: #2069
@flipsi
Copy link
Author

flipsi commented Jan 3, 2025

Thank you for being so responsive and fixing this! 👍

Also thank you for pointing me to the new changelog. I was going to suggest to add a note to the old one, but I see you already did this. 👏

Does this mean (even though importing themes without extension seems to be the recommended way), imports with the .rasi extension will fail in 1.7.6? Because wouldn't that be a breaking change? If so:

  • Did you consider "magically"/"dirtily" resolving .rasi to .rasinc in order to not break UX?
  • Should this be highlighted in the changelog? It hardly falls under "Other smaller changes" IMHO, since the behavior I described leaks the internal change.

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Jan 3, 2025

  • Did you consider "magically"/"dirtily" resolving .rasi to .rasinc in order to not break UX?

No. If explicitly specified, the tool should not change extension. That would cause more confusion then anything else.
Nothing is broken compared to previous versions

To me there is no UX break. I think the only place where it affected people was your usecase, where you import part of a theme file that was shipped with previous rofi that is no longer part of current rofi. (If you would have copied the old common file into your local theme dir, everything still would have worked fine).

The ""fix"" here is to work with it more transparently and avoid possible issues in the future, but I don't really see this as a bug as everything was working as intended and documented.

@DaveDavenport
Copy link
Collaborator

Does this mean (even though importing themes without extension seems to be the recommended way), imports with the .rasi extension will fail in 1.7.6? Because wouldn't that be a breaking change? If so:

Does it? or is this an assumption?

@flipsi
Copy link
Author

flipsi commented Jan 3, 2025

No. If explicitly specified, the tool should not change extension. That would cause more confusion then anything else.

Generally agreed!

To me there is no UX break. I think the only place where it affected people was your usecase, where you import part of a theme file that was shipped with previous rofi that is no longer part of current rofi.

Yes. Unfortunately I don't remember how I created my config years ago, but I would assume I copied the import statement from the docs somewhere. If that's the case, it's likely that more users will run into my issue - and if the import including the extension was part of the official docs at some point, one could consider (re-)moving the gruvbox theme file a breaking change.

But you are right, I see that the import behavior is in fact documented well.

@DaveDavenport
Copy link
Collaborator

one could consider (re-)moving the gruvbox theme file a breaking change.

Agree. I think this slipped through the Changelog as an explicit note, given the change was made a long time ago (2 years), and nobody had any issues with it, until now and have been very busy and little time/energy/motivation for rofi.

@flipsi
Copy link
Author

flipsi commented Jan 3, 2025

Does it? or is this an assumption?

I just assumed this based on your post above.

The docs say

@import "myfile"

which kind of implies with extension to me, despite the good explanation right after:

A name is resolved (if it has no valid extension) as a filename by appending the .rasi and the .rasinc extension. It will first look for files with .rasi, then for files with .rasinc.

Maybe this could be nudged for better by using theme-name instead of myfile.

@flipsi
Copy link
Author

flipsi commented Jan 3, 2025

Agree. I think this slipped through the Changelog as an explicit note, given the change was made a long time ago (2 years), and nobody had any issues with it, until now and have been very busy and little time/energy/motivation for rofi.

I didn't know it has been so long already. That's a good indicator it will not affect as many users as I feared 👍 Let's hope for the best!

Thank you for all your efforts!

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

No branches or pull requests

2 participants