Browse Source

modifying wtmp function to allow only updating certain variables to avoid overlaps, especially with online/offline status during a longer runtime of status-misc.sh

master
mxmehl 5 years ago
parent
commit
1984a70b99
  1. 24
      shared-functions.so
  2. 2
      status-ip.sh
  3. 3
      status-misc.sh

24
shared-functions.so

@ -12,10 +12,22 @@ source "$TMP"
# WRITE TMP
function wtmp {
> $TMP
echo "var_mailqueue_runs=$var_mailqueue_runs" >> $TMP
echo "var_conn=$var_conn" >> $TMP
echo "var_ip4=$var_ip4" >> $TMP
echo "var_ip6=$var_ip6" >> $TMP
echo "var_vpn=$var_vpn" >> $TMP
if [ "$1" = "" ]; then # no argument given
> $TMP
echo "var_mailqueue_runs=$var_mailqueue_runs" >> $TMP
echo "var_conn=$var_conn" >> $TMP
echo "var_ip4=$var_ip4" >> $TMP
echo "var_ip6=$var_ip6" >> $TMP
echo "var_vpn=$var_vpn" >> $TMP
echo "var_ns=$var_ns" >> $TMP
else # certain variables given, so only update these variables' values (avoids overlaps, esp. if status-misc.sh needs longer to be executed)
NO=$#
for ((i = 1; i <= $NO; i++)); do
VAR_NAME=${!i} # variable name
VAR_VAL=${!VAR_NAME} # value of the variable's name
sed -Ei "s/^$VAR_NAME=.*/$VAR_NAME=$VAR_VAL/" $TMP
done
fi
}

2
status-ip.sh

@ -41,4 +41,4 @@ else
echo "<tool>Offline status is set. Turn on to enable checks</tool>"
fi
wtmp # Write changes back
wtmp var_ip4 var_ip6 var_vpn # Write changes back

3
status-misc.sh

@ -52,6 +52,7 @@ function check_svn {
TOOL="$TOOL;svn=$SVN_REV"
}
# OUTPUT INFO ON STATUSBAR
check_mailqueue
check_svn
@ -64,4 +65,4 @@ echo "<tool>$TOOL</tool>"
echo "<img>/usr/share/icons/gnome/16x16/actions/format-justify-fill.png</img>"
echo "<click>xfce4-terminal -x $CURDIR/status-interaction.sh &</click>"
wtmp
wtmp var_mailqueue_runs # write updated values back to status file

Loading…
Cancel
Save