From b3fa23487d5d8ddeb416d95ad0665eae3574eae5 Mon Sep 17 00:00:00 2001 From: GabriWar <72227489+GabriWar@users.noreply.github.com> Date: Thu, 2 Dec 2021 16:13:47 +0000 Subject: [PATCH] Add files via upload --- .local/bin/statusbar/sb-battery | 40 ++++++++++++++--------------- .local/bin/statusbar/sb-clock | 26 +++++++++---------- .local/bin/statusbar/sb-cpu | 2 +- .local/bin/statusbar/sb-forecast | 22 ++++++++-------- .local/bin/statusbar/sb-internet | 16 +++++------- .local/bin/statusbar/sb-memory | 10 ++++---- .local/bin/statusbar/sb-moonphase | 34 ++++++++++++------------ .local/bin/statusbar/sb-nettraf | 28 ++++++++++---------- .local/bin/statusbar/sb-pacpackages | 10 ++++---- .local/bin/statusbar/sb-volume | 22 ++++++++-------- 10 files changed, 103 insertions(+), 107 deletions(-) diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index 2462b403..679d8105 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -4,34 +4,34 @@ # to charge status ( for plugged up,  for discharging on battery, etc.). case $BLOCK_BUTTON in - 3) notify-send " Battery module" ": discharging +3) notify-send " Battery module" ": discharging : not charging : stagnant charge : charging : charged : battery very low! - Scroll to change adjust xbacklight." ;; - 4) xbacklight -inc 10 ;; - 5) xbacklight -dec 10 ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +4) xbacklight -inc 10 ;; +5) xbacklight -dec 10 ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac # Loop through all attached batteries and format the info for battery in /sys/class/power_supply/BAT?*; do - # If non-first battery, print a space separator. - [ -n "${capacity+x}" ] && printf " " - # Sets up the status and capacity - case "$(cat "$battery/status" 2>&1)" in - "Full") status="" ;; - "Discharging") status="" ;; - "Charging") status="" ;; - "Not charging") status="" ;; - "Unknown") status="" ;; - *) exit 1 ;; - esac - capacity="$(cat "$battery/capacity" 2>&1)" - # Will make a warn variable if discharging and low - [ "$status" = "" ] && [ "$capacity" -le 25 ] && warn="" - # Prints the info - printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn +# If non-first battery, print a space separator. +[ -n "${capacity+x}" ] && printf " " +# Sets up the status and capacity +case "$(cat "$battery/status" 2>&1)" in +"Full") status="" ;; +"Discharging") status="" ;; +"Charging") status="" ;; +"Not charging") status="" ;; +"Unknown") status="" ;; +*) exit 1 ;; +esac +capacity="$(cat "$battery/capacity" 2>&1)" +# Will make a warn variable if discharging and low +[ "$status" = "" ] && [ "$capacity" -le 25 ] && warn="" +# Prints the info +printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn done && printf "\\n" diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock index 121b80d3..072dd20c 100755 --- a/.local/bin/statusbar/sb-clock +++ b/.local/bin/statusbar/sb-clock @@ -3,19 +3,19 @@ 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="" ;; + "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 diff --git a/.local/bin/statusbar/sb-cpu b/.local/bin/statusbar/sb-cpu index cd31f308..c2e26d7c 100755 --- a/.local/bin/statusbar/sb-cpu +++ b/.local/bin/statusbar/sb-cpu @@ -9,4 +9,4 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -sensors | awk '/Core 0/ {print " " $3}' +sensors | awk '/Core 0/ {print "" $3}' diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index 72e850d5..5c893874 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -1,6 +1,6 @@ #!/bin/sh -# Displays todays precipication chance () and daily low () and high (). +# Displays todays precipication chance () and daily low () and high (). # Usually intended for the statusbar. # If we have internet, get a weather report from wttr.in and store it locally. @@ -13,23 +13,23 @@ getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} # precipitation chance and the daily high and low from the downloaded file and # display them with coresponding emojis. showweather() { printf "%s" "$(sed '16q;d' "$weatherreport" | - grep -wo "[0-9]*%" | sort -rn | sed "s/^//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 "°"}' ;} +grep -wo "[0-9]*%" | sort -rn | sed "s/^//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. +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. -: Chance of rain/snow -: Daily low -: Daily high" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +: Chance of rain/snow +: Daily low +: Daily high" ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac # The test if our forcecast is updated to the day. If it isn't download a new # weather report from wttr.in with the above function. [ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || - getforecast +getforecast showweather diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet index 4d7f3033..09ffd71b 100755 --- a/.local/bin/statusbar/sb-internet +++ b/.local/bin/statusbar/sb-internet @@ -1,12 +1,8 @@ #!/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 - case $BLOCK_BUTTON in - 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; - 3) notify-send " Internet module" "\- Click to connect +1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; +3) notify-send " Internet module" "\- Click to connect : wifi disabled : no wifi connection : wifi connection with quality @@ -14,13 +10,13 @@ case $BLOCK_BUTTON in : ethernet working : vpn is active " ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then - wifiicon="$(awk '/^\s*w/ { print "", int($3 * 100 / 70) "% " }' /proc/net/wireless)" +wifiicon="$(awk '/^\s*w/ { print "", int($3 * 100 / 70) "% " }' /proc/net/wireless)" elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then - grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="📡 " || wifiicon="❌ " +grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon=" " || wifiicon=" " fi -printf "%s%s%s\n" "$wifiicon" "$(sed "s/down//;s/up//" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)" +printf "%s%s%s\n" "$wifiicon" "$(sed "s/down//;s/up//" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*//" /sys/class/net/tun*/operstate 2>/dev/null)" diff --git a/.local/bin/statusbar/sb-memory b/.local/bin/statusbar/sb-memory index d9a59173..2dd711fe 100755 --- a/.local/bin/statusbar/sb-memory +++ b/.local/bin/statusbar/sb-memory @@ -1,12 +1,12 @@ #!/bin/sh case $BLOCK_BUTTON in - 1) notify-send " Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; - 2) setsid -f "$TERMINAL" -e htop ;; - 3) notify-send " Memory module" "\- Shows Memory Used/Total. +1) notify-send " Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;; +2) setsid -f "$TERMINAL" -e htop ;; +3) notify-send " Memory module" "\- Shows Memory Used/Total. - Click to show memory hogs. - Middle click to open htop." ;; - 6) "$TERMINAL" "$EDITOR" "$0" ;; +6) "$TERMINAL" "$EDITOR" "$0" ;; esac -free --mebi | sed -n '2{p;q}' | awk '{printf (" %2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}' +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-moonphase b/.local/bin/statusbar/sb-moonphase index fab8b4da..cd77d599 100755 --- a/.local/bin/statusbar/sb-moonphase +++ b/.local/bin/statusbar/sb-moonphase @@ -10,28 +10,28 @@ moonfile="${XDG_DATA_HOME:-$HOME/.local/share}/moonphase" icon="$(cat "$moonfile")" case "$icon" in - 🌑) name="New" ;; - 🌒) name="Waxing Crescent" ;; - 🌓) name="First Quarter" ;; - 🌔) name="Waxing Gibbous" ;; - 🌕) name="Full" ;; - 🌖) name="Waning Gibbous" ;; - 🌗) name="Last Quarter" ;; - 🌘) name="Waning Crescent" ;; + ) name="New" ;; + ) name="Waxing Crescent" ;; + ) name="First Quarter" ;; + ) name="Waxing Gibbous" ;; + ) name="Full" ;; + ) name="Waning Gibbous" ;; + ) name="Last Quarter" ;; + ) name="Waning Crescent" ;; *) exit 1 ;; esac echo "${icon-?}" case $BLOCK_BUTTON in - 3) notify-send "🌜 Moon phase module" "Displays current moon phase. -- 🌑: New -- 🌒: Waxing Crescent -- 🌓: First Quarter -- 🌔: Waxing Gibbous -- 🌕: Full -- 🌖: Waning Gibbous -- 🌗: Last Quarter -- 🌘: Waning Crescent" ;; + 3) notify-send " Moon phase module" "Displays current moon phase. +- : New +- : Waxing Crescent +- : First Quarter +- : Waxing Gibbous +- : Full +- : Waning Gibbous +- : Last Quarter +- : Waning Crescent" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf index 6bb7a379..ed2f86dd 100755 --- a/.local/bin/statusbar/sb-nettraf +++ b/.local/bin/statusbar/sb-nettraf @@ -5,25 +5,25 @@ # second, gives network traffic per second. case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e bmon ;; - 3) notify-send " Network traffic module" ": Traffic received -: Traffic transmitted" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +1) setsid -f "$TERMINAL" -e bmon ;; +3) notify-send " Network traffic module" ": Traffic received +: Traffic transmitted" ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac update() { - sum=0 - for arg; do - read -r i < "$arg" - sum=$(( sum + i )) - done - cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/} - [ -f "$cache" ] && read -r old < "$cache" || old=0 - printf %d\\n "$sum" > "$cache" - printf %d\\n $(( sum - old )) +sum=0 +for arg; do +read -r i < "$arg" +sum=$(( sum + i )) +done +cache=${XDG_CACHE_HOME:-$HOME/.cache}/${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 "%4s %4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx) +printf "%4s %4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx) diff --git a/.local/bin/statusbar/sb-pacpackages b/.local/bin/statusbar/sb-pacpackages index cf0f68c0..e53d1f4b 100755 --- a/.local/bin/statusbar/sb-pacpackages +++ b/.local/bin/statusbar/sb-pacpackages @@ -18,12 +18,12 @@ # Exec = /usr/bin/pkill -RTMIN+8 dwmblocks # Or i3blocks if using i3. case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e sb-popupgrade ;; - 2) notify-send "$(/usr/bin/pacman -Qu)" ;; - 3) notify-send " Upgrade module" ": number of upgradable packages +1) setsid -f "$TERMINAL" -e sb-popupgrade ;; +2) notify-send "$(/usr/bin/pacman -Qu)" ;; +3) notify-send " Upgrade module"": number of upgradable packages - Left click to upgrade packages - Middle click to show upgradable packages" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -pacman -Qu | grep -Fcv "[ignored]" | sed "s/^//;s/^0$//g" +pacman -Qu | grep -Fcv "[ignored]" | sed "s/^//;s/^0$//g" diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume index b28ff73d..a55d18ad 100755 --- a/.local/bin/statusbar/sb-volume +++ b/.local/bin/statusbar/sb-volume @@ -1,16 +1,16 @@ #!/bin/sh -# Prints the current volume or 🔇 if muted. +# 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. +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" ;; +6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac [ $(pamixer --get-mute) = true ] && echo  && exit @@ -18,13 +18,13 @@ esac vol="$(pamixer --get-volume)" if [ "$vol" -gt "70" ]; then - icon="" +icon="" elif [ "$vol" -gt "30" ]; then - icon="" +icon="" elif [ "$vol" -gt "0" ]; then - icon="" +icon="" else - echo  && exit +echo 婢 && exit fi echo "$icon$vol%"