diff options
| author | Luke Smith <luke@lukesmith.xyz> | 2019-02-02 13:10:43 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-02 13:10:43 -0500 |
| commit | a37aba2078c083fecb9761e5dd6c740cf1414989 (patch) | |
| tree | 3b9e126da9cf874285718c91702fb14501a3faf5 /.scripts/tools | |
| parent | 18378660cae369465f520fb656c64b59dc0c5411 (diff) | |
| parent | 1bffcd12c363064829682e16690430a118d962a4 (diff) | |
| download | eibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.tar.gz eibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.tar.zst eibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.zip | |
Merge branch 'master' into dmenuumount
Diffstat (limited to '.scripts/tools')
| -rwxr-xr-x | .scripts/tools/compiler | 25 | ||||
| -rwxr-xr-x | .scripts/tools/ifinstalled | 2 | ||||
| -rwxr-xr-x | .scripts/tools/qndl | 11 | ||||
| -rwxr-xr-x | .scripts/tools/queueandnotify | 7 | ||||
| -rwxr-xr-x | .scripts/tools/setbg | 2 | ||||
| -rwxr-xr-x | .scripts/tools/transadd | 4 |
6 files changed, 22 insertions, 29 deletions
diff --git a/.scripts/tools/compiler b/.scripts/tools/compiler index cf628aa..7d3bf1d 100755 --- a/.scripts/tools/compiler +++ b/.scripts/tools/compiler @@ -1,21 +1,14 @@ #!/bin/sh - # This script will compile or run another finishing operation on a document. I # have this script run via vim. # -# tex files: Compiles to pdf, including bibliography if necessary -# md files: Compiles to pdf via pandoc -# rmd files: Compiles via R Markdown -# c files: Compiles via whatever compiler is set to cc. Usually gcc. -# py files: runs via python command -# go files: compiles and runs with "go run" -# config.h files: (For suckless utils) recompiles and installs program. -# all others: run `sent` to show a presentation +# Compiles .tex. groff (.mom, .ms), .rmd, .md. +# Opens .sent files as sent presentations. +# Runs scripts based on extention or shebang file=$(readlink -f "$1") dir=$(dirname "$file") base="${file%.*}" -shebang=$(sed -n 1p "$file") cd "$dir" || exit @@ -29,22 +22,16 @@ textype() { \ $command --output-directory="$dir" "$base" } -shebangtest() { - case "$shebang" in - \#\!*) "$file" ;; - *) sent "$file" 2>/dev/null & ;; - esac -} - case "$file" in *\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;; *\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;; *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;; *\.tex) textype "$file" ;; *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;; - *config.h) make && sudo make install ;; + *config.h) sudo make install ;; *\.c) cc "$file" -o "$base" && "$base" ;; *\.py) python "$file" ;; *\.go) go run "$file" ;; - *) shebangtest ;; + *\.sent) setsid sent "$file" 2>/dev/null & ;; + *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; esac diff --git a/.scripts/tools/ifinstalled b/.scripts/tools/ifinstalled index bdbcbc4..bbaaf11 100755 --- a/.scripts/tools/ifinstalled +++ b/.scripts/tools/ifinstalled @@ -1,3 +1,3 @@ #!/bin/sh # If $1 command is not available, error code and notify. -command -v "$1" >/dev/null || { notify-send "$1 is not installed." && exit 1 ;} +command -v "$1" >/dev/null || { notify-send -i "$PIX/larbs.svg" "<b>$1</b> must be installed for this function." && exit 1 ;} diff --git a/.scripts/tools/qndl b/.scripts/tools/qndl new file mode 100755 index 0000000..ffe3647 --- /dev/null +++ b/.scripts/tools/qndl @@ -0,0 +1,11 @@ +#!/bin/sh +# $1 is a url; $2 is a command +[ -z "$1" ] && exit +base="$(basename "$1")" +notify-send -i "$PIX/dl.svg" "Queuing $base..." +cmd="$2" +[ -z "$cmd" ] && cmd="youtube-dl --add-metadata" +idnum="$(tsp $cmd "$1")" +realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" +tsp -D "$idnum" mv "$base" "$realname" +tsp -D "$idnum" notify-send -i "$PIX/check.svg" "$realname done." diff --git a/.scripts/tools/queueandnotify b/.scripts/tools/queueandnotify index 332668f..a1417ec 100755 --- a/.scripts/tools/queueandnotify +++ b/.scripts/tools/queueandnotify @@ -7,12 +7,7 @@ queuefile="$HOME/.local/share/newsboat/queue" while read -r line; do [ -z "$line" ] && continue url="$(echo "$line" | awk '{print $1}')" - base="$(basename "$url")" - notify-send -i "$PIX/dl.png" "Queuing $base..." - idnum="$(tsp curl -LO "$url")" - realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")" - tsp -D "$idnum" mv "$base" "$realname" - tsp -D "$idnum" notify-send -i "$PIX/check.png" "$realname done." + qndl "$url" "curl -LO" done < "$queuefile" echo > "$queuefile" diff --git a/.scripts/tools/setbg b/.scripts/tools/setbg index 00e996a..c9e4a94 100755 --- a/.scripts/tools/setbg +++ b/.scripts/tools/setbg @@ -1,4 +1,4 @@ #!/bin/sh # Sets the background. If given an argument, will set file as background. [ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed." -xwallpaper --center ~/.config/wall.png +xwallpaper --maximize ~/.config/wall.png diff --git a/.scripts/tools/transadd b/.scripts/tools/transadd index 8cc7e80..0ab4784 100755 --- a/.scripts/tools/transadd +++ b/.scripts/tools/transadd @@ -7,6 +7,6 @@ # transmission-daemon sometimes fails to take remote requests in its first # moments. -pgrep -x transmission-da || (transmission-daemon && note "Starting daemon..." "$PIX/dl.png" && sleep 3 && pkill -RTMIN+7 i3blocks) +pgrep -x transmission-da || (transmission-daemon && note "Starting daemon..." "$PIX/dl.svg" && sleep 3 && pkill -RTMIN+7 i3blocks) -transmission-remote -a "$@" && note "Torrent added." "$PIX/dl.png" +transmission-remote -a "$@" && note "Torrent added." "$PIX/dl.svg" |
