stylix icon indicating copy to clipboard operation
stylix copied to clipboard

gtk: moved the theme directory from '~/.themes' to '~/.local/share/themes'

Open starrymohannad opened this issue 8 months ago • 17 comments

changed one variable to make gtk themes generate in ~/.local/share/themes to adhere to the xdg specifications

starrymohannad avatar Apr 16 '25 18:04 starrymohannad

could/should this be done with xdg.dataFile?

Flameopathic avatar Apr 17 '25 01:04 Flameopathic

when I try replacing ${config.home.homeDirectory} to ${config.xdg.dataFile}

I get this error:

warning: Git tree '/home/starry/.local/nix' is dirty
building the system configuration...
warning: Git tree '/home/starry/.local/nix' is dirty
error:
       … while calling the 'head' builtin
         at /nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source/lib/attrsets.nix:1534:13:
         1533|           if length values == 1 || pred here (elemAt values 1) (head values) then
         1534|             head values
             |             ^
         1535|           else

       … while evaluating the attribute 'value'
         at /nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source/lib/modules.nix:1084:7:
         1083|     // {
         1084|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1085|       inherit (res.defsFinal') highestPrio;

       … while evaluating the option `system.build.toplevel':

       … while evaluating definitions from `/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source/nixos/modules/system/activation/top-level.nix':

       … while evaluating the option `warnings':

       … while evaluating definitions from `/nix/store/5ds20jm3x2s4z7wn3581r6lc9ybmh45b-source/nixos/modules/system/boot/systemd.nix':

       … while evaluating the option `systemd.services.home-manager-starry.serviceConfig':

       … while evaluating definitions from `/nix/store/dpn4lj4ll8972gsdhjrhamxyxri8g6ql-source/nixos':

       … while evaluating the option `home-manager.users.starry.home.file."/home/starry/.local/share/flatpak/overrides/global".source':

       … while evaluating definitions from `/nix/store/dpn4lj4ll8972gsdhjrhamxyxri8g6ql-source/modules/files.nix':

       … while evaluating the option `home-manager.users.starry.home.file."/home/starry/.local/share/flatpak/overrides/global".text':

       … while evaluating definitions from `/nix/store/dpn4lj4ll8972gsdhjrhamxyxri8g6ql-source/modules/misc/xdg.nix':

       … while evaluating the option `home-manager.users.starry.xdg.dataFile."flatpak/overrides/global".text':

       … while evaluating definitions from `/nix/store/fk2xyq5r00135cvpsaz091cld1cgfjaa-source/modules/gtk/hm.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: cannot coerce a set to a string: { "fcitx5/themes/stylix/highlight.svg" = { enable = true; executable = null; force = false; onChange = ""; recursive = false; source = "/nix/store/vri736vjyfc75ahwvws4lzf4j3cp49i9-catppuccin-frappe/base16-catppuccin-frappesvg"; target = ".local/share/fcitx5/themes/stylix/highlight.svg"; text = null; }; "fcitx5/themes/stylix/panel.svg" = { enable = true; «7 attributes elided» }; «7 attributes elided» }

starrymohannad avatar Apr 17 '25 15:04 starrymohannad

It actually worked fine this time :DD

starrymohannad avatar Apr 17 '25 18:04 starrymohannad

lol I forgot :P

starrymohannad avatar Apr 18 '25 14:04 starrymohannad

yipeeeeeeeeeeeee :3

starrymohannad avatar Apr 18 '25 15:04 starrymohannad

there is one issue however

flatpak apps doesn't seem to support the theme

starrymohannad avatar Apr 18 '25 15:04 starrymohannad

It seems like the issue is from the GTK_THEME variable not pointing to the correct theme for some reason

starrymohannad avatar Apr 18 '25 16:04 starrymohannad

Perhaps something is different inside the Flatpak environment so that it only looks at ~/.themes? Is there a way to mount the filesystem inside Flatpak at that path while still using the new path outside?

danth avatar Apr 18 '25 17:04 danth

the override mount the ~/.local/share/themes directory but for some reason the app can't detect the theme

starrymohannad avatar Apr 18 '25 17:04 starrymohannad

It turns out that flatpak can't detect themes in the ~/.local/share/themes directory even if they are mounted to the flatpak environment

https://discussion.fedoraproject.org/t/flatpaks-dont-use-applied-theme-even-when-giving-them-access/126475

starrymohannad avatar Apr 19 '25 06:04 starrymohannad

It turns out that flatpak can't detect themes in the ~/.local/share/themes directory even if they are mounted to the flatpak environment

https://discussion.fedoraproject.org/t/flatpaks-dont-use-applied-theme-even-when-giving-them-access/126475

Maybe a similar approach to commit 963e77a3a4fc ("gtk: add support for theming Flatpak applications (#693)") is possible here.

trueNAHO avatar Apr 30 '25 13:04 trueNAHO

It turns out that flatpak can't detect themes in the ~/.local/share/themes directory even if they are mounted to the flatpak environment https://discussion.fedoraproject.org/t/flatpaks-dont-use-applied-theme-even-when-giving-them-access/126475

Maybe a similar approach to commit 963e77a ("gtk: add support for theming Flatpak applications (#693)") is possible here.

does it use the ~/.themes only when flatpak compatibility is enabled and when it's disabled it uses ~/.local/share/themes ?

starrymohannad avatar Apr 30 '25 16:04 starrymohannad

It turns out that flatpak can't detect themes in the ~/.local/share/themes directory even if they are mounted to the flatpak environment https://discussion.fedoraproject.org/t/flatpaks-dont-use-applied-theme-even-when-giving-them-access/126475

Maybe a similar approach to commit 963e77a ("gtk: add support for theming Flatpak applications (#693)") is possible here.

does it use the ~/.themes only when flatpak compatibility is enabled and when it's disabled it uses ~/.local/share/themes ?

IIUC, it simply adds a

(lib.mkIf cfg.flatpakSupport.enable /* ... */)

clause to handle Flatpak additionally.

trueNAHO avatar May 05 '25 14:05 trueNAHO

okay :3

starrymohannad avatar May 08 '25 18:05 starrymohannad

tbh I don't know what to do from here :v

I was thinking of making a symlink to ~/.local/themes in the ~/.themes of the flatpak local home directory but I don't think there is a way to do such thing

starrymohannad avatar May 09 '25 19:05 starrymohannad

@brckd, do you mind helping out? You might be more familiar with the Flatpak workings.

trueNAHO avatar May 16 '25 17:05 trueNAHO

Hi, thanks for mentioning me! As you have figured out, placing the theme files in ~/.themes was a workaround to make Flatpak apps work with GTK. These files are exclusively used for Flatpak support. IIRC the GTK theme set by Home Manager is already located in the recommended XDG directory. I chose the non-standard directory in order to not override that theme and because it had more legacy support.

I apologize for not making this fact more clear before. However, I think this discussion is still valuable, since the Flatpak support had issues with some apps, which weren't colored correctly. Last time I checked I couldn't find a workaround for it, but I believe it was caused by this non-standard theming approach.

brckd avatar May 16 '25 19:05 brckd