Compare commits

...

16 Commits

Author SHA1 Message Date
appeasementPolitik
f59ebe88a7
Merge 1500ec504e44c3b2a3367c6bb54c1be865f7416e into b8cd0ab4953d053fef09c48ba04f2fbb2df57aa4 2023-10-03 21:24:42 +00:00
appeasementPolitik
1500ec504e
Use actual locks instead of pgrep 2023-10-03 21:23:15 +00:00
appeasementPolitik
b5317fdaf2
Merge branch 'master' into async 2023-10-03 20:40:48 +00:00
sban
b8cd0ab495
Timeout added to forecast module, ncmpcpp now tracks player state (#1359)
* Added timeout to getforecast to prevent status bar breakage.

A 2 second timeout is used in the case that wttr.in is inaccessible when dwm is started; as otherwise it tries to curl wttr.in indefinitely, not allowing other status bar modules to be loaded.

* Update music status bar module on player state change
2023-09-05 07:51:05 +00:00
Hylke Hellinga
c550a7c6e5
Fixed Booksplit for termux (#1358)
Co-authored-by: Simbaclaws <h.hellinga@inner-join.nl>
2023-09-03 07:20:13 +00:00
appeasementPolitik
92d3560888
Robustness not needed anymore because of curl's --output, no more empty files 2023-08-18 21:21:44 +00:00
appeasementPolitik
b0dbb1d1f6
Also change modification time 2023-08-18 14:49:50 +00:00
appeasementPolitik
36d40adb8d
Only redirect non-empty output: for when services are down 2023-08-16 13:32:44 +00:00
appeasementPolitik
de863bf0f0
Make the retry logic better + other changes 2023-08-16 10:56:33 +00:00
appeasementPolitik
b7dc644e1a
Re-add fail-early to sb-price 2023-04-23 15:02:32 +00:00
appeasementPolitik
fead6d66ce
Merge branch 'master' into async 2023-04-20 17:16:20 +00:00
appeasementPolitik
b1ddd9548e
Merge latest commits and add retries 2023-04-20 17:11:58 +00:00
appeasementPolitik
e3a5d38200
Become synchronous on manual run and make dwmblocks signal code optional 2023-04-05 08:09:57 +00:00
appeasementPolitik
0e237592d7
Allow dwmblocks signal numbers to be changed 2023-04-04 07:25:19 +00:00
appeasementPolitik
060c093deb
Merge branch 'LukeSmithxyz:master' into async 2023-04-04 07:19:35 +00:00
appeasementPolitik
d1054d839e
Make dwmblocks modules async 2023-04-02 11:53:46 +00:00
6 changed files with 37 additions and 18 deletions

View File

@ -31,3 +31,4 @@ progressbar_elapsed_color = blue:b
statusbar_color = red
statusbar_time_color = cyan:b
execute_on_song_change="pkill -RTMIN+11 dwmblocks"
execute_on_player_state_change="pkill -RTMIN+11 dwmblocks"

View File

@ -12,7 +12,7 @@ inputaudio="$1"
ext="${1##*.}"
# Get a safe file name from the book.
escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
escbook="$(echo "$booktitle" | iconv -c -f UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
! mkdir -p "$escbook" &&
echo "Do you have write access in this directory?" &&
@ -31,7 +31,7 @@ do
cmd="$cmd -metadata artist=\"$author\" -metadata title=\"$title\" -metadata album=\"$booktitle\" -metadata year=\"$year\" -metadata track=\"$track\" -metadata total=\"$total\" -ss \"$start\" -to \"$end\" -vn -c:a copy \"$file\" "
fi
title="$(echo "$x" | cut -d' ' -f2-)"
esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
esctitle="$(echo "$title" | iconv -c -f UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
track="$((track+1))"
start="$end"
done < "$2"

View File

@ -7,11 +7,11 @@ url="${WTTRURL:-wttr.in}"
weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
# Get a weather report from 'wttr.in' and save it locally.
getforecast() { curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; }
getforecast() { curl -sf "$url/$LOCATION" --output "$weatherreport" && touch "$weatherreport"; }
# Forecast should be updated only once a day.
checkforecast() {
[ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
[ "$(stat -c %y "$weatherreport" 2>/dev/null |
cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
}
@ -48,6 +48,9 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
checkforecast || getforecast
showweather
checkforecast && showweather ||
( flock -n 9 &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
getforecast; do sleep 60; done &&
pkill -RTMIN+"${1:-5}" "${STATUSBAR:-dwmblocks}" ) &
echo ) 9>/tmp/sb-forecast.lock

View File

@ -5,10 +5,15 @@
#
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
set -e
ifinstalled "geoip" || exit 1
ifinstalled "geoip"
addr="$(geoiplookup "$(curl -sfm 1 ifconfig.me 2>/dev/null)")"
ipfile="$XDG_RUNTIME_DIR/iplocate"
addr=$(cat "$ipfile" 2>/dev/null) && addr=$(geoiplookup "$addr" 2>/dev/null) && rm "$ipfile" ||
( flock -n 9 &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
curl -sf api.ipify.org --output "$ipfile"; do sleep 60; done &&
pkill -RTMIN+"${1:-27}" "${STATUSBAR:-dwmblocks}" ) &
echo; exit ) 9>/tmp/sb-iplocate.lock
name="${addr##*, }"
flag="$(grep "flag: $name" "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji")"
flag="${flag%% *}"

View File

@ -4,8 +4,12 @@
moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase"
[ -s "$moonfile" ] && [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
{ curl -sf "wttr.in/?format=%m" > "$moonfile" || exit 1 ;}
[ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
( flock -n 9 &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
curl -sf "wttr.in/?format=%m" --output "$moonfile" && touch "$moonfile"; do sleep 60; done &&
pkill -RTMIN+"${1:-17}" "${STATUSBAR:-dwmblocks}" ) &
echo; exit ) 9>/tmp/sb-moonphase.lock
icon="$(cat "$moonfile")"

View File

@ -28,8 +28,7 @@ filestat="$(stat -c %x "$pricefile" 2>/dev/null)"
[ -d "$dir" ] || mkdir -p "$dir"
updateprice() { curl -sf -m 1 --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" ||
rm -f "$pricefile" "$chartfile" ;}
updateprice() { curl -sf --fail-early $denom.$url/{1$target,$target$interval} --output "$pricefile" --output "$chartfile" && touch "$pricefile" "$chartfile"; }
[ "${filestat%% *}" != "$(date '+%Y-%m-%d')" ] &&
updateme="1"
@ -48,9 +47,16 @@ case $BLOCK_BUTTON in
esac
[ -n "$updateme" ] &&
updateprice "$target" &&
[ -n "$showupdate" ] &&
notify-send "$icon Update complete." "$name price is now
\$$(cat "$pricefile")"
if [ -n "$showupdate" ]; then
updateprice && notify-send "$icon Update complete." "$name price is now \$$(cat "$pricefile")"
else
[ -n "$4" ] &&
( flock -n 9 &&
( until { [ "$(cat /sys/class/net/w*/operstate)" = 'up' ] || [ "$(cat /sys/class/net/e*/operstate)" = 'up' ]; } &&
updateprice; do sleep 60; done &&
pkill -RTMIN+"$4" "${STATUSBAR:-dwmblocks}" ) &
echo; exit ) 9>/tmp/sb-price.lock ||
updateprice
fi
[ -f "$pricefile" ] && printf "%s%s%0.2f" "$icon" "$symb" "$(cat "$pricefile")"