summaryrefslogtreecommitdiffstats
path: root/.local/bin/statusbar
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/statusbar')
-rwxr-xr-x.local/bin/statusbar/sb-battery7
-rwxr-xr-x.local/bin/statusbar/sb-clock2
-rwxr-xr-x.local/bin/statusbar/sb-doppler414
-rwxr-xr-x.local/bin/statusbar/sb-internet10
-rwxr-xr-x.local/bin/statusbar/sb-mailbox2
-rwxr-xr-x.local/bin/statusbar/sb-music2
-rwxr-xr-x.local/bin/statusbar/sb-nettraf4
-rwxr-xr-x.local/bin/statusbar/sb-price26
-rwxr-xr-x.local/bin/statusbar/sb-volume6
9 files changed, 272 insertions, 201 deletions
diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery
index 382b31b..93cbe08 100755
--- a/.local/bin/statusbar/sb-battery
+++ b/.local/bin/statusbar/sb-battery
@@ -21,16 +21,17 @@ 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")" in
+ 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")
+ 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 && exit 0
+done && printf "\\n"
diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock
index d25e8d0..e1ca8c7 100755
--- a/.local/bin/statusbar/sb-clock
+++ b/.local/bin/statusbar/sb-clock
@@ -19,7 +19,7 @@ case "$clock" in
esac
case $BLOCK_BUTTON in
- 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
+ 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;;
2) setsid -f "$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" ;;
diff --git a/.local/bin/statusbar/sb-doppler b/.local/bin/statusbar/sb-doppler
index dc93db0..dabf18b 100755
--- a/.local/bin/statusbar/sb-doppler
+++ b/.local/bin/statusbar/sb-doppler
@@ -1,194 +1,248 @@
#!/bin/sh
-# Show a Doppler RADAR of an American user's preferred location.
+# 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"
-pickloc() { chosen="$(echo "Northeast
-Southeast
-PacNorthWest
-PacSouthWest
-UpperMissVly
-SouthMissVly
-SouthPlains
-NorthRockies
-SouthRockies
-Alaska
-Carib
-Hawaii
-CentGrLakes
-Conus-Large
-KABR: Aberdeen, SD
-KBIS: Bismarck, ND
-KFTG: Denver/Boulder, CO
-KDMX: Des Moines, IA
-KDTX: Detroit, MI
-KDDC: Dodge City, KS
-KDLH: Duluth, MN
-KCYS: Cheyenne, WY
-KLOT: Chicago, IL
-KGLD: Goodland, KS
-KUEX: Hastings, NE
-KGJX: Grand Junction, CO
-KGRR: Grand Rapids, MI
-KMVX: Fargo/Grand Forks, ND
-KGRB: Green Bay, WI
-KIND: Indianapolis, IN
-KJKL: Jackson, KY
-KARX: La Crosse, WI
-KILX: Lincoln/Central Illinois, IL
-KLVX: Louisville, KY
-KMQT: Marquette
-KMKX: Milwaukee, WI
-KMPX: Minneapolis, MN
-KAPX: Gaylord/Alpena, MI
-KLNX: North Platte, NE
-KIWX: N. Webster/Northern, IN
-KOAX: Omaha, NE
-KPAH: Paducah, KY
-KEAX: Pleasant Hill, MO
-KPUX: Pueblo, CO
-KDVN: Quad Cities, IA
-KUDX: Rapid City, SD
-KRIW: Riverton, WY
-KSGF: Springfield, MO
-KLSX: St. LOUIS, MO
-KFSD: Sioux Falls, IA
-KTWX: Topeka, KS
-KICT: Wichita, KS
-KVWX: Paducah, KY
-ICAO: Responsible Wfo
-KLTX: WILMINGTON, NC
-KCCX: State College/Central, PA
-KLWX: Sterling, VA
-KFCX: Blacksburg/Roanoke, VA
-KRAX: Raleigh/Durham, NC
-KGYX: Portland, ME
-KDIX: Mt Holly/Philadelphia, PA
-KPBZ: Pittsburgh, PA
-KAKQ: Wakefield, VA
-KMHX: Morehead City, NC
-KGSP: Greer/Greenville/Sprtbg, SC
-KILN: Wilmington/Cincinnati, OH
-KCLE: Cleveland, OH
-KCAE: Columbia, SC
-KBGM: Binghamton, NY
-KENX: Albany, NY
-KBUF: Buffalo, NY
-KCXX: Burlington, VT
-KCBW: Caribou, ME
-KBOX: Boston /Taunton, MA
-KOKX: New York City, NY
-KCLX: Charleston, SC
-KRLX: Charleston, WV
-ICAO: Responsible WFO
-KBRO: Brownsville, TX
-KABX: Albuquerque, NM
-KAMA: Amarillo, TX
-KFFC: Peachtree City/Atlanta, GA
-KEWX: Austin/Sanantonio, TX
-KBMX: Birmingham, AL
-KCRP: Corpus Christi, TX
-KFWS: Dallas / Ft. Worth, TX
-KEPZ: El Paso, TX
-KHGX: Houston/ Galveston, TX
-KJAX: Jacksonville, FL
-KBYX: Key West, FL
-KMRX: Morristown/knoxville, TN
-KLBB: Lubbock, TX
-KLZK: Little Rock, AR
-KLCH: Lake Charles, LA
-KOHX: Nashville, TN
-KMLB: Melbourne, FL
-KNQA: Memphis, TN
-KAMX: Miami, FL
-KMAF: Midland/odessa, TX
-KTLX: Norman, OK
-KHTX: Huntsville, AL
-KMOB: Mobile, AL
-KTLH: Tallahassee, FL
-KTBW: Tampa Bay Area, FL
-KSJT: San Angelo, TX
-KINX: Tulsa, OK
-KSRX: Tulsa, OK
-KLIX: New Orleans/slidell, LA
-KDGX: Jackson, MS
-KSHV: Shreveport, LA
-ICAO: Responsible WFO
-KLGX: Seattle / Tacoma, WA
-KOTX: Spokane, WA
-KEMX: Tucson, AZ
-KYUX: Phoenix, AZ
-KNKX: San Diego, CA
-KMUX: Monterey/san Francisco, CA
-KHNX: San Joaquin/hanford, CA
-KSOX: San Diego, CA
-KATX: Seattle / Tacoma, WA
-KIWA: Phoenix, AZ
-KRTX: Portland, OR
-KSFX: Pocatello, ID
-KRGX: Reno, NV
-KDAX: Sacramento, CA
-KMTX: Salt Lake City, UT
-KPDT: Pendleton, OR
-KMSX: Missoula, MT
-KESX: Las Vegas, NV
-KVTX: Los Angeles, CA
-KMAX: Medford, OR
-KFSX: Flagstaff, AZ
-KGGW: Glasgow, MT
-KLRX: Elko, NV
-KBHX: Eureka, CA
-KTFX: Great Falls, MT
-KCBX: Boise, ID
-KBLX: Billings, MT
-KICX: Salt Lake City, UT
-ICAO: Responsible Wfo W/ MSCF
-PABC: Anchorage, AK
-PAPD: Fairbanks, AK
-PHKM: Honolulu, HI
-PAHG: Anchorage, AK
-PAKC: Anchorage, AK
-PAIH: Anchorage, AK
-PHMO: Honolulu, HI
-PAEC: Fairbanks, AK
-TJUA: San Juan, PR
-PACG: Juneau, AK
-PHKI: Honolulu, HI
-PHWA: Honolulu, HI
-ICAO: Responsible Wfo W/ MSCF
-KFDR: Norman, OK
-PGUA: Guam
-KBBX: Sacramento, CA
-KFDX: Albuquerque, NM
-KGWX: Jackson, MS
-KDOX: Wakefield, VA
-KDYX: San Angelo, TX
-KEYX: Las Vegas, NV
-KEVX: Mobile, AL
-KHPX: Paducah, KY
-KTYX: Burlington, VT
-KGRK: Dallas / Ft. Worth, TX
-KPOE: Lake Charles, LA
-KEOX: Tallahassee, FL
-KHDX: El Paso, TX
-KDFX: San Antonio, TX
-KMXX: Birmingham, AL
-KMBX: Bismarck, ND
-KVAX: Jacksonville, FL
-KJGX: Peachtree City/atlanta, GA
-KVNX: Norman, OK
-KVBX: Vandenberg Afb: Orcutt, CA" | dmenu -r -i -l 50 -p "Select a National Weather Service radar to use as default:" | sed "s/:.*//" | tr "[:lower:]" "[:upper:]")"
+pickloc() { chosen="$(echo "US: Northeast
+US: Southeast
+US: PacNorthWest
+US: PacSouthWest
+US: UpperMissVly
+US: SouthMissVly
+US: SouthPlains
+US: NorthRockies
+US: SouthRockies
+US: Alaska
+US: Carib
+US: Hawaii
+US: CentGrLakes
+US: Conus-Large
+US: KABR: Aberdeen, SD
+US: KBIS: Bismarck, ND
+US: KFTG: Denver/Boulder, CO
+US: KDMX: Des Moines, IA
+US: KDTX: Detroit, MI
+US: KDDC: Dodge City, KS
+US: KDLH: Duluth, MN
+US: KCYS: Cheyenne, WY
+US: KLOT: Chicago, IL
+US: KGLD: Goodland, KS
+US: KUEX: Hastings, NE
+US: KGJX: Grand Junction, CO
+US: KGRR: Grand Rapids, MI
+US: KMVX: Fargo/Grand Forks, ND
+US: KGRB: Green Bay, WI
+US: KIND: Indianapolis, IN
+US: KJKL: Jackson, KY
+US: KARX: La Crosse, WI
+US: KILX: Lincoln/Central Illinois, IL
+US: KLVX: Louisville, KY
+US: KMQT: Marquette
+US: KMKX: Milwaukee, WI
+US: KMPX: Minneapolis, MN
+US: KAPX: Gaylord/Alpena, MI
+US: KLNX: North Platte, NE
+US: KIWX: N. Webster/Northern, IN
+US: KOAX: Omaha, NE
+US: KPAH: Paducah, KY
+US: KEAX: Pleasant Hill, MO
+US: KPUX: Pueblo, CO
+US: KDVN: Quad Cities, IA
+US: KUDX: Rapid City, SD
+US: KRIW: Riverton, WY
+US: KSGF: Springfield, MO
+US: KLSX: St. LOUIS, MO
+US: KFSD: Sioux Falls, IA
+US: KTWX: Topeka, KS
+US: KICT: Wichita, KS
+US: KVWX: Paducah, KY
+US: ICAO: Responsible Wfo
+US: KLTX: WILMINGTON, NC
+US: KCCX: State College/Central, PA
+US: KLWX: Sterling, VA
+US: KFCX: Blacksburg/Roanoke, VA
+US: KRAX: Raleigh/Durham, NC
+US: KGYX: Portland, ME
+US: KDIX: Mt Holly/Philadelphia, PA
+US: KPBZ: Pittsburgh, PA
+US: KAKQ: Wakefield, VA
+US: KMHX: Morehead City, NC
+US: KGSP: Greer/Greenville/Sprtbg, SC
+US: KILN: Wilmington/Cincinnati, OH
+US: KCLE: Cleveland, OH
+US: KCAE: Columbia, SC
+US: KBGM: Binghamton, NY
+US: KENX: Albany, NY
+US: KBUF: Buffalo, NY
+US: KCXX: Burlington, VT
+US: KCBW: Caribou, ME
+US: KBOX: Boston /Taunton, MA
+US: KOKX: New York City, NY
+US: KCLX: Charleston, SC
+US: KRLX: Charleston, WV
+US: ICAO: Responsible WFO
+US: KBRO: Brownsville, TX
+US: KABX: Albuquerque, NM
+US: KAMA: Amarillo, TX
+US: KFFC: Peachtree City/Atlanta, GA
+US: KEWX: Austin/Sanantonio, TX
+US: KBMX: Birmingham, AL
+US: KCRP: Corpus Christi, TX
+US: KFWS: Dallas / Ft. Worth, TX
+US: KEPZ: El Paso, TX
+US: KHGX: Houston/ Galveston, TX
+US: KJAX: Jacksonville, FL
+US: KBYX: Key West, FL
+US: KMRX: Morristown/knoxville, TN
+US: KLBB: Lubbock, TX
+US: KLZK: Little Rock, AR
+US: KLCH: Lake Charles, LA
+US: KOHX: Nashville, TN
+US: KMLB: Melbourne, FL
+US: KNQA: Memphis, TN
+US: KAMX: Miami, FL
+US: KMAF: Midland/odessa, TX
+US: KTLX: Norman, OK
+US: KHTX: Huntsville, AL
+US: KMOB: Mobile, AL
+US: KTLH: Tallahassee, FL
+US: KTBW: Tampa Bay Area, FL
+US: KSJT: San Angelo, TX
+US: KINX: Tulsa, OK
+US: KSRX: Tulsa, OK
+US: KLIX: New Orleans/slidell, LA
+US: KDGX: Jackson, MS
+US: KSHV: Shreveport, LA
+US: ICAO: Responsible WFO
+US: KLGX: Seattle / Tacoma, WA
+US: KOTX: Spokane, WA
+US: KEMX: Tucson, AZ
+US: KYUX: Phoenix, AZ
+US: KNKX: San Diego, CA
+US: KMUX: Monterey/san Francisco, CA
+US: KHNX: San Joaquin/hanford, CA
+US: KSOX: San Diego, CA
+US: KATX: Seattle / Tacoma, WA
+US: KIWA: Phoenix, AZ
+US: KRTX: Portland, OR
+US: KSFX: Pocatello, ID
+US: KRGX: Reno, NV
+US: KDAX: Sacramento, CA
+US: KMTX: Salt Lake City, UT
+US: KPDT: Pendleton, OR
+US: KMSX: Missoula, MT
+US: KESX: Las Vegas, NV
+US: KVTX: Los Angeles, CA
+US: KMAX: Medford, OR
+US: KFSX: Flagstaff, AZ
+US: KGGW: Glasgow, MT
+US: KLRX: Elko, NV
+US: KBHX: Eureka, CA
+US: KTFX: Great Falls, MT
+US: KCBX: Boise, ID
+US: KBLX: Billings, MT
+US: KICX: Salt Lake City, UT
+US: ICAO: Responsible Wfo W/ MSCF
+US: PABC: Anchorage, AK
+US: PAPD: Fairbanks, AK
+US: PHKM: Honolulu, HI
+US: PAHG: Anchorage, AK
+US: PAKC: Anchorage, AK
+US: PAIH: Anchorage, AK
+US: PHMO: Honolulu, HI
+US: PAEC: Fairbanks, AK
+US: TJUA: San Juan, PR
+US: PACG: Juneau, AK
+US: PHKI: Honolulu, HI
+US: PHWA: Honolulu, HI
+US: ICAO: Responsible Wfo W/ MSCF
+US: KFDR: Norman, OK
+US: PGUA: Guam
+US: KBBX: Sacramento, CA
+US: KFDX: Albuquerque, NM
+US: KGWX: Jackson, MS
+US: KDOX: Wakefield, VA
+US: KDYX: San Angelo, TX
+US: KEYX: Las Vegas, NV
+US: KEVX: Mobile, AL
+US: KHPX: Paducah, KY
+US: KTYX: Burlington, VT
+US: KGRK: Dallas / Ft. Worth, TX
+US: KPOE: Lake Charles, LA
+US: KEOX: Tallahassee, FL
+US: KHDX: El Paso, TX
+US: KDFX: San Antonio, TX
+US: KMXX: Birmingham, AL
+US: KMBX: Bismarck, ND
+US: KVAX: Jacksonville, FL
+US: KJGX: Peachtree City/atlanta, GA
+US: KVNX: Norman, OK
+US: KVBX: Vandenberg Afb: Orcutt, CA
+EU: Europe
+EU: GB: Great Brittain
+EU: SCAN: Scandinavia
+EU: ALPS: The Alps
+EU: NL: The Netherlands
+EU: DE: Germany
+EU: SP: Spain
+EU: FR: France
+EU: IT: Italy
+EU: PL: Poland
+EU: GR: Greece
+EU: TU: Turkey
+EU: RU: Russia
+EU: BA: Bahrain
+EU: BC: Botswana
+EU: SE: Republic of Seychelles
+EU: HU: Hungary
+EU: UK: Ukraine
+AF: AF: Africa
+AF: WA: West Africa
+AF: ZA: South Africa
+AF: DZ: Algeria
+AF: CE: Canary Islands
+AF: NG: Nigeria
+AF: TD: Chad
+AF: CG: Democratic Republic of Congo
+AF: EG: Egypt
+AF: ET: Ethiopia
+AF: CM: Cameroon
+AF: IS: Israel
+AF: LY: Libya
+AF: MG: Madagascar
+AF: MO: Morocco
+AF: BW: Namibia
+AF: SA: Saudi Arabia
+AF: SO: Somalia
+AF: SD: Sudan
+AF: TZ: Tanzania
+AF: TN: Tunisia
+AF: ZM: Zambia
+AF: KE: Kenya
+AF: AO: Angola" | dmenu -r -i -l 50 -p "Select a radar to use as default:" | tr "[:lower:]" "[:upper:]")"
+
+# Set continent code and radar code.
+continentcode=$(echo "$chosen" | sed "s/:.*//")
+radarcode=$(echo "$chosen" | sed "s/..: // ; s/:.*//")
# Sanity check of selection and ensure user did not escape.
-echo "$chosen" | grep -q "^[A-Z]\+$" && echo "$chosen" > "$radarloc" ;}
+echo "$radarcode" | grep -q "^[A-Z]\+$" && printf "%s,%s\\n" "$continentcode" "$radarcode" > "$radarloc" ;}
getdoppler() {
- loc="$(cat "$radarloc")"
+ cont="$(sed "s/,.*//" "$radarloc")"
+ loc="$(cut -c 4- "$radarloc")"
notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
- curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;}
+ if [ "$cont" = "US" ] ; then
+ curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;
+ elif [ "$cont" = "EU" ] ; then
+ curl -sL "https://api.sat24.com/animated/${loc}/rainTMC/2/" > "$doppler" ;
+ elif [ "$cont" = "AF" ] ; then
+ curl -sL "https://api.sat24.com/animated/${loc}/rain/2/" > "$doppler" ;
+ fi
+}
showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}
@@ -198,7 +252,7 @@ case $BLOCK_BUTTON in
showdoppler ;;
2) pickloc && getdoppler && showdoppler ;;
3) notify-send "πŸ—ΊοΈ Doppler RADAR module" "\- Left click for local Doppler RADAR.
-- Middle click to update change RADAR location.
+- Middle click to update RADAR location.
After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet
index ee1a160..94b7da2 100755
--- a/.local/bin/statusbar/sb-internet
+++ b/.local/bin/statusbar/sb-internet
@@ -7,6 +7,7 @@
case $BLOCK_BUTTON in
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
❎: no ethernet
@@ -16,9 +17,10 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
- down) wifiicon="πŸ“‘ " ;;
- up) wifiicon="$(awk '/^\s*w/ { print "πŸ“Ά", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;;
-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)"
+elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
+ 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)"
diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox
index 5a67428..2132184 100755
--- a/.local/bin/statusbar/sb-mailbox
+++ b/.local/bin/statusbar/sb-mailbox
@@ -5,7 +5,7 @@
case $BLOCK_BUTTON in
1) setsid -f "$TERMINAL" -e neomutt ;;
- 2) setsid -f mw sync >/dev/null ;;
+ 2) setsid -f mw -Y >/dev/null ;;
3) notify-send "πŸ“¬ Mail module" "\- Shows unread mail
- Shows πŸ”ƒ if syncing mail
- Left click opens neomutt
diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music
index 7504313..7ea7032 100755
--- a/.local/bin/statusbar/sb-music
+++ b/.local/bin/statusbar/sb-music
@@ -1,6 +1,6 @@
#!/bin/sh
-filter() { mpc | sed "/^volume:/d;s/\\&/&amp;/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d" | paste -sd ' ' -;}
+filter() { mpc | sed "/^volume:/d;s/\\&/&amp;/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;}
pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf
index eb7a73b..178f677 100755
--- a/.local/bin/statusbar/sb-nettraf
+++ b/.local/bin/statusbar/sb-nettraf
@@ -17,7 +17,7 @@ update() {
read -r i < "$arg"
sum=$(( sum + i ))
done
- cache=${XDG_CACHE_HOME:-$HOME/.cache}/${1##*/}
+ cache=/tmp/${1##*/}
[ -f "$cache" ] && read -r old < "$cache" || old=0
printf %d\\n "$sum" > "$cache"
printf %d\\n $(( sum - old ))
@@ -26,4 +26,4 @@ update() {
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) $(numfmt --to=iec $tx)
+printf "πŸ”»%4sB πŸ”Ί%4sB\\n" $(numfmt --to=iec $rx $tx)
diff --git a/.local/bin/statusbar/sb-price b/.local/bin/statusbar/sb-price
index 35b072f..42c84c1 100755
--- a/.local/bin/statusbar/sb-price
+++ b/.local/bin/statusbar/sb-price
@@ -1,19 +1,24 @@
#!/bin/sh
# Usage:
-# price <url> <Name of currency> <icon>
+# price <url> <Name of currency> <icon> <Price to show in>
# price bat "Basic Attention Token" 🦁
# When the name of the currency is multi-word, put it in quotes.
[ -z "$3" ] && exit 1
+
+# use $4 as currency, if not passed in use "usd" as default
+currency="${4:-usd}"
interval="@14d" # History contained in chart preceded by '@' (7d = 7 days)
dir="${XDG_DATA_HOME:-$HOME/.local/share}/crypto-prices"
-pricefile="$dir/$1"
-chartfile="$dir/$1-chart"
+pricefile="$dir/$1-$currency"
+chartfile="$dir/$1-$currency-chart"
-updateprice() { ping -q -c 1 example.org >/dev/null 2>&1 &&
- curl -s "rate.sx/1$1" > "$pricefile" &&
- curl -s "rate.sx/$1$interval" > "$chartfile" ;}
+updateprice() { temp="$(mktemp)"
+ curl -s "$currency.rate.sx/1$1" > "$temp" &&
+ mv -f "$temp" "$pricefile" &&
+ curl -s "$currency.rate.sx/$1$interval" > "$temp" &&
+ mv -f "$temp" "$chartfile" ;}
[ -d "$dir" ] || mkdir -p "$dir"
@@ -35,4 +40,11 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-printf "$3$%0.2f" "$(cat "$pricefile")"
+case "$currency" in
+ usd) symb="$" ;;
+ gbp) symb="Β£" ;;
+ eur) symb="€" ;;
+ btc) symb="β‚Ώ" ;;
+esac
+
+printf "$3$symb%0.2f$after" "$(cat "$pricefile")"
diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume
index 61588c3..3cfdc45 100755
--- a/.local/bin/statusbar/sb-volume
+++ b/.local/bin/statusbar/sb-volume
@@ -19,10 +19,12 @@ vol="$(pamixer --get-volume)"
if [ "$vol" -gt "70" ]; then
icon="πŸ”Š"
-elif [ "$vol" -lt "30" ]; then
+elif [ "$vol" -gt "30" ]; then
+ icon="πŸ”‰"
+elif [ "$vol" -gt "0" ]; then
icon="πŸ”ˆ"
else
- icon="πŸ”‰"
+ echo πŸ”‡ && exit
fi
echo "$icon$vol%"