stockholm/krebs/5pkgs/simple/pager.nix

41 lines
1.0 KiB
Nix
Raw Normal View History

2022-04-05 20:16:29 +00:00
{ pkgs }:
2023-02-07 13:34:51 +00:00
pkgs.symlinkJoin {
name = "pager-wrapper";
paths = [
(pkgs.writeDashBin "pager" ''
# usage: pager {view,shift,shiftview}
#
# Environment variables
#
# PAGER_NAME (default: Pager)
# The environment variables specifies the application name under
# which resources are to be obtained. PAGER_NAME should not contain
# “.” or “*” characters.
#
set -efu
2022-04-05 20:16:29 +00:00
2023-02-07 13:34:51 +00:00
pidfile=$XDG_RUNTIME_DIR/pager.lock
name=''${PAGER_NAME-Pager}
2022-04-05 20:16:29 +00:00
2023-02-07 13:34:51 +00:00
if test -e "$pidfile" &&
${pkgs.procps}/bin/pgrep --pidfile="$pidfile" >/dev/null
then
${pkgs.procps}/bin/pkill --pidfile="$pidfile"
${pkgs.coreutils}/bin/rm "$pidfile"
exit
fi
2022-04-05 20:16:29 +00:00
2023-02-07 13:34:51 +00:00
echo $$ > "$pidfile"
2022-04-05 20:16:29 +00:00
2023-02-07 13:34:51 +00:00
exec ${pkgs.xterm}/bin/xterm \
-name "$name" \
-ti vt340 \
2023-02-07 13:35:01 +00:00
-xrm '*geometry: 32x10' \
-xrm '*internalBorder: 2' \
-e ${pkgs.haskellPackages.desktop-pager}/bin/pager "$@"
2023-02-07 13:34:51 +00:00
'')
pkgs.haskellPackages.pager
];
}