WizardKit/.linux_items/include_x/airootfs/etc/skel/.update_conky
2Shirt 61f2ab5777
Avoid replacing .conkyrc if nothing changed
* This prevents conky from reloading every 30 seconds
2019-05-29 20:46:48 -06:00

31 lines
790 B
Bash
Executable file

#!/bin/bash
CONFIG_BASE="${HOME}/.conkyrc_base"
CONFIG_NEW="${HOME}/.conkyrc_new"
CONFIG_REAL="${HOME}/.conkyrc"
IF_LIST=($(ip l \
| egrep '^[0-9]+:\s+(eth|en|wl)' \
| sed -r 's/^[0-9]+:\s+(\w+):.*/\1/' \
| sort))
# Build new config from the default
rm "${CONFIG_NEW}"
cp "${CONFIG_BASE}" "${CONFIG_NEW}"
# Add interfaces to conkyrc_new
for i in "${IF_LIST[@]}"; do
if [[ "${i:0:1}" == "e" ]]; then
sed -i -r "s/#Network/Wired:\${alignr}\${addr $i}\n#Network/" "${CONFIG_NEW}"
else
sed -i -r "s/#Network/Wireless:\${alignr}\${addr $i}\n#Network/" "${CONFIG_NEW}"
fi
done
# Replace config if there were changes
if ! diff -q "${CONFIG_NEW}" "${CONFIG_REAL}" >/dev/null 2>&1; then
rm "${CONFIG_REAL}"
cp "${CONFIG_NEW}" "${CONFIG_REAL}"
fi
# vim: sts=2 sw=2 ts=2