diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/statusbar/sb-clock | 21 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-doppler | 19 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-forecast | 52 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-internet | 27 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-memory | 15 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-microphone | 24 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-nettraf | 22 | ||||
-rwxr-xr-x | .local/bin/statusbar/sb-volume | 26 |
8 files changed, 206 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock new file mode 100755 index 0000000..bdf3590 --- /dev/null +++ b/.local/bin/statusbar/sb-clock @@ -0,0 +1,21 @@ +#!/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 + +date "+%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..4567e30 --- /dev/null +++ b/.local/bin/statusbar/sb-doppler @@ -0,0 +1,19 @@ +#!/bin/sh + +showdoppler() { + hyprctl dispatch exec "[float; size 800 800;]" 'curl -s https://meteoinfo.ru/hmc-output/rmap/phenomena.gif | imv - -H 1200 -W 1200' +} + +sendnotif() { + notify-send "š¦ļø Doppler RADAR" "Left click for full forecast." +} +if [ ! -n "$1" ]; then + echo š
+else + if [ "$1" -eq 1 ]; then + showdoppler + elif [ "$1" -eq 3 ]; then + sendnotif + fi +fi + diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast new file mode 100755 index 0000000..42442cf --- /dev/null +++ b/.local/bin/statusbar/sb-forecast @@ -0,0 +1,52 @@ +#!/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; } + +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;]" 'kitty -e sh -c "curl wttr.in; read _"' +} + +sendnotif() { + notify-send "š Weather module" "Left click for full forecast." +} + +if [ ! -n "$1" ]; then + getforecast + showweather +else + if [ "$1" -eq 1 ]; then + openterm + elif [ "$1" -eq 3 ]; then + sendnotif + fi +fi + diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet new file mode 100755 index 0000000..0cbf877 --- /dev/null +++ b/.local/bin/statusbar/sb-internet @@ -0,0 +1,27 @@ +#!/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 + +printconnection() { + [ "$(cat /sys/class/net/eth0/operstate 2>/dev/null)" = 'up' ] && ethericon="š" || ethericon="ā" + [ -n "$(cat /sys/class/net/wg0/operstate 2>/dev/null)" ] && tunicon=" š" + printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon" +} + +if [ ! -n "$1" ]; then + printconnection +else + if [ "$1" -eq 1 ]; then + 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 + elif [ "$1" -eq 3 ]; then + notify-send "š Internet module" "\- Click to connect to vpn" + fi +fi diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory new file mode 100755 index 0000000..cf661a6 --- /dev/null +++ b/.local/bin/statusbar/sb-memory @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ ! -n "$1" ]; then + free --mebi | sed -n '2{p;q}' | awk '{printf ("š§ %2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}' +else + if [ "$1" -eq 1 ]; then + notify-send "š§ Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" + elif [ "$1" -eq 2 ]; then + hyprctl dispatch exec "[float; size 1800 1300;]" 'kitty -e sh -c "btop"' + elif [ "$1" -eq 3 ]; then + notify-send "š§ Memory module" "\- Shows Memory Used/Total." + fi +fi + + diff --git a/.local/bin/statusbar/sb-microphone b/.local/bin/statusbar/sb-microphone new file mode 100755 index 0000000..e07e0de --- /dev/null +++ b/.local/bin/statusbar/sb-microphone @@ -0,0 +1,24 @@ +#!/bin/sh + +mic="$(wpctl get-volume @DEFAULT_SOURCE@)" + +# If muted, print š and exit. +[ "$mic" != "${mic%\[MUTED\]}" ] && echo ļ± && exit + +mic="${mic#Volume: }" + +split() { + # For ommiting the . without calling and external program. + IFS=$2 + set -- $1 + printf '%s' "$@" +} + +mic="$(printf "%.0f" "$(split "$mic" ".")")" + +case 1 in + $((mic >= 1)) ) icon="šļø" ;; + * ) echo ļ± && exit ;; +esac + +echo "$icon $mic%" diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf new file mode 100755 index 0000000..88df9bd --- /dev/null +++ b/.local/bin/statusbar/sb-nettraf @@ -0,0 +1,22 @@ +#!/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. + +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..e3501d1 --- /dev/null +++ b/.local/bin/statusbar/sb-volume @@ -0,0 +1,26 @@ +#!/bin/sh + +vol="$(wpctl get-volume @DEFAULT_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%" |