diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/statusbar/sb-clock | 29 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-doppler | 22 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-forecast | 57 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-internet | 43 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-mailbox | 20 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-memory | 13 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-microphone | 34 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-nettraf | 29 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-volume | 36 |
9 files changed, 283 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock new file mode 100755 index 0000000..b2ed96a --- /dev/null +++ b/.local/bin/statusbar/sb-clock @@ -0,0 +1,29 @@ +#!/bin/sh + +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 $1 in + 1) notify-send "This Month" "$(cal | sed "s/\<$(date +'%e'|tr -d ' ')\>/<b><span color='red'>&<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;; + 2) hyprctl dispatch exec "$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) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +date "+%Y %b %d (%a) $icon %H:%M" diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler new file mode 100755 index 0000000..e6062a3 --- /dev/null +++ b/.local/bin/statusbar/sb-doppler @@ -0,0 +1,22 @@ +#!/bin/sh + +# Show a Doppler RADAR of a user's preferred location. +secs=600 # Download a new doppler radar if one hasn't been downloaded in $secs seconds. +radarloc="${XDG_CACHE_HOME:-$HOME/.cache}/radar" +doppler="${XDG_CACHE_HOME:-$HOME/.cache}/doppler.gif" + +getdoppler() { curl -sL https://meteoinfo.ru/hmc-output/rmap/phenomena.gif > "$doppler" ;} + +showdoppler() { hyprctl dispatch exec "[float; size 800 800;]" "imv \"$doppler\" -H 1200 -W 1200" ;} + +case $1 in + 1) [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler + showdoppler ;; + 2) getdoppler && showdoppler ;; + 3) notify-send "πΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR. +- Middle click to update RADAR location. +After $secs seconds, new clicks will also automatically update the doppler RADAR." ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +echo π
diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast new file mode 100755 index 0000000..699c868 --- /dev/null +++ b/.local/bin/statusbar/sb-forecast @@ -0,0 +1,57 @@ +#!/bin/sh + +# Displays today's precipication chance (β), and daily low (π₯Ά) and high (π). +# Usually intended for the statusbar. +LOCATION="Moscow" +url="${WTTRURL:-wttr.in}" +weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" + +# Get a weather report from 'wttr.in' and save it locally. +getforecast() { timeout --signal=1 2s curl -sf "$url/$LOCATION" > "$weatherreport" || exit 1; } + +# Forecast should be updated only once a day. +checkforecast() { + [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null | + cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] +} + +getprecipchance() { + echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file + grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%' + sort -rn | # Sort in descending order + head -1q # Extract first line +} + +getdailyhighlow() { + echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file + grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m<signed number>" + sed 's/[+m]//g' | # Remove '+' and 'm' + sort -g | # Sort in ascending order + sed -e 1b -e '$!d' # Extract the first and last lines +} + +readfile() { weatherdata="$(cat "$weatherreport")" ;} + +showweather() { + readfile + printf "β%s π₯Ά%sΒ° π%sΒ°\n" "$(getprecipchance)" $(getdailyhighlow) +} + +openterm() { + hyprctl dispatch exec "[float; size 1800 1300;]" '$TERMINAL -e sh -c "curl wttr.in/Moscow; read _"' +} + +case $1 in + 1) hyprctl dispatch exec "[float; size 1800 1100;]" "$TERMINAL -e less -Sfr \"$weatherreport\"" + ;; + 2) getforecast && showweather ;; + 3) notify-send "π Weather module" "\- Left click for full forecast. +- Middle click to update forecast. +β: Chance of rain/snow +π₯Ά: Daily low +π: Daily high" ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +checkforecast || getforecast +showweather diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet new file mode 100755 index 0000000..7802f39 --- /dev/null +++ b/.local/bin/statusbar/sb-internet @@ -0,0 +1,43 @@ +#!/bin/sh + +# Show wifi πΆ and percent strength or π‘ if none. +# Show π if connected to ethernet or β if none. +# Show π if a vpn connection is active + +togglevpn() { + if [ ! -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ];then + doas wg-quick up wg0 + notify-send "π Internet module" "Connected to VPN" + else + doas wg-quick down wg0 + notify-send "π Internet module" "Disconnected from VPN" + fi +} + +case $1 in + 1) togglevpn 2>/dev/null ;; + 3) notify-send "π Internet module" "\- Click to enable/disable VPN +β: wifi disabled +π‘: no wifi connection +πΆ: wifi connection with quality +β: no ethernet +π: ethernet working +π: vpn is active +" ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +# Wifi +if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then + wifiicon="$(awk '/^\s*w/ { print "πΆ", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then + [ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="π‘ " || wifiicon="β " +fi + +# Ethernet +[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="π" || ethericon="β" + +# Wireguard +[ -n "$(cat /sys/class/net/libre/operstate 2>/dev/null)" ] && tunicon=" π" + +printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon" diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox new file mode 100755 index 0000000..b03724f --- /dev/null +++ b/.local/bin/statusbar/sb-mailbox @@ -0,0 +1,20 @@ +#!/bin/sh + +# Displays number of unread mail and an loading icon if updating. +# When clicked, brings up `neomutt`. + +case $1 in + 1) hyprctl dispatch exec '$TERMINAL -e neomutt'; pkill -RTMIN+12 waybar ;; + 2) setsid -f mailsync >/dev/null ;; + 3) notify-send "π¬ Mail module" "\- Shows unread mail +- Shows π if syncing mail +- Left click opens neomutt +- Middle click syncs mail" ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)" + +pidof mailsync >/dev/null 2>&1 && icon="π" + +[ "$unread" = "0" ] && [ "$icon" = "" ] || echo "π¬$unread$icon" diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory new file mode 100755 index 0000000..c39488f --- /dev/null +++ b/.local/bin/statusbar/sb-memory @@ -0,0 +1,13 @@ +#!/bin/sh + +case $1 in + 1) notify-send "π§ Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; + 2) hyprctl dispatch exec '$TERMINAL -e sh -c "btop"' ;; + 3) notify-send "π§ Memory module" "\- Shows Memory Used/Total. +- Click to show memory hogs. +- Middle click to open btop." ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +free --mebi | sed -n '2{p;q}' | awk '{printf ("π§ %2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}' + diff --git a/.local/bin/statusbar/sb-microphone b/.local/bin/statusbar/sb-microphone new file mode 100755 index 0000000..610eb21 --- /dev/null +++ b/.local/bin/statusbar/sb-microphone @@ -0,0 +1,34 @@ +#!/bin/sh + +# Prints the current microphone volume or ο± if muted. + +case $1 in + 1) hyprctl dispatch exec "$TERMINAL -e pulsemixer" ;; + 3) notify-send "π€ Microphone volume module" "\- Shows volume ποΈ, ο± if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +vol="$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@)" + +# If muted, print ο± and exit. +[ "$vol" != "${vol%\[MUTED\]}" ] && echo ο± && exit + +vol="${vol#Volume: }" + +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} + +vol="$(printf "%.0f" "$(split "$vol" ".")")" + +case 1 in + $((vol >= 1)) ) icon="ποΈ" ;; + * ) echo ο± && exit ;; +esac + +echo "$icon $vol%" diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf new file mode 100755 index 0000000..0f4201b --- /dev/null +++ b/.local/bin/statusbar/sb-nettraf @@ -0,0 +1,29 @@ +#!/bin/sh + +# Module showing network traffic. Shows how much data has been received (RX) or +# transmitted (TX) since the previous time this script ran. So if run every +# second, gives network traffic per second. + +case $1 in + 1) hyprctl dispatch exec "$TERMINAL -e bmon" ;; + 3) notify-send "π Network traffic module" "π»: Traffic received +πΊ: Traffic transmitted" ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +update() { + sum=0 + for arg; do + read -r i < "$arg" + sum=$(( sum + i )) + done + cache=/tmp/${1##*/} + [ -f "$cache" ] && read -r old < "$cache" || old=0 + printf %d\\n "$sum" > "$cache" + printf %d\\n $(( sum - old )) +} + +rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) +tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) + +printf "π»%4sB πΊ%4sB\\n" $(numfmt --to=iec $rx $tx) diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume new file mode 100755 index 0000000..3b77433 --- /dev/null +++ b/.local/bin/statusbar/sb-volume @@ -0,0 +1,36 @@ +#!/bin/sh + +# Prints the current volume or π if muted. + +case $1 in + 1) hyprctl dispatch exec "$TERMINAL -e pulsemixer" ;; + 3) notify-send "π’ Volume module" "\- Shows volume π, π if muted. +- Middle click to mute. +- Scroll to change." ;; + 6) hyprctl dispatch exec "$TERMINAL -e \"$EDITOR\" \"$0\"" ;; +esac + +vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)" + +# If muted, print π and exit. +[ "$vol" != "${vol%\[MUTED\]}" ] && echo π && exit + +vol="${vol#Volume: }" + +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} + +vol="$(printf "%.0f" "$(split "$vol" ".")")" + +case 1 in + $((vol >= 70)) ) icon="π" ;; + $((vol >= 30)) ) icon="π" ;; + $((vol >= 1)) ) icon="π" ;; + * ) echo π && exit ;; +esac + +echo "$icon $vol%" |