inital commit

This commit is contained in:
2020-07-04 14:23:27 +02:00
commit 46d9d9eb4c
251 changed files with 15044 additions and 0 deletions

27
.local/bin/statusbar/battery Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# Prints all batteries, their percentage remaining and an emoji corresponding
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
case $BLOCK_BUTTON in
3) notify-send "🔋 Battery module" "🔋: discharging
🛑: not charging
♻: stagnant charge
🔌: charging
⚡: charged
❗: battery very low!" ;;
esac
# Loop through all attached batteries.
for battery in /sys/class/power_supply/BAT?
do
# Get its remaining capacity and charge status.
capacity=$(cat "$battery"/capacity) || break
status=$(sed "s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/" "$battery"/status)
# If it is discharging and 25% or less, we will add a ❗ as a warning.
[ "$capacity" -le 25 ] && [ "$status" = "🔋" ] && warn="❗"
printf "%s%s%s%% " "$status" "$warn" "$capacity"
unset warn
done | sed 's/ *$//'

View File

@ -0,0 +1,32 @@
#!/bin/sh
# Give a battery name (e.g. BAT0) as an argument.
case $BLOCK_BUTTON in
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
🛑: not charging
♻: stagnant charge
🔌: charging
⚡: charged
❗: battery very low!
- Text color reflects charge left" ;;
esac
capacity=$(cat /sys/class/power_supply/"$1"/capacity 2>/dev/null) || exit
status=$(cat /sys/class/power_supply/"$1"/status)
if [ "$capacity" -ge 75 ]; then
color="#00ff00"
elif [ "$capacity" -ge 50 ]; then
color="#ffffff"
elif [ "$capacity" -ge 25 ]; then
color="#ffff00"
else
color="#ff0000"
warn="❗"
fi
[ -z $warn ] && warn=" "
[ "$status" = "Charging" ] && color="#ffffff"
printf "%s%s%s" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"

View File

@ -0,0 +1,32 @@
#!/bin/sh
# Give a battery name (e.g. BAT0) as an argument.
case $BLOCK_BUTTON in
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
🛑: not charging
♻: stagnant charge
🔌: charging
⚡: charged
❗: battery very low!
- Text color reflects charge left" ;;
esac
capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
status=$(cat /sys/class/power_supply/"$1"/status)
if [ "$capacity" -ge 75 ]; then
color="#00ff00"
elif [ "$capacity" -ge 50 ]; then
color="#ffffff"
elif [ "$capacity" -ge 25 ]; then
color="#ffff00"
else
color="#ff0000"
warn="❕"
fi
[ -z $warn ] && warn=" "
[ "$status" = "Charging" ] && color="#ffffff"
printf "<span color='%s'>%s%s%s</span>" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not charging/🛑/;s/Charging/🔌/;s/Unknown//;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"

2
.local/bin/statusbar/btstatus Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
bluetoothctl show | grep Powered | awk '{print $2}' | sed "s/no//; s/yes/🎧/"

3
.local/bin/statusbar/clock Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
date '+%H:%M'

11
.local/bin/statusbar/corona Executable file
View File

@ -0,0 +1,11 @@
#!/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 }' )

12
.local/bin/statusbar/cpu Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;;
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
- Click to show intensive processes.
- % is of single core." ;;
esac
temp=$(sensors | awk '/Package id 0/ {print "🌡 "$4}' | sed 's/\.[0-9]//; s/+//')
[ -n "$temp" ] && echo $temp > /tmp/cpu_temp
cat /tmp/cpu_temp

53
.local/bin/statusbar/crypto Executable file
View File

@ -0,0 +1,53 @@
#!/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

@ -0,0 +1,2 @@
#!/bin/sh
date '+%a %b %d'

18
.local/bin/statusbar/disk Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# Status bar module for disk space
# $1 should be drive mountpoint
# $2 is optional icon, otherwise mountpoint will displayed
[ -z "$1" ] && exit
icon="$2"
[ -z "$2" ] && icon="$1"
case $BLOCK_BUTTON in
1) pgrep -x dunst >/dev/null && notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
3) pgrep -x dunst >/dev/null && notify-send "💽 Disk module" "\- Shows used hard drive space.
- Click to show all disk info." ;;
esac
printf "%s: %s" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')"

2
.local/bin/statusbar/getbright Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
echo ☀ $(bc <<< "scale=0; $(cat /sys/class/backlight/intel_backlight/brightness) /9.37")%

3
.local/bin/statusbar/getmail Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
num=$(find ~/.local/share/mail/*/INBOX/new -type f | wc -l)
[ $num != 0 ] && echo "📬 "$num

View File

@ -0,0 +1,6 @@
#!/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" ] && echo '🍅'$min

View File

@ -0,0 +1,6 @@
#!/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" ] && echo '📚'$min

View File

@ -0,0 +1,2 @@
#!/bin/bash
pactl list sinks | grep -qE 'device.icon_name = \"audio-(headset|headphones)-bluetooth\"' && echo 🎧

7
.local/bin/statusbar/help Executable file
View File

@ -0,0 +1,7 @@
#!/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 "❓"

16
.local/bin/statusbar/help-icon Executable file
View File

@ -0,0 +1,16 @@
#!/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 "❓"

19
.local/bin/statusbar/internet Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) $TERMINAL -e nmtui ;;
3) pgrep -x dunst >/dev/null && notify-send "🌐 Internet module" "\- Click to connect
📡: no wifi connection
📶: wifi connection with quality
❎: no ethernet
🌐: ethernet working
" ;;
esac
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡"
[ ! -n "${wifiicon+var}" ] && wifiicon="📶"
#[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
printf "%s%s" "$wifiicon" "$(cat /sys/class/net/w*/operstate | sed "s/down/❎/;s/up/🌐/")"

9
.local/bin/statusbar/iplocate Executable file
View File

@ -0,0 +1,9 @@
#!/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/;.*//"

16
.local/bin/statusbar/mailbox Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# i3blocks mail module.
# Displays number of unread mail and an loading icon if updating.
# When clicked, brings up `neomutt`.
case $BLOCK_BUTTON in
1) "$TERMINAL" -e neomutt ;;
2) setsid mailsync >/dev/null & ;;
3) pgrep -x dunst >/dev/null && notify-send "📬 Mail module" "\- Shows unread mail
- Shows 🔃 if syncing mail
- Left click opens neomutt
- Middle click syncs mail" ;;
esac
echo "$(du -a ~/.local/share/mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)"

9
.local/bin/statusbar/memory Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
case $BLOCK_BUTTON in
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
- Click to show memory hogs." ;;
esac
free -h | awk '/^Mem:/ {print $3 "/" $2}'

25
.local/bin/statusbar/moonphase Executable file
View File

@ -0,0 +1,25 @@
#!/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"%

9
.local/bin/statusbar/mpdupdate Executable file
View File

@ -0,0 +1,9 @@
#!/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

10
.local/bin/statusbar/music Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
if [ $( mpc status | grep '\[paused\]' | wc -l ) -eq 1 ]; then
echo ""
exit
fi
if [ $( mpc status | grep '\[playing\]' | wc -l ) -eq 1 ]; then
echo $(mpc status | sed "/^volume:/d" | tac | sed -e "s/\\[paused\\].*//g;s/\\[playing\\].*//g" | tr -d '\n' | sed -e "s/$/ /g")
exit
fi

18
.local/bin/statusbar/music_old Executable file
View File

@ -0,0 +1,18 @@
#!/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

3
.local/bin/statusbar/news Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
num=$( cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)")
[ "$num" = "" ] || echo 📰$num

View File

@ -0,0 +1,18 @@
#!/bin/sh
# i3blocks module for pacman upgrades.
# Displays number of upgradeable packages.
# For this to work, have a `pacman -Sy` command run in the background as a
# cronjob every so often as root. This script will then read those packages.
# When clicked, it will run an upgrade via pacman.
case $BLOCK_BUTTON in
1) $TERMINAL -e popupgrade ;;
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
3) pgrep -x dunst >/dev/null && notify-send "Upgrade module" "📦: number of upgradable packages
- Left click to upgrade packages
- Middle click to show upgradable packages" ;;
esac
pacman -Qu | grep -v "\[ignored\]" | wc -l | sed -e "s/^0$//g"

View File

@ -0,0 +1,9 @@
#!/bin/sh
printf "Beginning upgrade.\\n"
yay -Syu
pkill -RTMIN+8 i3blocks
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
read -r

View File

@ -0,0 +1,32 @@
#!/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

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

28
.local/bin/statusbar/torrent Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
transmission-remote -l | grep % |
sed " # This first sed command is to ensure a desirable order with sort
s/.*Stopped.*/A/g;
s/.*Seeding.*/Z/g;
s/.*100%.*/N/g;
s/.*Idle.*/B/g;
s/.*Uploading.*/L/g;
s/.*%.*/M/g" |
sort -h | uniq -c | sed " # Now we replace the standin letters with icons.
s/A/🛑/g;
s/B/⌛️/g;
s/L/🔼/g;
s/M/🔽/g;
s/N/✅/g;
s/Z/🌱/g" | awk '{print $2, $1}' | tr '\n' ' ' | sed -e "s/ $//g"
case $BLOCK_BUTTON in
1) $TERMINAL -e transmission-remote-cli ;;
3) pgrep -x dunst >/dev/null && notify-send "Torrent module" "🛑: paused
⏳: idle (seeds needed)
🔼: uploading (unfinished)
🔽: downloading
✅: done
🌱: done and seeding" ;;
esac

48
.local/bin/statusbar/volume Executable file
View File

@ -0,0 +1,48 @@
#!/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"

25
.local/bin/statusbar/volume_ Executable file
View File

@ -0,0 +1,25 @@
#!/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"

23
.local/bin/statusbar/weather Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
location="$1"; [ -z "$location" ] || { location="$location+" && rm -f "$HOME/.local/share/weatherreport" ;}
getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" || exit 1 ;}
showweather() { printf "%s" "$(sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
case $BLOCK_BUTTON in
1) $TERMINAL -e less -S "$HOME/.local/share/weatherreport" ;;
2) getforecast && showweather ;;
3) pgrep -x dunst >/dev/null && notify-send "🌈 Weather module" "\- Left click for full forecast.
- Middle click to update forecast.
☔: Chance of rain/snow
❄: Daily low
🌞: Daily high" ;;
esac
if [ "$(stat -c %y "$HOME/.local/share/weatherreport" >/dev/null 2>&1 | awk '{print $1}')" != "$(date '+%Y-%m-%d')" ]
then getforecast && showweather
else showweather
fi