about summary refs log tree commit diff
path: root/pkgs/applications/window-managers/i3/lock-fancy.nix
blob: a66e52bc40b0d5e28ca28c55e201f84bfd43b9b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ coreutils
, fetchFromGitHub
, fontconfig
, gawk
, getopt
, i3lock-color
, imagemagick
, installShellFiles
, lib
, makeWrapper
, scrot
, stdenv

, screenshotCommand ? ""
}:

stdenv.mkDerivation {
  pname = "i3lock-fancy";
  version = "unstable-2023-04-28";

  src = fetchFromGitHub {
    owner = "meskarune";
    repo = "i3lock-fancy";
    rev = "55f5c30071403faf5ae4363a54b6d1f63876d5ce";
    hash = "sha256-ISymKlxLE4/ChDiyjnavFx4T5hEVI62cCxYLWrWiHrg=";
  };

  nativeBuildInputs = [
    makeWrapper
    installShellFiles
  ];

  postPatch = ''
    sed -i i3lock-fancy \
      -e 's|icon="/usr/share/i3lock-fancy/icons/lockdark.png"|icon="'$out'/share/i3lock-fancy/icons/lockdark.png"|' \
      -e 's|icon="/usr/share/i3lock-fancy/icons/lock.png"|icon="'$out'/share/i3lock-fancy/icons/lock.png"|'
    rm Makefile
  '' + lib.optionalString (screenshotCommand != "") ''
    sed -i i3lock-fancy \
      -e "s|shot=(import -silent -window root)|shot=(${screenshotCommand})|";
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin $out/share/i3lock-fancy/icons
    cp i3lock-fancy $out/bin/i3lock-fancy
    ln -s $out/bin/i3lock-fancy $out/bin/i3lock
    cp icons/lock*.png $out/share/i3lock-fancy/icons
    installManPage doc/i3lock-fancy.1

    runHook postInstall
  '';

  postInstall = ''
    wrapProgram $out/bin/i3lock-fancy \
      --prefix PATH : ${lib.makeBinPath [ coreutils fontconfig gawk getopt i3lock-color imagemagick scrot ]}
  '';

  meta = with lib; {
    description = "i3lock is a bash script that takes a screenshot of the desktop, blurs the background and adds a lock icon and text";
    homepage = "https://github.com/meskarune/i3lock-fancy";
    maintainers = [ maintainers.reedrw ];
    mainProgram = "i3lock-fancy";
    license = licenses.mit;
    platforms = platforms.linux;
  };
}