~chimo/dotfiles

777628357a7a0e6c7f8b77e857d55523808e28c4 — chimo 2 months ago 221d4e8
.local/bin: imv, pinta, zathura use file redirection.

Instead of copying files around.
3 files changed, 5 insertions(+), 64 deletions(-)

M .local/bin/libs/imv.sh
M .local/bin/libs/pinta.sh
M .local/bin/libs/zathura.sh
M .local/bin/libs/imv.sh => .local/bin/libs/imv.sh +2 -22
@@ 1,4 1,4 @@
#!/bin/sh -e
#!/bin/sh -eu

file="${1}"



@@ 11,26 11,6 @@ else
    # ex: "foo.sh" to "/home/samsepi0l/foo.sh"
    filepath=$(readlink -f -- "${file}")

    # Grab the resulting directory
    # ex: "/home/samsepi0l/foo.sh" to "/home/samsepi0l"
    filedir=$(dirname -- "${filepath}")

    # Prefix paths with "/tmp" on the container
    # ex: "/tmp/home/samsepi0l/foo.sh"
    remote_prefix="/tmp"
    remote_dir="${remote_prefix}${filedir}"
    remote_path="${remote_prefix}${filepath}"

    # Create remote directory
    incus exec "${container_name}" -- mkdir -p "${remote_dir}"

    # Copy file over
    incus file push -q "${filepath}" "${container_name}${remote_path}"

    # Run
    incus exec "${container_name}" -- sh -c "imv ${remote_path}"

    # Cleanup
    incus exec "${container_name}" -- sh -c "rm -fr ${remote_dir}"
    incus exec "${container_name}" -- sh -c "imv -" < "${filepath}"
fi


M .local/bin/libs/pinta.sh => .local/bin/libs/pinta.sh +1 -20
@@ 11,26 11,7 @@ else
    # ex: "foo.sh" to "/home/samsepi0l/foo.sh"
    filepath=$(readlink -f -- "${file}")

    # Grab the resulting directory
    # ex: "/home/samsepi0l/foo.sh" to "/home/samsepi0l"
    filedir=$(dirname -- "${filepath}")

    # Prefix paths with "/tmp" on the container
    # ex: "/tmp/home/samsepi0l/foo.sh"
    remote_prefix="/tmp"
    remote_dir="${remote_prefix}${filedir}"
    remote_path="${remote_prefix}${filepath}"

    # Create remote directory
    incus exec "${container_name}" -- mkdir -p "${remote_dir}"

    # Copy file over
    incus file push -q "${filepath}" "${container_name}${remote_path}"

    # Run
    incus exec "${container_name}" -- sh -c "pinta ${remote_path}"

    # Cleanup
    incus exec "${container_name}" -- sh -c "rm -fr ${remote_dir}"
    incus exec "${container_name}" -- sh -c "pinta -" < "${filepath}"
fi


M .local/bin/libs/zathura.sh => .local/bin/libs/zathura.sh +2 -22
@@ 1,4 1,4 @@
#!/bin/sh -e
#!/bin/sh -eu

file="${1}"



@@ 11,26 11,6 @@ else
    # ex: "foo.sh" to "/home/samsepi0l/foo.sh"
    filepath=$(readlink -f -- "${file}")

    # Grab the resulting directory
    # ex: "/home/samsepi0l/foo.sh" to "/home/samsepi0l"
    filedir=$(dirname -- "${filepath}")

    # Prefix paths with "/tmp" on the container
    # ex: "/tmp/home/samsepi0l/foo.sh"
    remote_prefix="/tmp"
    remote_dir="${remote_prefix}${filedir}"
    remote_path="${remote_prefix}${filepath}"

    # Create remote directory
    incus exec "${container_name}" -- mkdir -p "${remote_dir}"

    # Copy file over
    incus file push -q "${filepath}" "${container_name}${remote_path}"

    # Run
    incus exec "${container_name}" -- sh -c "zathura ${remote_path}"

    # Cleanup
    incus exec "${container_name}" -- sh -c "rm -fr ${remote_dir}"
    incus exec "${container_name}" -- sh -c "zathura -" < "${filepath}"
fi