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

gtk+ 2 doesn't recognize default themes #25838

Closed
shosti opened this issue May 16, 2017 · 22 comments
Closed

gtk+ 2 doesn't recognize default themes #25838

shosti opened this issue May 16, 2017 · 22 comments

Comments

@shosti
Copy link
Contributor

shosti commented May 16, 2017

Issue description

gtk+ 2 comes with a few default themes ("Default", "Raleigh", and "Emacs"), but by default gtk apps don't seem to be able to pick them up.

Steps to reproduce

  1. Install chromium (through /etc/nixos/configuration.nix)
  2. echo 'gtk-key-theme-name="Emacs"' >> ~/.gtkrc-2.0
  3. Launch chromium
  4. Try using Emacs keybindings (for instance, C-a in the search bar)

Expected: Uses Emacs keybindings
Actual: Uses default keybindings

(I was able to work around the issue by copying from the nix store for gtk to ~/.themes.)

Technical details

  • System: NixOS 17.03.1152.22da5d0246 (Gorilla)
  • Nix version: nix-env (Nix) 1.11.8
  • Nixpkgs version: "17.03.1152.22da5d0246"
  • Sandboxing enabled: build-use-sandbox = false
@pbogdan
Copy link
Member

pbogdan commented May 16, 2017

Would be interested in this as well, currently my /etc/nixos/configuration.nix features:

  # this is needed so that gtk can find emacs key theme
  environment.extraInit = ''
    # argh
    mkdir ~/.themes/ 2>/dev/null
    ln -sf "${pkgs.gnome2.gtk}/share/themes/Emacs" ~/.themes/

    export XDG_DATA_DIRS="${pkgs.gnome3.gtk}/share:$XDG_DATA_DIRS"
  '';

:/

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

@pbogdan and with this change it works for you?

@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

@Mic92 yes, it does. Once I adjust .config/gtk-3.0/settings.ini and .gtkrc-2.0 to use Emacs key theme I get them working in both gtk+2 and gtk+3 apps.

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

if you install gnome2.gtk in systemPackages or via nix-env, it will get a symlink in ~/.nix-profile/share/themes or /run/current-system/sw/share/themes. Since these directories are also in XDG_DATA_DIR, they should be picked up by applications like Chrome. This should at least work for gtk3. I am not 100% sure about gtk2 though.

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

Just tested it and the chromium example worked for me.

@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

IIRC gtk+2 won't search through any of $XDG_DATA_DIRS but has hardcoded list of folders ~/.themes and $GTK_DATA_PREFIX/share/themes ($GTK_DATA_PREFIX must contain a single path I think).
Did you install gtk system wide or into your profile?
The issue then is that you can't have both in a single profile due to collisions.

@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

Some digging turned up this patch from our Guix friends 😄 - https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/patches/gtk2-theme-paths.patch - which enables gtk+2 to search through $XDG_DATA_DIRS

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

I had it in my profile, but system wide should working the same following the logic. Also just using ~/.gtkrc-2.0 was enough. You also have to really kill chromium. It tends to leave running background processes.

@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

Odd, gtk+2 doesn't look at $XDG_DATA_DIRS AFAIK. What's your $GTK_DATA_PREFIX set to?

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

Seems like I that this at some point:

$ echo $GTK_DATA_PREFIX                        
/run/current-system/sw

@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

Anything under /run/current-system/sw/share/themes/ ? I would guess that's where it gets picked up from there though it would be strange for a package installed via user profile. Unless you have anything under ~/.themes perhaps?

@shosti
Copy link
Contributor Author

shosti commented May 17, 2017

All installations for me are global, and I'm using xmonad (gnome isn't installed and I'd like to avoid installing it if possible). It looks like the themes don't end up in /run/current-system/sw/share/themes/:

~ $ echo $XDG_DATA_DIRS
/nix/store/wgghc6zvhc1jjy8h76czp6z16kg0qk3g-emacs-25.1/share:/nix/store/zp3zcinsx7d5fa6mc407pz1bndk7wl2v-gtk+3-3.22.8/share/gsettings-schemas/gtk+3-3.22.8:/nix/store/9755bvfhzln5yrbjnjarl6p5vczmsgnl-gsettings-desktop-schemas-3.22.0/share/gsettings-schemas/gsettings-desktop-schemas-3.22.0:/nix/store/wgghc6zvhc1jjy8h76czp6z16kg0qk3g-emacs-25.1/share:/nix/store/zp3zcinsx7d5fa6mc407pz1bndk7wl2v-gtk+3-3.22.8/share/gsettings-schemas/gtk+3-3.22.8:/nix/store/9755bvfhzln5yrbjnjarl6p5vczmsgnl-gsettings-desktop-schemas-3.22.0/share/gsettings-schemas/gsettings-desktop-schemas-3.22.0:/run/opengl-driver/share:/home/shosti/.nix-profile/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
~ $ echo $GTK_DATA_PREFIX
/nix/store/d0f84nizpwdj6aiss7051ixn0aqakqwh-system-path
~ $ ls /run/current-system/sw/share/themes/
~ $ 

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

You do not need to install gnome, but gnome.gtk2 in systemPackages, which is already there (but not linked in /nix/store/d0f84nizpwdj6aiss7051ixn0aqakqwh-system-path) if you already have any gtk2 application like chromium.

@shosti
Copy link
Contributor Author

shosti commented May 17, 2017

Oh, sorry, misunderstood. It's definitely not linked in my case, either to /run/current-system/sw/share/themes/, or to $GTK_DATA_PREFIX/share/themes/.

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

I mean you have to explicitly add it to systemPackages, also it already lives in /nix/store.

@shosti
Copy link
Contributor Author

shosti commented May 17, 2017 via email

@shosti
Copy link
Contributor Author

shosti commented May 17, 2017

Actually I spoke too soon--it is linked to /run/current-system/sw/share/themes/ but chromium still isn't picking it up.

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

this is actually the same as the system-path package:

$ ls -al /run/current-system/sw
lrwxrwxrwx 1 root root 55 Jan  1  1970 /run/current-system/sw -> /nix/store/rqgbn2syh1d5av1kb4sl5dkdsi7zmizh-system-path/

@Mic92 Mic92 closed this as completed May 17, 2017
@pbogdan
Copy link
Member

pbogdan commented May 17, 2017

@shosti shot in the dark - you wouldn't happen to be running xsettingsd or another settings daemon like gnome-settings-daemon? Does stop / starting that help at all?

And sorry to bug - @Mic92 @shosti what display manager you are using?

@shosti
Copy link
Contributor Author

shosti commented May 17, 2017

Oh, actually I got it working--the problem was that GTK_DATA_PREFIX didn't get reset on nix-rebuild switch, so I had to log out and log in (it was pointing to the old system path).

(For the record, using xmonad.)

@Mic92
Copy link
Member

Mic92 commented May 17, 2017

@Mic92
Copy link
Member

Mic92 commented May 18, 2017

I will also port the GUIX patch to nixos: #25881

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

No branches or pull requests

3 participants