diff options
author | katherine <shmibs@shmibbles.me> | 2016-03-19 22:17:28 -0700 |
---|---|---|
committer | katherine <shmibs@shmibbles.me> | 2016-03-19 22:17:28 -0700 |
commit | e92af1f7088cc5b6b40a5ceba275a197c305de62 (patch) | |
tree | 5d92832f1ecdaff44ca61a15f3c3d11b49fb2d79 /.config/init/funcs | |
parent | b351865a2b3678708d70c6e088c70ae8f7fd923f (diff) | |
download | dotfiles-e92af1f7088cc5b6b40a5ceba275a197c305de62.tar.gz |
snapshot
lots of random things changed; forgot to update for a while again.
moving things to .config/init/funcs is one important thing; means
being able to use those shell scripts anywhere, like ranger or whatever
Diffstat (limited to '.config/init/funcs')
-rwxr-xr-x | .config/init/funcs/mpd-cover-convert | 12 | ||||
-rwxr-xr-x | .config/init/funcs/mpd-sleep | 10 | ||||
-rwxr-xr-x | .config/init/funcs/send | 48 |
3 files changed, 70 insertions, 0 deletions
diff --git a/.config/init/funcs/mpd-cover-convert b/.config/init/funcs/mpd-cover-convert new file mode 100755 index 0000000..cd3569a --- /dev/null +++ b/.config/init/funcs/mpd-cover-convert @@ -0,0 +1,12 @@ +#!/bin/zsh +# make small cover versions for mpc-notify.sh +# leaks memory for some reason, so don't run on a clean library +# or it'll crash everything + +local d +find ~/music -type f -regextype posix-extended -regex ".*cover\.(png|jpg)"\ + | while read file; do + if [[ ! -f "${file:h}/cover-small.png" ]]; then + convert "$file" -resize 250x "${file:h}/cover-small.png" + fi +done diff --git a/.config/init/funcs/mpd-sleep b/.config/init/funcs/mpd-sleep new file mode 100755 index 0000000..c01d734 --- /dev/null +++ b/.config/init/funcs/mpd-sleep @@ -0,0 +1,10 @@ +#!/bin/zsh + +# power off after finishing mpd playlist +mpc play > /dev/null +while true; do + mpc idle player > /dev/null || return 1 + if [[ -z "$(mpc status | grep playing)" ]]; then + poweroff + fi +done diff --git a/.config/init/funcs/send b/.config/init/funcs/send new file mode 100755 index 0000000..88b3dbb --- /dev/null +++ b/.config/init/funcs/send @@ -0,0 +1,48 @@ +#!/bin/zsh +# quickly send a file to hosted tmp dir + +local name +local basename +local escapes +typeset -A escapes +escapes=(' ' '%20' '"' '%22' '#' '%23' '$' '%24' + '%' '%25' '&' '%26' "'" '%27' '+' '%2b' + ',' '%2c' '/' '%2f' ':' '%3a' ';' '%3b' + '<' '%3c' '=' '%3d' '>' '%3e' '?' '%3f' + '@' '%40' '[' '%5b' '\' '%5c' ']' '%5d' + '^' '%5e' '`' '%60' '{' '%7b' '|' '%7c' + '}' '%7d' '~' '%7e') +if [[ "$1" ]]; then + for i in "$@"; do + [[ -f "$i" ]] \ + || { echo "file '$i' not found"; return 1 } + done + scp "$@" shmibbles.me:http/tmp/ >/dev/null 2>&1 \ + || { echo "sending files failed"; return 1 } + if [[ $? -eq 0 ]]; then + for name in "$@" + do + basename=${name:t} + ssh shmibbles.me "cd http/tmp; chmod o+r \"${basename//\"/\\\"}\"" + if [[ $? -eq 0 ]]; then + { + printf "%s" 'https://shmibbles.me/tmp/' + for c in "${(s::)basename}"; do + if [[ "${escapes[$c]}" == "" ]]; then + printf "%s" "$c" + else + printf "%s" "${escapes[$c]}" + fi + done + } | tee >(xclip -i -selection clipboard) \ + | xclip -i -selection primary + else + echo "making '$name' readable failed" + return 1 + fi + done + fi +else + echo "specify at least one file to send" + return 1 +fi |