updates to Makefile, vim-swap-handler, disp, and nws

This commit is contained in:
randomuser 2022-06-13 16:39:17 -05:00
parent 3751a7d125
commit d8febccf82
4 changed files with 94 additions and 65 deletions

View File

@ -19,6 +19,7 @@ sh:
cp -f sh/proxtest $(DESTDIR)$(PREFIX)/bin
cp -f sh/pco $(DESTDIR)$(PREFIX)/bin
cp -f sh/git-survey $(DESTDIR)$(PREFIX)/bin
cp -f sh/vim-swap-handler $(DESTDIR)$(PREFIX)/bin
mkc:
cc c/scream.c -o c/scream

32
sh/disp
View File

@ -1,29 +1,29 @@
#!/bin/sh
exists() {
xrandr | grep ' connected' | grep "${1}" | wc -l
xrandr | grep ' connected' | grep "${1}" | wc -l
}
if [ $(exists "HDMI-2") -eq 1 ]; then
printf "one"
xrandr --output LVDS-1 --off --auto
xrandr --output VGA-1 --off --auto
bspc monitor -d I II III IV V VI VII VIII IX X
bspc monitor -g 1680x1050+0+0
exit 0
printf "one"
xrandr --output LVDS-1 --off --auto
xrandr --output VGA-1 --off --auto
bspc monitor -d I II III IV V VI VII VIII IX X
bspc monitor -g 1680x1050+0+0
exit 0
fi
if [ $(exists "LVDS-1") -eq 1 ]; then
bspc monitor -d I II III IV V VI VII VIII IX X
bspc monitor LVDS-1 -a I II III IV V VI VII VIII IX
exit 0
bspc monitor -d I II III IV V VI VII VIII IX X
bspc monitor LVDS-1 -a I II III IV V VI VII VIII IX
exit 0
fi
if [ $(exists "HDMI-2") -eq 1 ] && [ $(exists "LVDS-1") -eq 1 ]; then
printf "two"
xrandr --output HDMI-2 --above LVDS-1 --auto
xrandr --output VGA-1 --off --auto
bspc monitor LVDS-1 -a I III V VII IX
bspc monitor HDMI-2 -a II IV VI VIII
exit 0
printf "two"
xrandr --output HDMI-2 --above LVDS-1 --auto
xrandr --output VGA-1 --off --auto
bspc monitor LVDS-1 -a I III V VII IX
bspc monitor HDMI-2 -a II IV VI VIII
exit 0
fi

98
sh/nws
View File

@ -28,74 +28,74 @@ Torify wrapper: export NWS_TORIFY=<command>
"
}
err () {
printf "err: %s\n" ${1}
[ -z "${2}" ] && exit 1
exit ${2}
printf "err: %s\n" ${1}
[ -z "${2}" ] && exit 1
exit ${2}
}
kstrip () {
printf %s "$1" | sed 's/^K\(.*\)/\1/'
printf %s "$1" | sed 's/^K\(.*\)/\1/'
}
national () {
mosaic CONUS-LARGE
mosaic CONUS-LARGE
}
# name interestingly to avoid keyword collision
localradar () {
mosaic ${NWS_ZONE}
mosaic ${NWS_ZONE}
}
mosaic () {
${NWS_GIF} "https://radar.weather.gov/ridge/lite/${1}_loop.gif"
${NWS_GIF} "https://radar.weather.gov/ridge/lite/${1}_loop.gif"
}
setzone () {
printf "%s" "${1}" > ${NWS_CONFIG}
printf "%s" "${1}" > ${NWS_CONFIG}
}
river () {
textmessage "RVA"
textmessage "RVA"
}
weather () {
textmessage "ZFP"
textmessage "ZFP"
}
textmessage () {
curl --silent --fail "https://forecast.weather.gov/product.php?site=NWS&issuedby=$(kstrip ${NWS_ZONE})&product=${1}&format=TXT&version=1" | \
sed -n '/<!-- \/\/ CONTENT STARTS HERE -->/,/<\/pre>/p' | \
grep -v "a href" | \
grep -v '<!-- // CONTENT STARTS HERE -->' | \
grep -v '<\/pre>' || \
printf "${1} data not found for zone %s" ${NWS_ZONE}
curl --silent --fail "https://forecast.weather.gov/product.php?site=NWS&issuedby=$(kstrip ${NWS_ZONE})&product=${1}&format=TXT&version=1" | \
sed -n '/<!-- \/\/ CONTENT STARTS HERE -->/,/<\/pre>/p' | \
grep -v "a href" | \
grep -v '<!-- // CONTENT STARTS HERE -->' | \
grep -v '<\/pre>' || \
printf "${1} data not found for zone %s" ${NWS_ZONE}
}
case $1 in
"n"*)
national
exit 0
;;
"l"*)
localradar
exit 0
;;
"r"*)
river
exit 0
;;
"w"*)
weather
exit 0
;;
"m"*)
[ $# -eq 2 ] && mosaid $2 || \
err "two args required"
;;
"s"*)
[ $# -eq 2 ] && setzone $2 || \
err "two args required"
exit 0
;;
"t"*)
[ $# -eq 2 ] && textmessage $2 || \
err "two args required"
;;
*)
info
exit 0
;;
"n"*)
national
exit 0
;;
"l"*)
localradar
exit 0
;;
"r"*)
river
exit 0
;;
"w"*)
weather
exit 0
;;
"m"*)
[ $# -eq 2 ] && mosaid $2 || \
err "two args required"
;;
"s"*)
[ $# -eq 2 ] && setzone $2 || \
err "two args required"
exit 0
;;
"t"*)
[ $# -eq 2 ] && textmessage $2 || \
err "two args required"
;;
*)
info
exit 0
;;
esac
exit 0

28
sh/vim-swap-handler Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
# when the vim SwapExists autocommand is fired, this script is
# called with the path of the file in question.
# mad props to daniel conway for having this big brain idea
# note to self: protect $1 from expansion as it can contain a
# ~
[ "$#" -eq 0 ] && exit 2
window=$(
xdotool search --name "$1" | \
sed 1q
)
desk=$(
xdotool get_desktop_for_window "$window" 2>/dev/null || printf "none"
)
[ "$desk" = "none" ] && exit 1
desk=$(($desk + 1))
bspc desktop -f "^${desk}"
killall -10 simplestatus
xdotool set_window --urgency 1 "$window"
exit 0