From 2fd868ee9c2ac35f6cd3a77ef158b8d0ab4a5103 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 27 May 2024 13:48:38 +0100 Subject: [PATCH] Write basic loop for inserter program --- sevenkeys/storagemanager | 48 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/sevenkeys/storagemanager b/sevenkeys/storagemanager index 454a434..573390c 100755 --- a/sevenkeys/storagemanager +++ b/sevenkeys/storagemanager @@ -1,5 +1,51 @@ #!/bin/bash +printLastInsertedCard() { + printf "Last inserted card: " + + if test -n "$1"; then + printf "$1" + else + printf "None" + fi + + printf "\n" +} + +searchForCard() { + # TODO: Add keybinding to show card image with feh + ./printinglist | fzf +} + +declare g_lastInsertedCardId +declare g_lastInsertedCardName + while true; do - printf "Hello, world\n" + clear + + printLastInsertedCard "$g_lastInsertedCardName" + + printf "search? (y/N)" + read response + if [[ "$response" == "y" ]]; then + selection="$(searchForCard)" + case "$?" in + 0) + # Insert the card + printf "$selection\n" + # TODO: set last inserted card name and id + ;; + 1) + # Print "no match" error + ;; + 2) + # Print error + ;; + 130) + # User cancelled search + ;; + esac + else + break + fi done