From afac997fa711e7bcc0d5d83334618bfd74b3ed26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Mon, 25 May 2026 22:15:50 +0200 Subject: [PATCH] Add script for managing Kindle files. --- kindle-cmd | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 kindle-cmd diff --git a/kindle-cmd b/kindle-cmd new file mode 100755 index 0000000..896cff6 --- /dev/null +++ b/kindle-cmd @@ -0,0 +1,67 @@ +#!/bin/bash +set -euo pipefail + +PROG_NAME="kindle-cmd" + +print_usage() { + echo "$PROG_NAME " +} + +print_help() { + print_usage + + echo -e "\nCOMMANDS:" + echo -e "\tmount Mount the device" + echo -e "\tumount Unmount the device" + echo -e "\tls List files on device" + echo -e "\tadd Add file to device" + echo -e "\trm Remove file from device" + echo -e "\thelp Show this help information" +} + +if [ $# -lt 1 ] +then + >&2 echo "No commands given. Use 'help' for information." + print_usage + exit 1 +fi + +COMMAND="$1" +shift + +case "$COMMAND" in + "mount") + gio mount "mtp://Amazon_Kindle_G093KM075467019V/" + ;; + "umount") + gio mount -u "mtp://Amazon_Kindle_G093KM075467019V/" + ;; + "ls") + gio list "mtp://Amazon_Kindle_G093KM075467019V/Internal Storage/documents" | grep -v ".sdr" + ;; + "add") + if [ $# -ne 1 ] + then + >&2 echo "Wrong number of arguments. Use 'help' for information." + exit 1 + fi + FILE="$1" + gio copy "$FILE" "mtp://Amazon_Kindle_G093KM075467019V/Internal Storage/documents/" + ;; + "rm") + if [ $# -ne 1 ] + then + >&2 echo "Wrong number of arguments. Use 'help' for information." + exit 1 + fi + FILE="$1" + gio remove "mtp://Amazon_Kindle_G093KM075467019V/Internal Storage/documents/$FILE" + ;; + "help") + print_help + ;; + *) + >&2 echo "Unknown command '$COMMAND'. Use 'help' for information." + exit 1 + ;; +esac