diff --git a/Makefile b/Makefile index 6aea880..663ac4d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/sh/disp b/sh/disp index 784a7fd..9222e02 100755 --- a/sh/disp +++ b/sh/disp @@ -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 diff --git a/sh/nws b/sh/nws index e2e9531..b0f415e 100755 --- a/sh/nws +++ b/sh/nws @@ -28,74 +28,74 @@ Torify wrapper: export NWS_TORIFY= " } 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 '//,/<\/pre>/p' | \ - grep -v "a href" | \ - grep -v '' | \ - 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 '//,/<\/pre>/p' | \ + grep -v "a href" | \ + grep -v '' | \ + 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 diff --git a/sh/vim-swap-handler b/sh/vim-swap-handler new file mode 100755 index 0000000..bf39d6c --- /dev/null +++ b/sh/vim-swap-handler @@ -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