1
0
Fork 0

prep sb scripts for new setup

This commit is contained in:
Luca Bilke 2022-08-19 18:44:18 +02:00
parent 8eb1ef3081
commit 622374cc92
8 changed files with 85 additions and 20 deletions

View file

@ -1,3 +1,39 @@
#!/bin/sh
date "+%d.%m.%Y %H:%M"
clock=$(date '+%I')
case "$clock" in
"00") icon="" ;;
"01") icon="" ;;
"02") icon="" ;;
"03") icon="" ;;
"04") icon="" ;;
"05") icon="" ;;
"06") icon="" ;;
"07") icon="" ;;
"08") icon="" ;;
"09") icon="" ;;
"10") icon="" ;;
"11") icon="" ;;
"12") icon="" ;;
esac
case $BLOCK_BUTTON in
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
2) setsid -f "$TERMINAL" -e calcurse ;;
3) notify-send " Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
- Middle click opens calcurse if installed" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
expireTime=3000
appoint="$(calcurse -d7 --output-datefmt '%A')" # Easier reading on this output
case $BLOCK_BUTTON in
1) notify-send --expire-time=$expireTime "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && [ ${#appoint} -gt 0 ] && notify-send --expire-time=$expireTime "Appointments" "$appoint" ;;
2) setsid -f "$TERMINAL" -e calcurse ;;
3) notify-send " Time/date module" "\- Left click to show upcoming appointments for the next three days (if there are any) and the month.
- Middle click opens calcurse if installed" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
date "+%d.%M.%Y $icon %H:%M"

View file

@ -1,5 +1,5 @@
#!/bin/sh
# TODO: Add color
case $BLOCK_BUTTON in
1) notify-send "﬙ CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)\\n(100% per core)" ;;
2) setsid -f "$TERMINAL" -e htop ;;

View file

@ -19,7 +19,7 @@ esac
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
[ ! -f $cache ] && echo "$stats" > "$cache"
old=$(cat "$cache")
printf "﬙"
printf "﬙ "
echo "$stats" | while read -r row; do
id=${row%% *}
rest=${row#* }
@ -30,15 +30,15 @@ echo "$stats" | while read -r row; do
printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \
id="$id" total="$total" idle="$idle")" in
"0") printf "";;
"1") printf "";;
"2") printf "";;
"3") printf "";;
"4") printf "";;
"5") printf "";;
"6") printf "";;
"7") printf "";;
"8") printf "";;
"0") printf "\033[32m▁\033[0m";;
"1") printf "\033[32m▂\033[0m";;
"2") printf "\033[32m▃\033[0m";;
"3") printf "\033[33m▄\033[0m";;
"4") printf "\033[33m▅\033[0m";;
"5") printf "\033[33m▆\033[0m";;
"6") printf "\033[31m▇\033[0m";;
"7") printf "\033[31m█\033[0m";;
"8") printf "\033[31m█\033[0m";;
esac
done; printf "\\n"
echo "$stats" > "$cache"

View file

@ -14,10 +14,4 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
case "$location" in
"/home"* ) icon="" ;;
"/mnt"* ) icon="禍" ;;
*) icon="ﲾ";;
esac
printf "%s: %s\n" "$icon" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
printf "%s\n" " $(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"

View file

@ -25,6 +25,17 @@ showweather() { emoji=$(cat "$weatheremoji") && printf "%s" "$(sed '16q;d' "$wea
grep -wo "[0-9]*%" | sort -rn | sed "s/^/ $(printf %.1s "$emoji") /g;1q" | tr -d '\n')"
sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " " $1 "°"," " $2 "°"}' ;}
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;;
2) getforecast && showweather ;;
3) notify-send " Weather module" "\- Left click for full forecast.
- Middle click to update forecast.
${emoji}: Chance of rain/snow
: Daily low
: Daily high" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
[ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] ||
getforecast && convertemoji

View file

@ -4,5 +4,5 @@
# music player's status. mpd must be running on X's start for this to work.
while : ; do
mpc idle >/dev/null && kill -46 "$(pidof dwm)" || break
mpc idle >/dev/null && kill -45 "$(pidof dwm)" || break
done

View file

@ -13,3 +13,17 @@ filter() {
}
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
case $BLOCK_BUTTON in
1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause
2) mpc toggle | filter ;; # right click, pause/unpause
3) mpc status | filter ; notify-send " Music module" "\- Shows mpd song playing.
- ⏸ 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
6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
*) mpc status | filter ;;
esac

View file

@ -1,6 +1,16 @@
#!/bin/sh
# Prints the current volume or ﱝ if muted.
case $BLOCK_BUTTON in
1) setsid -f "$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." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
[ "$(pamixer --get-mute)" = true ] && echo "ﱝ" && exit