pi-build/conky/setconky

71 wiersze
2.1 KiB
Bash

#!/bin/bash
#set conky display size &/or update call sign
#20200123 km4ack
#20200514 edit km4ack
MYPATH=$HOME/pi-build/conky
TEMPFILE=/run/user/1000/conky.tmp
LOGO=$MYPATH/conky-logo.png
CALL=$(cat ~/.conkyrc | grep "{color Yellow}" | sed s'/.*{alignc}//' | head -1)
INFO=$(yad --form --width=420 --text-align=center --center --title="Preferences" \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Conky Preferences</b>\r\rThis only changes the call sign in conky." \
--field="Call Sign" "$CALL" \
--field="Conky Size":CB "conky-small|conky-medium|conky-large|conky-7inch" \
--field="C or F":CB "C|F" \
--button="Exit":1 \
--button="Continue":2)
BUT=$?
if [ $BUT = 252 ] || [ $BUT = 1 ]; then
exit
fi
CALL=$(echo $INFO | awk -F "|" '{ print $1 }')
CALL=${CALL^^}
CS=$(echo $INFO | awk -F "|" '{ print $2 }')
TEMP=$(echo $INFO | awk -F "|" '{ print $3 }')
cp $MYPATH/$CS $TEMPFILE
sed -i "s/N0CALL/$CALL/" $TEMPFILE
if [ "$TEMP" = 'C' ] && [ "$CS" = 'conky-large' ]; then
#delete F line
echo
sed -i '/vcgencmd/d' $TEMPFILE
#add cel line
sed -i '/#TEMP/a \
${font Arial:bold:size=14}${color White}Temp: $alignr ${exec /opt/vc/bin/vcgencmd measure_temp | cut -c6-9} C' $TEMPFILE
elif [ "$TEMP" = 'C' ] && [ "$CS" = 'conky-medium' ]; then
#delete F line
echo
sed -i '/vcgencmd/d' $TEMPFILE
#add cel line
sed -i '/#TEMP/a \
${font Arial:bold:size=10}${color White}Temp: $alignr ${exec /opt/vc/bin/vcgencmd measure_temp | cut -c6-9} C' $TEMPFILE
elif [ "$TEMP" = 'C' ] && [ "$CS" = 'conky-small' ]; then
#delete F line
echo
elif [ "$TEMP" = 'C' ] && [ "$CS" = 'conky-7inch' ]; then
#delete F line
echo
sed -i '/vcgencmd/d' $TEMPFILE
#add cel line
sed -i '/#TEMP/a \
${font Arial:bold:size=08}${color White}Temp: $alignr ${exec /opt/vc/bin/vcgencmd measure_temp | cut -c6-9} C' $TEMPFILE
fi
cp $TEMPFILE $HOME/.conkyrc
sudo killall conky > /dev/null 2>&1
conky > /dev/null 2>&1
yad --form --width=420 --text-align=center --center --title="Preferences" \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>Conky Preferences</b>\r\rConky is being restarted" \
--button=gtk-ok