Thumbnails: Difference between revisions

Joshbuker (talk | contribs)
m Rephrase gdk-pixbuf intro
Joshbuker (talk | contribs)
m Fix typos and whitespace consistency
Line 5: Line 5:


* GNOME environments with the option <code>services.gnome.core-utilities.enable = false;</code>
* GNOME environments with the option <code>services.gnome.core-utilities.enable = false;</code>
* Custom environments built from ground-up using window managers like sway or hyperland
* Custom environments built from ground-up using window managers like sway or hyprland


=== Save yourself hours of troubleshooting!! ===
=== Save yourself hours of troubleshooting!! ===
Line 30: Line 30:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# configuration.nix
# configuration.nix
{ pkgs, ... }:  
{ pkgs, ... }:
 
{
{
   environment.systemPackages = [
   environment.systemPackages = [
     pkgs.ffmpeg-headless
     pkgs.ffmpeg-headless
Line 39: Line 39:


   # 'ffmpegthumbnailer.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
   # 'ffmpegthumbnailer.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 50: Line 49:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# configuration.nix
# configuration.nix
{ pkgs, ... }:  
{ pkgs, ... }:
 
{
{
   environment.systemPackages = [  
   environment.systemPackages = [  
     pkgs.gdk-pixbuf
     pkgs.gdk-pixbuf
Line 58: Line 57:


   # 'gdk-pixbuf-thumbnailer.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
   # 'gdk-pixbuf-thumbnailer.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
}</syntaxhighlight>
}</syntaxhighlight>


Line 68: Line 66:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# configuration.nix
# configuration.nix
{ pkgs, ... }:  
{ pkgs, ... }:
 
{
{
   environment.systemPackages = [  
   environment.systemPackages = [  
     pkgs.libheif
     pkgs.libheif
Line 77: Line 75:


   # 'heif.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
   # 'heif.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 91: Line 88:


{
{
   environment.systemPackages = [
   environment.systemPackages = [
     pkgs.gdk-pixbuf
     pkgs.gdk-pixbuf
Line 108: Line 104:
     # Test other formats by adding them above
     # Test other formats by adding them above
   ];
   ];
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 119: Line 114:


<syntaxhighlight lang="nix"># configuration.nix
<syntaxhighlight lang="nix"># configuration.nix
{ pkgs, ... }:  
{ pkgs, ... }:
 
{
{
   environment.systemPackages = [  
   environment.systemPackages = [  
     pkgs.nufraw
     pkgs.nufraw
Line 128: Line 123:


   # 'nufraw.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'  
   # 'nufraw.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'  
}</syntaxhighlight>
}</syntaxhighlight>


Line 138: Line 132:
Output of <code>cat /run/current-system/sw/share/thumbnailers/nufraw.thumbnailer</code>:
Output of <code>cat /run/current-system/sw/share/thumbnailers/nufraw.thumbnailer</code>:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="desktop">
[Thumbnailer Entry]
[Thumbnailer Entry]
TryExec=/nix/store/piss9dl8i5xnfm5yagdffgxycm8lsqpl-nufraw-0.43-3/bin/nufraw-batch
TryExec=/nix/store/piss9dl8i5xnfm5yagdffgxycm8lsqpl-nufraw-0.43-3/bin/nufraw-batch
Line 153: Line 147:


{
{
   environment.systemPackages = [
   environment.systemPackages = [
     pkgs.nufraw
     pkgs.nufraw
Line 171: Line 164:
       # thumbnails generated form the 'embedded jpeg' without the EXIF metadata
       # thumbnails generated form the 'embedded jpeg' without the EXIF metadata
   ];
   ];
}</syntaxhighlight>
}</syntaxhighlight>


Line 202: Line 194:


<syntaxhighlight lang="nix"># configuration.nix
<syntaxhighlight lang="nix"># configuration.nix
{ pkgs, ... }: {
{ pkgs, ... }:
 
{
   environment.systemPackages = [
   environment.systemPackages = [
     (
     (pkgs.writeTextFile {
      pkgs.writeTextFile {
      # This can be anything, it's just the name of the derivation in the nix store
        # This can be anything, it's just the name of the derivation in the nix store
      name = "krita-thumbnailer";
        name = "krita-thumbnailer";
      # This is the important part, the path under which this will be installed
        # This is the important part, the path under which this will be installed
      destination = "/share/thumbnailers/kra.thumbnailer";
        destination = "/share/thumbnailers/kra.thumbnailer";
      # The contents of your thumbnailer, don't forget to specify the full path to executables
        # The contents of your thumbnailer, don't forget to specify the full path to executables
      text = ''
        text = ''
        [Thumbnailer Entry]
          [Thumbnailer Entry]
        Exec=sh -c "${pkgs.unzip}/bin/unzip -p %i preview.png > %o"
          Exec=sh -c "${pkgs.unzip}/bin/unzip -p %i preview.png > %o"
        MimeType=application/x-krita;
          MimeType=application/x-krita;
      '';
        '';
    })
      }
    )
   ];
   ];
}</syntaxhighlight>
}</syntaxhighlight>