rofi icon indicating copy to clipboard operation
rofi copied to clipboard

[BUG] `-config` path resolved differently from `-theme` path

Open coloursofnoise opened this issue 1 year ago • 2 comments

Rofi version (rofi -v)

Version: 1.7.5

Configuration

https://gist.github.com/coloursofnoise/9a0c574a1c50df9aad94e78ebb09407c#file-config-rasi

Theme

https://gist.github.com/coloursofnoise/9a0c574a1c50df9aad94e78ebb09407c#file-theme-rasi

Timing report

No response

Launch command

rofi -config test.rasi

Step to reproduce

% cat  > `$XDG_CONFIG_HOME/rofi/test.rasi` <<EOF
configuration {
    modes: [ "filebrowser" ];
}
EOF
% rofi -config test.rasi -dump-theme

Expected behavior

-dump-config output should include modes: "filebrowser";.

Actual behavior

-dump-config output only has default values (/* modes: "window,drun,run,ssh";*/).

Additional information

This behaviour differs from the -theme option, which does work with test.rasi.

Using wayland display server protocol

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

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

  • [X] Yes, I have checked the problem exists in the latest stable version

coloursofnoise avatar Oct 16 '24 18:10 coloursofnoise

I am not sure this is a bug, but more intended behavior. We could change the behavior easily:

diff --git a/source/rofi.c b/source/rofi.c
index 9ebe28df..fb1224c7 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -328,7 +328,8 @@ static void print_main_application_options(int is_term) {
                  "Behave as a normal window. (experimental)", NULL, is_term);
   print_help_msg("-transient-window", "",
                  "Behave as a modal dialog that is transient to the currently "
-                 "focused window. (experimental)", NULL, is_term);
+                 "focused window. (experimental)",
+                 NULL, is_term);
   print_help_msg("-show", "[mode]",
                  "Show the mode 'mode' and exit. The mode has to be enabled.",
                  NULL, is_term);
@@ -1063,7 +1064,7 @@ int main(int argc, char *argv[]) {
       g_free(etc);
     }

-    if (config_path && g_file_test(config_path, G_FILE_TEST_IS_REGULAR)) {
+    if (config_path) {
       if (rofi_theme_parse_file(config_path)) {
         rofi_theme_free(rofi_theme);
         rofi_theme = NULL;

DaveDavenport avatar Oct 16 '24 18:10 DaveDavenport

One issue I could see is having the same filename in both $XDG_CONFIG_HOME/rofi and $XDG_CONFIG_HOME/rofi/themes, where presumably one would want -config to prioritize the former and -theme the latter. I think the distinction between config and theme is blurry enough that it shouldn't matter all that much though.

coloursofnoise avatar Oct 16 '24 19:10 coloursofnoise

@DaveDavenport Note that this change causes a regression when using -theme and the default config ~/.config/rofi/rofi.rasi does not exist.

> # save old config
> if [ -d ~/.config/rofi ]; then mv ~/.config/rofi ~/.config/rofi.bak; fi
> echo >| /tmp/rofi.rasi # empty file
> rofi -theme /tmp/rofi.rasi  -show
(process:55337): Rofi-WARNING **: 03:46:50.205: Failed to load theme. Try to load default:

Before 39f231b, this would work and load the default config (or whatever is in the file if not empty) After, it will display an error:

The following errors were detected when starting rofi: 

Failed to open theme: /home/aaron/.config/rofi/config.rasi
Error: No such file or directory 

Notably, it does work if you use -config instead. This may be intended behavior, but it broke my window manager, so I figured it's worth mentioning.

aarondill avatar Dec 31 '24 09:12 aarondill

Thanks for mentioning.

DaveDavenport avatar Dec 31 '24 10:12 DaveDavenport

For loading theme you can also do:

-theme-str '@theme "default"'

Can you test latest commit to see if it returns old behaviour?

DaveDavenport avatar Dec 31 '24 11:12 DaveDavenport

@aarondill ^^ (sorry forgot to task)

DaveDavenport avatar Dec 31 '24 11:12 DaveDavenport

@DaveDavenport yes, the latest commit fixes it

aarondill avatar Dec 31 '24 22:12 aarondill

This pull request 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[bot] avatar Feb 01 '25 00:02 github-actions[bot]