more scripts

This commit is contained in:
Chris Cochrun 2021-08-17 20:40:14 -05:00
parent d25a75a078
commit ea0f4fd844
7 changed files with 301 additions and 0 deletions

7
scripts/cpu-plasma.10s.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
# awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \
# <(rg 'cpu ' /proc/stat) <(sleep 1;rg 'cpu ' /proc/stat)
# echo 100 - $(mpstat | rg all | cut -d \ -f43) | bc
cpu="$(mpstat 1 1 | rg Average | awk '{print $3+$4+$5}' | sed 's/\(.*\)/\1%/g')"
echo "$cpu | color=#5af78e"

206
scripts/doppler Executable file
View file

@ -0,0 +1,206 @@
#!/bin/sh
# Show a Doppler RADAR of an American 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:]")"
# Sanity check of selection and ensure user did not escape.
echo "$chosen" | grep -q "^[A-Z]\+$" && echo "$chosen" > "$radarloc" ;}
getdoppler() {
loc="$(cat "$radarloc")"
notify-send "🌦️ Doppler RADAR" "Pulling most recent Doppler RADAR for $loc."
curl -sL "https://radar.weather.gov/ridge/lite/${loc}_loop.gif" > "$doppler" ;}
showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}
case $BLOCK_BUTTON in
1) [ ! -f "$radarloc" ] && pickloc && getdoppler
[ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
showdoppler ;;
2) pickloc && getdoppler && showdoppler ;;
3) notify-send "🗺️ Doppler RADAR module" "\- Left click for local Doppler RADAR.
- Middle click to update change RADAR location.
After $secs seconds, new clicks will also automatically update the doppler RADAR." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
echo 🗺️

10
scripts/mem-plasma.3s.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# Get the percentage of used memory and print it
read used total <<< $(free -m | awk '/Mem/{printf $2" "$3}')
percent=$(bc -l <<< "100 * $total / $used")
mem=$(awk -v u=$used -v t=$total -v p=$percent 'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}'| awk '{printf $2}')
echo "$mem | color=#ff9f43"

4
scripts/muunread-plasma.2s.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
muunread="$(mu find flag:unread AND NOT flag:trashed AND NOT maildir:\"/outlook/Junk\" AND NOT maildir:\"/office/Junk Email\" AND NOT maildir:\"/outlook/Deleted\" AND NOT maildir:\"/office/Deleted Items\" | wc -l)"
echo "$muunread | color=#f3f99d"

56
scripts/wlrofi-rbw Executable file
View file

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Very basic interface for rbw using rofi
# Get all password files and create an array
CACHE=~/.local/tmp/pass_rofi
seat=seat0
list_passwords() {
rbw list
}
prompt='search for passwords...'
SECRET=$(list_passwords | rofi -i -p="${prompt}" -dmenu)
# Ask whether pass, user or both are required
options=("Password" \
"User" \
"User and password" \
"QR-Code" \
"OTP")
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="...")
# echo $option
case ${option} in
Password )
# echo "${SECRET}"
wtype $(rbw get "${SECRET}")
;;
User )
wtype $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
;;
"User and password" )
wtype $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}')
wtype -k TAB
wtype $(rbw get "${SECRET}")
;;
"QR-Code" )
if [[ $SECRET =~ wifi$ ]]; then
# Produce a valid wifi QR-code
WIFISSID=$(pass get_user ${SECRET})
WIFIPASS=$(pass get_pass ${SECRET})
WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
else
# Only password
pass show -q1 ${SECRET}
fi
;;
"OTP" )
wtype $(rbw code ${SECRET})
;;
esac
# wl-copy -o -s ${seat} ${PASSWD_PASS}

View file

@ -0,0 +1,8 @@
[Unit]
Description=lolcate updater
[Service]
ExecStart=lolcate --update
[Install]
WantedBy=default.target

View file

@ -0,0 +1,10 @@
[Unit]
Description=run lolcate updater every 20min
[Timer]
OnBootSec=1min
OnUnitActiveSec=20min
[Install]
WantedBy=timers.target