diff options
author | Mx Kookie <kookie@spacekookie.de> | 2020-12-22 20:38:50 +0100 |
---|---|---|
committer | Mx Kookie <kookie@spacekookie.de> | 2020-12-22 20:43:44 +0100 |
commit | dceec84b009fb7cf9f62d0131497a6db53d38825 (patch) | |
tree | 6d70cf3dbe7b8249cdd664fc65ac3bcb466ef484 /infra/libkookie/modules/workstation/ui/i3/core/tools | |
parent | 76f3d25f0c193a4e837632bd3d341ef7386c4193 (diff) |
libkookie: i3: adding compton and various improvements
Diffstat (limited to 'infra/libkookie/modules/workstation/ui/i3/core/tools')
-rw-r--r-- | infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix | 1 | ||||
-rw-r--r-- | infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix | 47 |
2 files changed, 48 insertions, 0 deletions
diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix index 40ce022c6144..1196dc28c46c 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix @@ -5,4 +5,5 @@ libkookie-i3-switch = (import ./i3-switch.nix args); libkookie-i3-rename = (import ./i3-rename.nix args); libkookie-i3-scrcap = (import ./i3-scrcap.nix args); + libkookie-i3-locker = (import ./i3-locker.nix args); } diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix new file mode 100644 index 000000000000..749d41e4eb39 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix @@ -0,0 +1,47 @@ +/** A utility script to lock the screen + * + * This tool relies on i3lock, ./lock.png, fortune, and imagemagic to + * create a picture to fill all available screens + */ + +{ pkgs, ... }: +with pkgs; +let + lockIcon = "${i3lock-fancy}/share/i3lock-fancy/icons/lock.png"; + i3lock = "${i3lock}/bin/i3lock"; + mktemp = "${coreutils}/bin/mktemp"; + rm = "${coreutils}/bin/rm"; + fortune = "${fortune}/bin/fortune"; + xrandr = "${xrandr}/bin/xrandr"; + convert = "${imagemagick}/bin/convert"; +in +writeShellScript "libkookie-i3locker" '' + + # Create a temp directory to work in + TMPDIR=$(${mktemp} -d) + BGIMAGE=$TMPDIR/lockbg.png + FORTUNE=$(${fortune} | sed -e 's/\t/ /g') + TMPRES=$(${xrandr} | grep \* | cut -d' ' -f4 | sed ':a;N;$!ba;s/\n/ /g') + RESOLUTION=$(`echo $TMP_RES | sed 's/ /\n/g'`) + + # Create a base image + ${convert} -size 0x0 canvas:black $BGIMAGE + + for mon in "${RESOLUTION[@]}" + do + echo "Running for monitor $mon" + TMPLOCK="$TMPDIR/tmplock.png" + ${convert} -size "$mon" canvas:black -font Inconsolata -pointsize 18 \ + -fill white -gravity center -annotate +0+250 "$FORTUNE" \ + "${lockIcon}" -gravity center -composite "$TMPLOCK" + + ${convert} "$IMAGE" "$TMPLOCK" +append "$IMAGE" + ${rm} "TMPLOCK" + done + + # Lock the screen + ${i3lock} -i "$IMAGE" + + # Remove all the temp images + ${rm} -rf $TMPDIR +'' |