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] Searching for a theme fails when a file exists in CWD with the same name #1889

Closed
2 tasks done
aarondill opened this issue Aug 15, 2023 · 8 comments
Closed
2 tasks done
Assignees
Labels
Milestone

Comments

@aarondill
Copy link

aarondill commented Aug 15, 2023

Rofi version (rofi -v)

Version: 1.7.1 AND Version: 1.7.5

Configuration

N/A

Theme

N/A

Timing report

https://gist.github.com/aarondill/405e6a5811943cbcd84fa6c59c47a8b2

Launch command

rofi -show

Step to reproduce

  1. mkdir -p ~/.config/rofi
  2. make ~/.config/rofi/config.rasi with the contents @theme "theme_name"
  3. touch ~/.config/rofi/theme_name.rasi
  4. Create a file in your CWD with the name theme_name
  5. rofi -show
  6. Observe the failure from rofi (/ was the absolute path):
The following errors were detected when starting rofi:

Failed to open theme: /<HOME>/<USER>/.config/rofi/theme_name
Error: No such file or directory
  1. touch ~/.config/rofi/theme_name (notice no .rasi)
  2. rofi -show
  3. Success. ☹️ This is not supposed to happen.
  4. rm ~/.config/rofi/theme_name
  5. rm ./theme_name
  6. rofi -show
  7. Success 😄

Expected behavior

The presence of a file in your CWD with the name of the theme should not rofi's ability to search XDG_CONFIG_HOME (or other files) for the theme

Actual behavior

A file named the same as the theme in your CWD makes rofi search for the theme without a file extension.

Additional information

This is not an issue with @theme "theme_name.rasi". Since the .rasi extension is never added anyways, theme_name.rasi is correctly found.

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
@aarondill aarondill added the bug label Aug 15, 2023
@aarondill
Copy link
Author

aarondill commented Aug 15, 2023

Here is a simple bash script that can be used to test this.
Simply run ./repro.sh and press escape when rofi spawns:

./repro.sh
With file in CWD - @theme without .rasi
should pass: failed
should pass: failed
should fail: passed

Without file in CWD - @theme without .rasi
should pass: passed
should pass: passed
should fail: failed

With file in CWD - @theme full name
should pass: passed
should pass: passed
should fail: passed

Without file in CWD - @theme full name
should pass: passed
should pass: passed
should fail: failed

@DaveDavenport
Copy link
Collaborator

To avoid confusion, what do you mean with version 1.7.6?
The latest stable is 1.7.5, the latest git is 1.7.5-162-g52841926.

@DaveDavenport DaveDavenport added this to the 1.7.6 milestone Aug 15, 2023
@DaveDavenport DaveDavenport self-assigned this Aug 15, 2023
@aarondill
Copy link
Author

@DaveDavenport That was a typo. I downloaded the latest stable (1.7.5) and tested against it.

@DaveDavenport
Copy link
Collaborator

Thanks, and thanks for updating the issue.

I see that on trying to open the file it does:

fn = rofi_expand_path(file)l
if ( g_file_test(fn,EXISTS)){
}

Before it tries to look up the path.
This causes the issue, lets fix this.

@DaveDavenport
Copy link
Collaborator

This needs testing.

@DaveDavenport
Copy link
Collaborator

The specified file can either by name, filename,full path.

If a filename is provided, it will try to resolve it in the following order:

  • If path is absolute and file exists, it will open the file. This includes expansion of '~' or '~user'
  • On an @import or @theme it looks in the directory of the file that tried to include it.
  • ${XDG_CONFIG_HOME}/rofi/themes/
  • ${XDG_CONFIG_HOME}/rofi/
  • ${XDG_DATA_HOME}/rofi/themes/
  • ${INSTALL PREFIX}/share/rofi/themes/

A name is resolved (if it has no valid extension) as a filename by appending the .rasi extension.

@DaveDavenport
Copy link
Collaborator

pushed some more small (backward comp.) fixes.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants