major springcleaning

This commit is contained in:
2023-10-12 15:12:12 +02:00
parent 648a010f64
commit 98b48cb97b
332 changed files with 6708 additions and 10208 deletions

View File

@ -1,11 +0,0 @@
#!/bin/bash
( [ "$(stat -c %y ~/.cache/corona | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] || [ "$1" = "up" ] )&&
curl -s https://corona-stats.online/Switzerland | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" > ~/.cache/corona && notify-send "Corona" "Stats updated"; sleep 5; pkill -RTMIN+15 dwmblocks
increase=$( grep "Switzerland" ~/.cache/corona |
sed "s/\s*//g; s/║//g; s/│/;/g" | awk -F';' '{print $4}' )
[ "$increase" != "" ] && ( grep "Switzerland" ~/.cache/corona |
sed "s/\s*//g; s/║//g; s/│/;/g" |
awk -F';' '{print "😷"$3 " ("$4") 💀"$5 }' ) || ( grep "Switzerland" ~/.cache/corona |
sed "s/\s*//g; s/║//g; s/│/;/g" |
awk -F';' '{print "😷"$3 " 💀"$5 }' )

View File

@ -1,53 +0,0 @@
#!/bin/sh
# Shows the price for desired cryptocurrencies. Module updates automatically
# every calendar day, but can also be updated with a middle click.
# Currencies should be ;-separated:
# human-readable name;urlname;icon
coins="Bitcoin;btc;💰
Etherium;eth;🍸
Basic Attention Token;bat;🦁
LBC;lbc;📚"
# Directory where currency info is stored.
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
getprices() { # The command to get the desired prices
printf "🔃 "; printprices
{ rm -rf "${dir:?}/*"
echo "$coins" | while IFS=';' read -r human web icon; do
val="$(curl -s "rate.sx/1$web")" &&
echo "$icon;$val;$human" > "$dir/$web"
done; [ -d "$dir" ] && touch "$dir"
pkill -RTMIN+13 "${STATUSBAR:-dwmblocks}" ;} &
exit
}
printprices() { # Print/format all prices
for x in "$dir"/*; do
[ -f "$x" ] || break
info="$(cut -d';' -f-2 --output-delimiter=' ' "$x")"
printf "%s $%0.2f " $info
done | sed 's/ $//'
}
[ ! -d "$dir" ] && mkdir -p "$dir" && { getprices; exit ;}
# If currencies haven't been updated today, try to update them.
[ "$(stat -c %x "$HOME/.local/share/crypto-prices" | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] &&
{ ping -q -c 1 1.1.1.1 >/dev/null 2>&1 && getprices || exit ;}
case $BLOCK_BUTTON in
1) uptime="$(date -d "$(stat -c %x "$dir")" '+%D at %T' | sed "s|$(date '+%D')|Today|")"
notify-send "Exact prices in USD" "$(awk -F';' '{print $1, $3 ":\n\t$" $2}' "$dir"/*)
<b>Last updated:</b>
$uptime" ;;
2) getprices ;;
3) notify-send "💸 Crypto-currency module" "\- Left click for exact prices.
- Middle click to update.
- Shows 🔃 if updating prices.
- Manually add/remove currencies to list in the script." ;;
esac
printprices

View File

@ -1,7 +0,0 @@
#!/bin/bash
day=$(date '+%Y%b%d')
logged=$(grep -v Break ~/eth/pomodoros | grep $(date '+%Y%b%d') | grep -Eo "\(.*\)" | paste -sd+ | bc)
temp=$(cat /tmp/pomptemptimes 2>/dev/null)
min=$([ "$logged" != "" ] && ([ "$temp" != "" ] && echo "$logged + $temp" | bc || echo $logged ) || ([ "$temp" != "" ] && echo $temp))
[ -n "$min" ] && printf '🍅%s' "$min"
printf '\n'

View File

@ -1,7 +0,0 @@
#!/bin/bash
day=$(date '+%Y%b%d')
logged=$(grep -v Break ~/bks/pomodoros_freetime | grep $(date '+%Y%b%d') | grep -Eo "\(.*\)" | paste -sd+ | bc)
temp=$(cat /tmp/pomptemptimesft 2>/dev/null)
min=$([ "$logged" != "" ] && ([ "$temp" != "" ] && echo "$logged + $temp" | bc || echo $logged ) || ([ "$temp" != "" ] && echo $temp))
[ -n "$min" ] && printf '📚%s'"$min"
printf '\n'

View File

@ -1,5 +0,0 @@
#!/bin/sh
if pactl list sinks | grep -qE 'device.icon_name = \"audio-(headset|headphones)-bluetooth\"'; then
printf '🎧'
fi
printf '\n'

View File

@ -1,7 +0,0 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) groff -mom ~/.local/share/larbs/readme.mom -Tpdf | zathura - ;;
2) i3 restart ;;
3) pgrep -x dunst >/dev/null && notify-send "❓ Help module" "\- Left click to open LARBS guide.
- Middle click to refresh i3.";;
esac; echo "❓"

View File

@ -1,16 +0,0 @@
#!/bin/sh
# The clickable help menu. Middle click to restart wm.
# If dwm is running, use dwm's readme and restart.
ps ax | grep -q "\sdwm$" &&
READMEFILE=/usr/local/share/dwm/larbs.mom
restartwm() { pkill -HUP dwm ;} ||
restartwm() { i3 restart ;}
case $BLOCK_BUTTON in
1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;;
2) restartwm ;;
3) notify-send "❓ Help module" "\- Left click to open LARBS guide.
- Middle click to refresh window manager.";;
esac; echo "❓"

View File

@ -1,9 +0,0 @@
#!/bin/sh
# Gets your public ip address checks which country you are in and
# displays that information in the statusbar
#
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoiplookup" || exit
addr="$(curl ifconfig.me 2>/dev/null)" || exit
grep "flag: " ~/.config/emoji | grep "$(geoiplookup $addr | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Shows the current moon phase. Requires `pom-perl`.
mnphs=$(pom $1 | grep -o 'New\|Waxing Crescent\|First Quarter\|Waxing Gibbous\|Full\|Waning Gibbous\|Last Quarter\|Waning Crescent' | grep -m1 '.')
prcnt=$(pom $1 | grep -o '[[:digit:]]*%' | grep -o '[[:digit:]]*' )
case "$mnphs" in
"New") icon="🌑" prcnt="0" ;;
"Waxing Crescent") icon="🌒" ;;
"First Quarter") icon="🌓" prcnt="50" ;;
"Waxing Gibbous") icon="🌔" ;;
"Full") icon="🌕" prcnt="100" ;;
"Waning Gibbous") icon="🌖" ;;
"Last Quarter") icon="🌗" prcnt="50" ;;
"Waning Crescent") icon="🌘" ;;
*) echo errorrrr ;;
esac
case $BLOCK_BUTTON in
1) $mnphs ;;
2) $mnphs ;;
3) notify-send " 🌜$(pom)" ;;
esac
echo "$icon" "$prcnt"%

View File

@ -1,9 +0,0 @@
#!/bin/sh
# Whenever the mpd state changes, update the mpd i3 module.
#kill -0 "$(cat /tmp/mpdupdate)" 2>/dev/null && exit || echo $$ > /tmp/mpdupdate
#sleep 5 && while : ; do
#pkill -RTMIN+11 dwmblocks
#mpc idle >/dev/null || exit
#done
pkill -RTMIN+11 dwmblocks

View File

@ -1,12 +0,0 @@
#!/bin/sh
if [ "$( mpc status | grep -c '\[playing\]')" -eq 1 ]; then
full_length="$(mpc status | sed "/^volume:/d" | tac | sed -e "s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/ /g")"
#remove full directory structure if no title present and too long
if [ ${#full_length} -gt 40 ]; then
echo "${full_length##*/}"
else
echo "$full_length"
fi
else
printf '\n'
fi

View File

@ -1,18 +0,0 @@
#!/bin/sh
filter() {
sed "/^volume:/d" | tac | sed -e "s/\\&/&amp;/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' | sed -e "s/$/<\\/span>/g"
}
case $BLOCK_BUTTON in
1) mpc status | filter && setsid "$TERMINAL" -e ncmpcpp & ;; # right click, pause/unpause
2) mpc toggle | filter ;; # right click, pause/unpause
3) mpc status | filter && pgrep -x dunst >/dev/null && notify-send "🎵 Music module" "\- Shows mpd song playing.
- Italic when paused.
- Left click opens ncmpcpp.
- Middle click pauses.
- Scroll changes track.";; # right click, pause/unpause
4) mpc prev | filter ;; # scroll up, previous
5) mpc next | filter ;; # scroll down, next
*) mpc status | filter ;;
esac; exit

View File

@ -1,6 +1,16 @@
#!/bin/sh
#Print the next appointment for the day for statusbar
#or generate notification for upcoming appointment
notify_mins_before=10
calcurse -a | perl -pe 's/([0-9]{2}:[0-9]{2})\n/\1/' | tail -n+2 | perl -pe 's/^\s*-\s*([0-9]{2}:[0-9]{2})\s*->\s*([0-9]{2}:[0-9]{2})\s*(.*?)$/\1\t\2\t\3/' |
while read -r appointment; do
start=$(echo "$appointment" | cut -d'\t' -f1)
end=$(echo "$appointment" | cut -d'\t' -f2)
description=$(echo "$appointment" | cut -d'\t' -f3)
done
diff=$(calcurse --next | sed -n 's/^\s*//; s/\[//;s/\]//p' | cut -f1 -d ' ' | perl -pe 's/0([0-9])/\1/g' )
if [ -n "$diff" ]; then
secs=$(( $(echo "$diff" | cut -f1 -d ':') * 3600 + $(echo "$diff" | cut -f2 -d ':') *60 ))
@ -12,8 +22,11 @@ if [ -n "$diff" ]; then
fi
if [ "$1" = "notif" ]; then
msg="$(printf '%s\n%s' "$(date --date "@$time_appointment" +'%H:%M')" "$appointment")"
check_for_notif "$msg"
notify-send "Appointment coming up" "$msg"
printf "%s\n%s\n" $(date -I) $msg >> /tmp/apts_notif
else
#Fix this ugly thing lmao
midnight=$(( $(date --date "$(date | sed 's/..:..:../23:59:59/; s/ PM//; s/ AM//')" +%s) + 1 ))
if [ $midnight -gt "$time_appointment" ]; then
#only print appointment if dunst-notifications are also shown -> "privacy screen"

View File

@ -12,8 +12,13 @@ esac
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡"
[ -z "${wifiicon+var}" ] && wifiicon="📶"
#[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
printf "%s%s\n" "$wifiicon" "$(cat /sys/class/net/w*/operstate | sed "s/down/❎/;s/up//")"
if [ -d /sys/class/net/e* ]; then
wifiicon=🌐
printf "%s%s\n" "$wifiicon" "$(cat /sys/class/net/e*/operstate | sed "s/down/❎/;s/up//")"
else
[ -z "${wifiicon+var}" ] && wifiicon="📶"
printf "%s%s\n" "$wifiicon" "$(cat /sys/class/net/w*/operstate | sed "s/down/❎/;s/up//")"
fi

16
.local/bin/statusbar/sb-music Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
if [ "$( mpc status | grep -c '\[playing\]')" -eq 1 ]; then
if [ ! -f /tmp/nodunst ]; then
full_length="$(mpc status | sed "/^volume:/d" | tac | sed -e "s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/ /g")"
#remove full directory structure if no title present and too long
if [ ${#full_length} -gt 40 ]; then
echo "${full_length##*/}"
else
echo "$full_length"
fi
else
printf '\n'
fi
else
printf '\n'
fi

52
.local/bin/statusbar/sb-volume Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh
# Prints the current volume or 🔇 if muted. Uses PulseAudio by default,
# uncomment the ALSA lines if you remove PulseAudio.
case $BLOCK_BUTTON in
# 1) setsid "$TERMINAL" -e alsamixer & ;;
# 2) amixer sset Master toggle ;;
# 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;;
# 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;;
1) setsid "$TERMINAL" -e pulsemixer & ;;
2) pamixer -t ;;
4) pamixer --allow-boost -i 1 ;;
5) pamixer --allow-boost -d 1 ;;
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute.
- Scroll to change."
esac
#volstat="$(pactl list sinks)"
## volstat="$(amixer get Master)" # ALSA only equivalent.
#
## Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
#if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
# echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
#else
# echo "$volstat" | grep -A10 "State: RUNNING" | grep -q "Mute: yes" && printf "🔇\\n" && exit
#fi
## echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA
#
## Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
#if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
# vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
#else
# vol="$(echo "$volstat" | grep -A10 "State: RUNNING" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
#fi
# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA
vol="$(pamixer --get-volume-human | tr -d '%')"
if echo "$vol" | grep -q muted; then
printf '🔇\n'
else
if [ "$vol" -gt "70" ]; then
icon="🔊"
elif [ "$vol" -lt "30" ]; then
icon="🔈"
else
icon="🔉"
fi
printf "%s%s%%\\n" "$icon" "$vol"
fi

View File

@ -1,32 +0,0 @@
#!/bin/sh
echo "
____ _ _ _
/ ___|| |_ __ _| |_ _ _ ___| |__ __ _ _ __
\___ \| __/ _\` | __| | | / __| '_ \ / _\` | '__|
___) | || (_| | |_| |_| \__ \ |_) | (_| | |
|____/ \__\__,_|\__|\__,_|___/_.__/ \__,_|_|
This is a list of the statusbar modules.
📦5 \033[31mpacpackages\033[0m: updatable packages (must have pacman -Sy run in root cronjob to check).
📰 41 \033[32mnews\033[0m: unread RSS entries in newsboat.
☔ 83% ❄️ 69° 🌞 80° \033[33mweather\033[0m: ☔ for precipitation, 🌞 and ❄ for daily high and low.
📬 20 \033[34mmailbox\033[0m: number of unread mail if mutt-wizard is active.
🔉 62% \033[35mvolume\033[0m: master sink volume.
🔌83% \033[36mbattery\033[0m: 🔌 for charging, 🔋 for discharging, ⚡ for full.
📶 80% ❎ \033[37minternet\033[0m: 📶 for wifi with % (📡 if none), 🌐 for ethernet. (❎ if none).
Obviously the time and date are displayed as well.
Optional script modules:
Edit \033[32m~/.local/src/dwmblocks/config.h\033[0m to add these or your own if you'd like (and recompile and restart dwmblocks).
'memory' 🧠 559Mi/3.7Gi Current used memory/total memory.
'cpu' 🌡 +46.0°C CPU temperature.
'disk' 🖥 : 28G/30G Remaining disk space...
'disk ~' 🏠: 641G/850G ...can be given directory argument.
'moonphase' 🌕 39% Phase of the moon (requires \033[32m\`pom-perl\`\033[0m).
'iplocate' 🇺🇸 United States Your own or VPN location (requires \033[32m\`geoiplookup\`\033[0m).
" | less

View File

@ -1,8 +0,0 @@
#!/bin/sh
string="$(insync get_status)"
case "$string" in
SYNCED) echo '🔗' ;;
OFFLINE) echo '🔗' ;;
SYNCING) echo '🔄' ;;
esac

View File

@ -1,48 +0,0 @@
#!/bin/sh
# Prints the current volume or 🔇 if muted. Uses PulseAudio by default,
# uncomment the ALSA lines if you remove PulseAudio.
case $BLOCK_BUTTON in
# 1) setsid "$TERMINAL" -e alsamixer & ;;
# 2) amixer sset Master toggle ;;
# 4) amixer sset Master 5%+ >/dev/null 2>/dev/null ;;
# 5) amixer sset Master 5%- >/dev/null 2>/dev/null ;;
1) setsid "$TERMINAL" -e pulsemixer & ;;
2) pamixer -t ;;
4) pamixer --allow-boost -i 1 ;;
5) pamixer --allow-boost -d 1 ;;
3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute.
- Scroll to change."
esac
volstat="$(pactl list sinks)"
# volstat="$(amixer get Master)" # ALSA only equivalent.
# Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
echo "$volstat" | grep -q "Mute: yes" && printf "🔇\\n" && exit
else
echo "$volstat" | grep -A10 "State: RUNNING" | grep -q "Mute: yes" && printf "🔇\\n" && exit
fi
# echo "$volstat" | grep "\[off\]" >/dev/null && printf "🔇\\n" && exit # ALSA
# Uses active sink if one is running, otherwise just go for the default one (First one listed in pactl list sinks)
if [ -z "$(echo "$volstat" | grep -A10 'State: RUNNING' )" ]; then
vol="$(echo "$volstat" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
else
vol="$(echo "$volstat" | grep -A10 "State: RUNNING" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"
fi
# vol=$(echo "$volstat" | grep -o "\[[0-9]\+%\]" | sed "s/[^0-9]*//g;1q") # ALSA
if [ "$vol" -gt "70" ]; then
icon="🔊"
elif [ "$vol" -lt "30" ]; then
icon="🔈"
else
icon="🔉"
fi
printf "%s%s%%\\n" "$icon" "$vol"

View File

@ -1,25 +0,0 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) setsid "$TERMINAL" -e pulsemixer & ;;
2) pulsemixer --toggle-mute ;;
4) pulsemixer --change-volume +5 ;;
5) pulsemixer --change-volume -5 ;;
3) pgrep -x dunst >/dev/null && notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
- Middle click to mute.
- Scroll to change."
esac
[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit
vol=$(pulsemixer --get-volume | awk '{print $1}')
if [ "$vol" -gt "70" ]; then
icon="🔊"
elif [ "$vol" -lt "30" ]; then
icon="🔈"
else
icon="🔉"
fi
printf "%s %s%%\\n" "$icon" "$vol"

View File

@ -1,26 +0,0 @@
#!/bin/sh
meteobluelink="https://www.meteoblue.com/en/weather/forecast/multimodel/zurich_switzerland_2657896"
multimodel_path="$XDG_DATA_HOME/$(date -I)_multimodel.png"
last_downloaded_path="$(for file in "$XDG_DATA_HOME"/*_multimodel.png; do
echo "$file"
done | head -n1)"
last_downloaded="$(echo "${last_downloaded_path%_multimodel.png}" | awk 'BEGIN{FS="/"} {print $NF}')"
if [ "$last_downloaded" = "*" ]; then
FLAG_download=true
else
if [ "$(date -I)" != "$last_downloaded" ]; then
echo "Last report is from another day, downloading for today..."
rm "$XDG_DATA_HOME"/*_multimodel.png
FLAG_download=true
else
FLAG_download=false
fi
fi
if [ $FLAG_download = 'true' ]; then
mb_imagelink="$(lynx --dump --listonly --nonumbers "$meteobluelink" | grep meteogram_multiSimple_hd)"
curl -L "$mb_imagelink" -o "$multimodel_path"
else
echo "currently downloaded multimodel is from today, showing cached version"
fi
sxiv "$XDG_DATA_HOME"/*_multimodel.png