Files
rMscreens/changescrn
2022-03-18 19:07:26 -04:00

79 lines
2.6 KiB
Bash

#! /bin/bash
#Backup existing screens: changescrn -b
#Change Screen: changescrn -c [SCREEN] -n [PATH TO NEW SCREEN]
#Restore original screens: changescrn -r [SCREEN] (use option 'all' to restore all screens at once)
#[SCREEN] options: batteryempty | lowbattery | overheating | poweroff | rebooting | recovery | splash | starting | suspended
BACKUP="/opt/usr/share/backupscrns"
SOURCE="/usr/share/remarkable"
while getopts "r: c: n: :b" opt; do
case $opt in
r) #Restores original screen
case $OPTARG in
batteryempty | lowbattery | overheating | poweroff | rebooting | recovery | splash | starting | suspended)
echo "restoring $OPTARG.png..."
cp $BACKUP/$OPTARG.png $SOURCE >&2
echo "Done!"
;;
all)
echo "Restoring all screens..."
cp $BACKUP/*.png $SOURCE
echo "Done!"
;;
*)
echo "Screen Options: batteryempty lowbattery overheating poweroff rebooting recovery splash starting suspended"
exit 1
;;
esac
;;
c) #Specifies which screen to change. Must be used in combination with -n
SCREEN=$OPTARG
case $NEWSCRN in
"") echo "Please specify location of new screen"
echo "Usage: changescrn -c [SCREEN] -n [PATH TO NEW SCREEN]"
;;
esac
;;
n) #Specifies location of new screen. Must be used in combination with -c
NEWSCRN=$OPTARG
case $SCREEN in
batteryempty | lowbattery | overheating | poweroff | rebooting | recovery | splash | starting | suspended)
cp $NEWSCRN $source/$SCREEN.png
;;
*)
echo "You either didn't specify a screen option first or didn't specify a correct screen option"
echo "Usage: changescrn -c [SCREEN] -n [PATH TO NEW SCREEN]"
echo "[SCREEN] options: batteryempty | lowbattery | overheating | poweroff | rebooting | recovery | splash | starting | suspended"
;;
esac
;;
b) #Creates a backup of original screens
mkdir -p $BACKUP
cp $source/*.png $BACKUP/
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires and argument." >&2
echo "Usage: changescrn -c [SCREEN] -n [PATH TO NEW SCREEN]"
exit 1
;;
h)
echo "Change Screen: changescrn -c [SCREEN] -n [PATH TO NEW SCREEN]"
echo "Backup existing screens: changescrn -b"
echo "Restore original screens: changescrn -r [SCREEN] (use option 'all' to restore all screens at once)"
echo "[SCREEN] options: batteryempty | lowbattery | overheating | poweroff | rebooting | recovery | splash | starting | suspended"
exit 1
;;
esac
done