nxgs
This commit is contained in:
51
home-modules/nxgs.nix
Normal file
51
home-modules/nxgs.nix
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
ghostscript
|
||||||
|
(writeShellApplication rec {
|
||||||
|
name = "nxgs";
|
||||||
|
text = /* bash */ ''
|
||||||
|
print_help() {
|
||||||
|
echo "Usage: ${name} {flip <file(s)>|rotate <file(s)>|merge <Out File Name> <files>}"
|
||||||
|
}
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
print_help; exit 1;
|
||||||
|
fi
|
||||||
|
case "$1" in
|
||||||
|
flip)
|
||||||
|
for FILE in "''${@:2}"; do
|
||||||
|
NXGSTEMP=$(mktemp)
|
||||||
|
gs -o "$NXGSTEMP" -sDEVICE=pdfwrite -c "<</Orientation 2>> setpagedevice" -f "$FILE"
|
||||||
|
mv "$NXGSTEMP" "$FILE"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
rotate)
|
||||||
|
for FILE in "''${@:2}"; do
|
||||||
|
NXGSTEMP=$(mktemp)
|
||||||
|
gs -o "$NXGSTEMP" -sDEVICE=pdfwrite -c "<</Orientation 1>> setpagedevice" -f "$FILE"
|
||||||
|
mv "$NXGSTEMP" "$FILE"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
merge)
|
||||||
|
gs -dBATCH -dNOPAUSE -q -sOUTPUTFILE="$3" -sDEVICE=pdfwrite "''${@:3}"
|
||||||
|
;;
|
||||||
|
interactive-merge)
|
||||||
|
echo -n "Enter Name of the merged file without extension: "; read -r MERGED
|
||||||
|
NXGSTEMP=$(mktemp)
|
||||||
|
echo "''${@:2}" | tr " " "\n" > "$NXGSTEMP"
|
||||||
|
$EDITOR "$NXGSTEMP"
|
||||||
|
mapfile -t FILES < "$NXGSTEMP"
|
||||||
|
gs -dBATCH -dNOPAUSE -q -sOUTPUTFILE="''${MERGED}.pdf" -sDEVICE=pdfwrite "''${FILES[@]}"
|
||||||
|
rm "$NXGSTEMP"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown command '$1'"
|
||||||
|
print_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -188,6 +188,9 @@
|
|||||||
{ run = ''zathura "$@"''; desc = "zathura"; orphan = true; }
|
{ run = ''zathura "$@"''; desc = "zathura"; orphan = true; }
|
||||||
{ run = ''xournal "$@"''; desc = "xournal"; orphan = true; }
|
{ run = ''xournal "$@"''; desc = "xournal"; orphan = true; }
|
||||||
{ run = ''firefox "$@"''; desc = "firefox"; }
|
{ run = ''firefox "$@"''; desc = "firefox"; }
|
||||||
|
{ run = ''nxgs flip "$@"''; desc = "nxgs flip"; }
|
||||||
|
{ run = ''nxgs rotate "$@"''; desc = "nxgs rotate"; }
|
||||||
|
{ run = ''nxgs interactive-merge "$@"''; block = true; desc = "nxgs merge"; }
|
||||||
];
|
];
|
||||||
"browser" = [
|
"browser" = [
|
||||||
{ run = ''firefox "$@"''; desc = "firefox"; }
|
{ run = ''firefox "$@"''; desc = "firefox"; }
|
||||||
|
|||||||
2
home.nix
2
home.nix
@@ -32,6 +32,7 @@
|
|||||||
./home-modules/nixd.nix
|
./home-modules/nixd.nix
|
||||||
./home-modules/nvidia.nix
|
./home-modules/nvidia.nix
|
||||||
./home-modules/nx2site.nix
|
./home-modules/nx2site.nix
|
||||||
|
./home-modules/nxgs.nix
|
||||||
# ./home-modules/nx-gcal-event.nix
|
# ./home-modules/nx-gcal-event.nix
|
||||||
./home-modules/obs.nix
|
./home-modules/obs.nix
|
||||||
./home-modules/office.nix
|
./home-modules/office.nix
|
||||||
@@ -91,6 +92,7 @@
|
|||||||
cmake
|
cmake
|
||||||
|
|
||||||
speedtest-go
|
speedtest-go
|
||||||
|
imagemagick
|
||||||
|
|
||||||
glib
|
glib
|
||||||
gsettings-desktop-schemas
|
gsettings-desktop-schemas
|
||||||
|
|||||||
Reference in New Issue
Block a user