Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Parallelize non-local processes
Browse files Browse the repository at this point in the history
  • Loading branch information
hollystandring committed Jan 27, 2021
1 parent 38bf8a3 commit f4dc28b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
6 changes: 2 additions & 4 deletions bar-functions/dwm_networkmanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions bar-functions/dwm_weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 13 additions & 4 deletions dwm_bar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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)"
Expand All @@ -74,5 +84,4 @@ do

xsetroot -name "$dispstr"
sleep 1

done

0 comments on commit f4dc28b

Please sign in to comment.