Regularly update conky config

* This should allow USB adapters to be shown if connected after login
This commit is contained in:
2Shirt 2019-04-11 21:30:53 -07:00
parent c3ebdee5d0
commit 56ca605257
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
5 changed files with 35 additions and 12 deletions

View file

@ -0,0 +1,6 @@
[Unit]
Description=Conky config update service
[Service]
Type=oneshot
ExecStart=%h/.update_conky

View file

@ -0,0 +1,10 @@
[Unit]
Description=Conky config update timer
[Timer]
OnBootSec=5s
OnUnitActiveSec=30s
Unit=update-conky.service
[Install]
WantedBy=timers.target

View file

@ -1,18 +1,24 @@
#!/bin/bash
IF_LIST=($(ip l | egrep '^[0-9]+:\s+(eth|en|wl)' | sed -r 's/^[0-9]+:\s+(\w+):.*/\1/' | sort))
IF_LIST=($(ip l \
| egrep '^[0-9]+:\s+(eth|en|wl)' \
| sed -r 's/^[0-9]+:\s+(\w+):.*/\1/' \
| sort))
# Reset conkyrc to default
rm "${HOME}/.conkyrc"
cp "${HOME}/.conkyrc_base" "${HOME}/.conkyrc"
# Add interfaces to conkyrc
if fgrep '#Network' $HOME/.conkyrc; then
for i in "${IF_LIST[@]}"; do
if [[ "${i:0:1}" == "e" ]]; then
sed -i -r "s/#Network/Wired:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
else
sed -i -r "s/#Network/Wireless:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
fi
done
for i in "${IF_LIST[@]}"; do
if [[ "${i:0:1}" == "e" ]]; then
sed -i -r "s/#Network/Wired:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
else
sed -i -r "s/#Network/Wireless:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
fi
done
# Remove '#Network' line to prevent duplicating lines if this script is re-run
sed -i -r "s/#Network//" $HOME/.conkyrc
fi
# Remove '#Network' line to prevent duplicating lines if this script is re-run
sed -i -r "s/#Network//" $HOME/.conkyrc
# vim: sts=2 sw=2 ts=2