From 6efc27037aee345cee975805f2aacac66f6da2ce Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Sat, 1 Dec 2018 14:34:14 -0500 Subject: [PATCH] let a thousand autistic tweaks bloom --- .scripts/i3cmds/bottomleft | 9 ++++----- .scripts/i3cmds/camtoggle | 2 +- .scripts/i3cmds/ddspawn | 1 - .scripts/i3cmds/displayselect | 2 -- .scripts/i3cmds/samedir | 14 +++++++------- .scripts/i3cmds/showclip | 1 - .scripts/i3cmds/winresize | 2 +- .scripts/tools/getbib | 20 +++++++++++++------- .scripts/tools/lmc | 4 ++-- .scripts/tools/speedvid | 7 ------- .scripts/tools/texclear | 16 +++++++++------- 11 files changed, 37 insertions(+), 41 deletions(-) delete mode 100755 .scripts/tools/speedvid diff --git a/.scripts/i3cmds/bottomleft b/.scripts/i3cmds/bottomleft index 5f05beb..be12b63 100755 --- a/.scripts/i3cmds/bottomleft +++ b/.scripts/i3cmds/bottomleft @@ -1,7 +1,6 @@ -#!/bin/bash +#!/bin/sh # This script move the selected window to the bottom left of the screen. - current=$(xdotool getwindowfocus) # The window will take up no more than a third of @@ -9,9 +8,9 @@ current=$(xdotool getwindowfocus) newwidth=$(($(xdotool getdisplaygeometry | awk '{print $2}') / 3)) newheight=$(($(xdotool getdisplaygeometry | awk '{print $1}') / 3)) -xdotool windowsize $(xdotool getwindowfocus) $newheight $newwidth +xdotool windowsize "$(xdotool getwindowfocus)" $newheight $newwidth -newsize=$(xdotool getwindowgeometry $(xdotool getwindowfocus) | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') +newsize=$(xdotool getwindowgeometry "$(xdotool getwindowfocus)" | grep Geometry | sed -e 's/x/ /g' | awk '{print $3}') height=$(($(xdotool getdisplaygeometry | awk '{print $2}') - newsize)) -xdotool windowmove $current 0 $height +xdotool windowmove "$current" 0 $height diff --git a/.scripts/i3cmds/camtoggle b/.scripts/i3cmds/camtoggle index 1e39dec..05679c0 100755 --- a/.scripts/i3cmds/camtoggle +++ b/.scripts/i3cmds/camtoggle @@ -1,2 +1,2 @@ -#!/bin/bash +#!/bin/sh pkill -f /dev/video || mpv --no-osc --no-input-default-bindings --input-conf=/dev/null --geometry=-0-0 --autofit=30% --title="mpvfloat" /dev/video0 diff --git a/.scripts/i3cmds/ddspawn b/.scripts/i3cmds/ddspawn index aedcd18..0871a59 100755 --- a/.scripts/i3cmds/ddspawn +++ b/.scripts/i3cmds/ddspawn @@ -12,7 +12,6 @@ # bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24 # Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font) - [ -z "$1" ] && exit if xwininfo -tree -root | grep "(\"$1\" "; diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect index e36d214..a8cf2f5 100755 --- a/.scripts/i3cmds/displayselect +++ b/.scripts/i3cmds/displayselect @@ -43,7 +43,5 @@ esac # Fix feh background if screen size/arangement has changed. feh --bg-scale "$HOME/.config/wall.png" -# Polybar users will want to uncomment this line, which reactivates polybar on all new displays: -#polybar_launch # Re-remap keys if keyboard added (for laptop bases) remaps diff --git a/.scripts/i3cmds/samedir b/.scripts/i3cmds/samedir index 1bc1701..7d65838 100755 --- a/.scripts/i3cmds/samedir +++ b/.scripts/i3cmds/samedir @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152 CMD=$TERMINAL @@ -8,20 +8,20 @@ CWD='' ID=$(xdpyinfo | grep focus | cut -f4 -d " ") # Get PID of process whose window this is -PID=$(xprop -id $ID | grep -m 1 PID | cut -d " " -f 3) +PID=$(xprop -id "$ID" | grep -m 1 PID | cut -d " " -f 3) # Get last child process (shell, vim, etc) if [ -n "$PID" ]; then - TREE=$(pstree -lpA $PID | tail -n 1) - PID=$(echo $TREE | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') + TREE=$(pstree -lpA "$PID" | tail -n 1) + PID=$(echo "$TREE" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g') # If we find the working directory, run the command in that directory if [ -e "/proc/$PID/cwd" ]; then - CWD=$(readlink /proc/$PID/cwd) + CWD=$(readlink /proc/"$PID"/cwd) fi fi if [ -n "$CWD" ]; then - cd $CWD && $CMD + cd "$CWD" && "$CMD" else - $CMD + "$CMD" fi diff --git a/.scripts/i3cmds/showclip b/.scripts/i3cmds/showclip index f34addc..7b3aeee 100755 --- a/.scripts/i3cmds/showclip +++ b/.scripts/i3cmds/showclip @@ -7,7 +7,6 @@ clip=$(xclip -o -selection clipboard) - prim=$(xclip -o -selection primary) [ "$prim" != "" ] && notify-send "Clipboard: diff --git a/.scripts/i3cmds/winresize b/.scripts/i3cmds/winresize index df4b75c..090bbf3 100755 --- a/.scripts/i3cmds/winresize +++ b/.scripts/i3cmds/winresize @@ -1,2 +1,2 @@ #!/bin/sh -echo | dmenu -p "Give width and height:" | xargs xdotool windowsize "$(xdotool getwindowfocus)" +echo "📐" | dmenu -p "Give width and height:" | xargs xdotool windowsize "$(xdotool getwindowfocus)" diff --git a/.scripts/tools/getbib b/.scripts/tools/getbib index 0ea30d3..bf02694 100755 --- a/.scripts/tools/getbib +++ b/.scripts/tools/getbib @@ -1,15 +1,21 @@ -#!/bin/bash +#!/bin/sh # Give this script a .pdf and it will attempt # to return a proper .bib citation via doi. # Internet connection required. -# Get the doi from metadata, if not possible, get -# doi from pdftotext output, if not possible, exit. -doi=$(pdfinfo "$1" | grep -o doi:.*) || - doi=$(pdftotext "$1" - | grep -o doi.* -m 1) || +if [ -f "$1" ]; +then + # Get the doi from metadata, if not possible, get + # doi from pdftotext output, if not possible, exit. + doi=$(pdfinfo "$1" | grep -io "doi:.*") || + doi=$(pdftotext "$1" 2>/dev/null - | grep -o "doi:.*" -m 1) || exit 1 +else + # If not given file, assume argument is doi + doi="$1" +fi # Check crossref.org for the bib citation. -curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\n" | - sed -e "/^[^\(\t\|@\|}\)]/d" +curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n" | + sed -e "/^[^\\(\\t\\|@\\|}\\)]/d" diff --git a/.scripts/tools/lmc b/.scripts/tools/lmc index 9c92f3f..45cfcd9 100755 --- a/.scripts/tools/lmc +++ b/.scripts/tools/lmc @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # A general audio interface for LARBS. @@ -18,7 +18,7 @@ case "$1" in p*) mpc pause ; pauseallmpv ;; f*) mpc seek +"$num" ;; b*) mpc seek -"$num" ;; - r*) mpc seek 0\% ;; + r*) mpc seek 0% ;; *) cat << EOF lmc: cli music interface for mpd and pulse for those with divine intellect too grand to remember the mpc/pamixer commands. diff --git a/.scripts/tools/speedvid b/.scripts/tools/speedvid deleted file mode 100755 index ba3a4f6..0000000 --- a/.scripts/tools/speedvid +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -base=$(basename $1) -ext="${base##*.}" -base="${base%.*}" - -ffmpeg -i $1 -vf "setpts=$2*PTS" -an $base'_sped.'$ext diff --git a/.scripts/tools/texclear b/.scripts/tools/texclear index 0e08f1d..20f435c 100755 --- a/.scripts/tools/texclear +++ b/.scripts/tools/texclear @@ -1,12 +1,14 @@ -#!/bin/bash +#!/bin/sh # Clears the build files of a LaTeX/XeLaTeX build. # I have vim run this file whenever I exit a .tex file. -[[ "$1" == *.tex ]] || exit +case "$1" in + *.tex) + file=$(readlink -f "$1") + dir=$(dirname "$file") + base="${file%.*}" + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;; + *) printf "Give .tex file as argument.\\n" ;; +esac -file=$(readlink -f "$1") -dir=$(dirname "$file") -base="${file%.*}" - -find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\(busy\)|lof|nav|out|snm|toc|bcf|run\.xml|synctex\.gz|blg|bbl)" -delete