69 lines
1.9 KiB
Bash
Executable File
69 lines
1.9 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
FXDE_DIR=/home/midfavila/.config/fxde
|
|
|
|
tme() #Display current time in 24h notation
|
|
{
|
|
date|sed -ne 's/ */ /gp'|cut -d ' ' -f4|sed -ne 's/\([0-9][0-9]\):\([0-9][0-9]\).*/\1\2/p'
|
|
}
|
|
|
|
pwr() #Display current battery capacity and whether we're discharging or not.
|
|
{
|
|
if [ "$(cat /sys/class/power_supply/BAT1/status)" = "Discharging" ]
|
|
then printf "%s%%--" "$(cat /sys/class/power_supply/BAT1/capacity)"
|
|
else printf "%s%%++" "$(cat /sys/class/power_supply/BAT1/capacity)"
|
|
fi
|
|
}
|
|
|
|
ip() #Acquire the IP of our current connection. This is awful. I'm so sorry.
|
|
{
|
|
x=$(ifconfig wlp2s0|sed -ne 's/.*addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p')
|
|
if [ "$(route|sed 3!d|cut -b1-7)" != "default" ]
|
|
then printf "ERR"
|
|
elif [ "${x}" ]
|
|
then printf "%s" "${x}"
|
|
else
|
|
printf "N/A"
|
|
fi
|
|
}
|
|
|
|
tmp_helper()
|
|
{
|
|
curl -s http://wttr.in/?format=1|\
|
|
sed -ne 's/.*\(.[0-9][0-9]*.C\)/\1/p' > "${FXDE_DIR}/fxde-core/info/temp"
|
|
touch "${FXDE_DIR}/fxde-core/info/timepiece"
|
|
}
|
|
|
|
tmp() #Acquire ambient temperature from wttr.in every ival seconds
|
|
{
|
|
ival=120 #How often do we check?
|
|
|
|
if [ $(expr % $(expr - "${ival}" $(expr \* $(date|cut -d ':' -f2) 60)) "${ival}" ) ] && \
|
|
[ ! -e "${FXDE_DIR}/fxde-core/info/timepiece" ]
|
|
then printf "UPD"
|
|
tmp_helper
|
|
elif [ -e "${FXDE_DIR}/fxde-core/info/timepiece" ] && \
|
|
[ ! $(expr % $(expr - 120 $(expr \* $(date|cut -d ':' -f2) 60)) 1200) ]
|
|
then rm "${FXDE_DIR}/fxde-core/info/timepiece"
|
|
elif [ -s "${FXDE_DIR}/fxde-core/info/temp" ]
|
|
then cat "${FXDE_DIR}/fxde-core/info/temp"
|
|
else
|
|
printf "COND"
|
|
fi
|
|
|
|
}
|
|
|
|
curdesk()
|
|
{
|
|
x=0
|
|
target=' '
|
|
while [ "$target" != "*" ]
|
|
do
|
|
x=$(expr + 1 $x)
|
|
target=$(lsd|sed "${x}!d"|cut -b1)
|
|
done
|
|
printf "%s" "${x}"
|
|
}
|
|
|
|
while true;do sleep 1; printf "%%{l}[ %s | %%{A:xcalendar:}%s%%{A} | %s | %s | %%{A:rm "${FXDE_DIR}/fxde-core/info/timepiece":}%s%%{A} ]\n" "$(curdesk)" "$(tme)" "$(pwr)" "$(ip)" "$(tmp)";done
|