aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-27 03:44:14 +0300
committerawy <awy@tutamail.com>2024-08-27 03:44:14 +0300
commit8c24921832b2b6dc95bbb41dbfe2de7ff4fcf877 (patch)
treeb8bfc2d150de60d0f989843cb67bc0c6fd380366 /.local
parent01b0a486d1190b88ee40458b4e16bcd6fa0c93bc (diff)
update
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/statusbar/sb-clock21
-rwxr-xr-x.local/bin/statusbar/sb-doppler19
-rwxr-xr-x.local/bin/statusbar/sb-forecast52
-rwxr-xr-x.local/bin/statusbar/sb-internet27
-rwxr-xr-x.local/bin/statusbar/sb-memory15
-rwxr-xr-x.local/bin/statusbar/sb-microphone24
-rwxr-xr-x.local/bin/statusbar/sb-nettraf22
-rwxr-xr-x.local/bin/statusbar/sb-volume26
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%"