outsource interaction part to separate file; better name scheming; update default status values; small improvements
This commit is contained in:
66
status-interaction.sh
Executable file
66
status-interaction.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
CURDIR=$(dirname "$(readlink -f "$0")")
|
||||
source "$CURDIR"/shared-functions.so
|
||||
|
||||
# MAIL QUEUE ACTIONS
|
||||
function send_mailqueue { # send queued mails
|
||||
msmtp-listqueue.sh
|
||||
read -p "Send these queued mails? [Y/n]: " YN
|
||||
if [[ $YN =~ ^(Y|y|)$ ]]; then
|
||||
msmtp-runqueue.sh
|
||||
else
|
||||
echo "Not sending emails"
|
||||
fi
|
||||
}
|
||||
function list_mailqueue { # list emails in queue only
|
||||
msmtp-listqueue.sh
|
||||
}
|
||||
|
||||
# CHANGE ONLINE STATUS
|
||||
function switch_conn {
|
||||
echo "Current connection status: $var_conn"
|
||||
read -p "Switch connection status? [Y/n]: " YN
|
||||
if [[ $YN =~ ^(Y|y|)$ ]]; then
|
||||
if [ "$var_conn" == "off" ]; then
|
||||
var_conn="on"
|
||||
echo "Connection status switched to \"on\""
|
||||
else
|
||||
var_conn="off"
|
||||
echo "Connection status switched to \"off\""
|
||||
fi
|
||||
else
|
||||
echo "Connection status not changed."
|
||||
fi
|
||||
}
|
||||
|
||||
# OPTION SCREEN
|
||||
function exec {
|
||||
ACTIONS=("send mails in queue" "list mails in queue" "switch connection status [$var_conn]" "quit")
|
||||
PS3="Select action: "
|
||||
|
||||
select action in "${ACTIONS[@]}"
|
||||
do
|
||||
echo # empty line after selection
|
||||
case $REPLY in # $REPLY takes the numbers which is nice
|
||||
1) # Show queue; ask for confirmation; if yes, send emails
|
||||
send_mailqueue
|
||||
break ;;
|
||||
2) # Show queue
|
||||
list_mailqueue
|
||||
break ;;
|
||||
3) # Switch online status
|
||||
switch_conn
|
||||
break ;;
|
||||
4|"q") # exit silently, one can also press "q" instead of the number
|
||||
exit 0
|
||||
break ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
while :; do # endless loop
|
||||
exec # interaction screen
|
||||
wtmp; source "$TMP" # write changes back and load them
|
||||
echo # empty line
|
||||
done
|
||||
Reference in New Issue
Block a user