Browse Source

Parallelize non-local processes

patch-fontkeys
Joe Standring 3 years ago
parent
commit
f4dc28b0b5
3 changed files with 20 additions and 13 deletions
  1. +2
    -4
      bar-functions/dwm_networkmanager.sh
  2. +5
    -5
      bar-functions/dwm_weather.sh
  3. +13
    -4
      dwm_bar.sh

+ 2
- 4
bar-functions/dwm_networkmanager.sh View File

@ -15,13 +15,11 @@ dwm_networkmanager () {
PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}')
PUBLIC=$(curl -s https://ipinfo.io/ip)
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then
printf "🌐 %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC"
export __DWM_BAR_NETWORKMANAGER__="${SEP1}🌐 ${CONNAME} ${PRIVATE} ${PUBLIC}${SEP2}"
else
printf "NET %s %s | %s" "$CONNAME" "$PRIVATE" "$PUBLIC"
export __DWM_BAR_NETWORKMANAGER__="${SEP1}NET ${CONNAME} ${PRIVATE} ${PUBLIC}${SEP2}"
fi
printf "%s\n" "$SEP2"
}
dwm_networkmanager

+ 5
- 5
bar-functions/dwm_weather.sh View File

@ -8,15 +8,15 @@
# Change the value of LOCATION to match your city
dwm_weather() {
LOCATION=city
LOCATION=London
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then
printf "%s" "$(curl -s wttr.in/$LOCATION?format=1)"
DATA=$(curl -s wttr.in/$LOCATION?format=1)
export __DWM_BAR_WEATHER__="${SEP1} ${DATA} ${SEP2}"
else
printf "WEA %s" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o ".[0-9].*")"
DATA=$(curl -s wttr.in/$LOCATION?format=1 | grep -o ".[0-9].*")
export __DWM_BAR_WEATHER__="${SEP1} WEA ${DATA} ${SEP2}"
fi
printf "%s\n" "$SEP2"
}
dwm_weather

+ 13
- 4
dwm_bar.sh View File

@ -44,10 +44,20 @@ export SEP2="]"
. "$DIR/bar-functions/dwm_loadavg.sh"
. "$DIR/bar-functions/dwm_currency.sh"
parallelize() {
while true
do
printf "Running parallel processes\n"
dwm_weather &
dwm_networkmanager &
sleep 5
done
}
parallelize &
# Update dwm status bar every second
while true
do
# Append results of each func one by one to a string
dispstr=""
dispstr="$dispstr$(dwm_connman)"
@ -63,9 +73,9 @@ do
dispstr="$dispstr$(dwm_backlight)"
dispstr="$dispstr$(dwm_alsa)"
dispstr="$dispstr$(dwm_pulse)"
dispstr="$dispstr$(dwm_weather)"
dispstr="$dispstr${__DWM_BAR_WEATHER__}"
dispstr="$dispstr$(dwm_vpn)"
dispstr="$dispstr$(dwm_networkmanager)"
dispstr="$dispstr${__DWM_BAR_NETWORKMANAGER__}"
dispstr="$dispstr$(dwm_keyboard)"
dispstr="$dispstr$(dwm_ccurse)"
dispstr="$dispstr$(dwm_date)"
@ -74,5 +84,4 @@ do
xsetroot -name "$dispstr"
sleep 1
done

Loading…
Cancel
Save