#!/bin/bash

CRYFS_DIR="/home/greg/.cryfs/"
CRYFS_MOUNT_DIR="/home/greg/cryfs/"

# Retrieve volume name with zenity
VOLUME=$(zenity --entry --title="Unlock Cryfs" --text="Volume:")

# Retrieve password with zenity
PASSWORD=$(zenity --password --title="Unlock Cryfs" --text="Volume password:")

# Unlock the volume
cryfs "$CRYFS_DIR$VOLUME" $CRYFS_MOUNT_DIR$VOLUME <<< $PASSWORD

# If the unlock was successful, show a success message
if [ $? -eq 0 ]; then
  notify-send "Unlock Cryfs" "Volume $VOLUME unlocked successfully"
  exit 0
else
  notify-send "Unlock Cryfs" "Failed to unlock volume $VOLUME"
  exit 1
fi
