diff options
-rwxr-xr-x | .config/herbstluftwm/autostart | 6 | ||||
-rwxr-xr-x | .config/herbstluftwm/panel.sh | 29 | ||||
-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 | ||||
-rw-r--r-- | .config/init/gen-urxvt-theme.sh | 5 | ||||
-rw-r--r-- | .config/init/gen-userChrome.sh | 8 | ||||
-rw-r--r-- | .config/init/gen-zathurarc.sh | 2 | ||||
-rw-r--r-- | .config/init/vars | 65 | ||||
-rw-r--r-- | .config/pms/rc | 5 | ||||
-rw-r--r-- | .config/ranger/rifle.conf | 30 | ||||
-rwxr-xr-x | .config/sxiv/exec/key-handler | 27 | ||||
-rw-r--r-- | .vimrc | 2 | ||||
-rw-r--r-- | .zprofile | 7 | ||||
-rw-r--r-- | .zshrc-linux-desktop | 188 |
15 files changed, 306 insertions, 138 deletions
diff --git a/.config/herbstluftwm/autostart b/.config/herbstluftwm/autostart index 890f9c4..021df77 100755 --- a/.config/herbstluftwm/autostart +++ b/.config/herbstluftwm/autostart @@ -2,10 +2,6 @@ source ~/.config/init/vars -hc() { - herbstclient "$@" -} - # always start frames max (pt. 1) hc set default_frame_layout 2 hc set_layout max @@ -215,5 +211,5 @@ pkill dunst dunst -lb $bg_normal -nb $bg_normal -cb $bg_focus \ -lf $fg_normal -nf $fg_normal -cf $fg_focus \ -frame_color $bg_focus -geom "0x3-4+$(($bheight + 4))" \ - -fn "$ttfont $ttfont_size,$jfont $jfont_size" + -fn "$mfont $mfont_size,$jfont $jfont_size" diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh index 4b7c1a0..78f7d7b 100755 --- a/.config/herbstluftwm/panel.sh +++ b/.config/herbstluftwm/panel.sh @@ -4,7 +4,6 @@ # SETUP # ########### -hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} monitor=${1:-0} geometry=( $(herbstclient monitor_rect "$monitor") ) if [ -z "$geometry" ] ;then @@ -67,9 +66,10 @@ update_taglist() { -e '$d' \ -e 's/\(.*\)/\1 /' \ -e 's/:/ /' \ - -e "s/[#+\-%]\(.*\)/%{B${bg_focus} F${fg_focus}} \1%{B${bg_normal} F${fg_normal}}/" \ - -e "s/!\(.*\)/%{B${bg_urgent} F${fg_urgent}} \1%{B${bg_normal} F${fg_normal}}/" \ - -e "s/\.\(.*\)/%{B${bg_normal} F${light_black}} \1%{B${bg_normal} F${fg_normal}}/" \ + -e "s/^[-%]\(.*\)/%{B${light_black} F${fg_normal}} \1%{B${bg_normal} F${fg_normal}}/" \ + -e "s/^[#+]\(.*\)/%{B${bg_focus} F${fg_focus}} \1%{B${bg_normal} F${fg_normal}}/" \ + -e "s/^!\(.*\)/%{B${bg_urgent} F${fg_urgent}} \1%{B${bg_normal} F${fg_normal}}/" \ + -e "s/^\.\(.*\)/%{B${bg_normal} F${light_black}} \1%{B${bg_normal} F${fg_normal}}/" \ | tr -d '\n' echo "$sep" } @@ -96,7 +96,13 @@ update_winlist() { else echo -n "%{B${bg_normal} F${fg_normal}} " fi - echo -n "${line[@]:3}" | sed -r 's/(.{40}).*/\1\.\.\./' + { + if [[ -z "${line[@]:3}" ]]; then + echo -n "(has no name)" + else + echo -n "${line[@]:3}" + fi + } | sed -r 's/(.{40})...*/\1\.\.\./' echo -n " " done echo -n "%{B${bg_normal} F${fg_normal}}" @@ -198,13 +204,9 @@ event_when() { { event_tick & - echo -e "child\t$!" event_stats & - echo -e "child\t$!" event_when & - echo -e "child\t$!" event_mpd & - echo -e "child\t$!" hc --idle } 2> /dev/null | { @@ -280,15 +282,8 @@ event_when() { fields[2]=$(update_winlist) ;; - # append children to kill list - child) - child[((${#child[@]}+1))]=event[1] - ;; - quit_panel|reload) - for id in ${child[@]}; do - kill $id - done + kill -- -$$ exit ;; 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 diff --git a/.config/init/gen-urxvt-theme.sh b/.config/init/gen-urxvt-theme.sh index ba11d71..40e986b 100644 --- a/.config/init/gen-urxvt-theme.sh +++ b/.config/init/gen-urxvt-theme.sh @@ -42,8 +42,9 @@ URxvt*color15: $light_white # Select the fonts to be used. This is a comma separated list of font names that are checked in order when trying to find glyphs for characters. The first font echo -n "URxvt*font: " -echo -n "xft:${ttfont}:size=${ttfont_size}, " -echo "xft:${jfont}:size=${jfont_size}" +echo -n "xft:${mfont}:size=${mfont_size}, " +echo -n "xft:${jfont}:size=${jfont_size}, " +echo "xft:${bkfont}:size=${bkfont_size}" } > /tmp/urxvt-theme diff --git a/.config/init/gen-userChrome.sh b/.config/init/gen-userChrome.sh index ed5f1f2..14b3dec 100644 --- a/.config/init/gen-userChrome.sh +++ b/.config/init/gen-userChrome.sh @@ -25,15 +25,15 @@ echo "\ .tabbrowser-tab { background: ${bg_normal} !important; color: ${fg_normal} !important; - font-family: \"${ttfont}\" !important; - font-size: ${ttfont_size}pt !important; + font-family: \"${mfont}\" !important; + font-size: ${mfont_size}pt !important; } .tabbrowser-tab[selected] { background: ${bg_focus} !important; color: ${fg_focus} !important; - font-family: \"${ttfont}\" !important; - font-size: ${ttfont_size}pt !important; + font-family: \"${mfont}\" !important; + font-size: ${mfont_size}pt !important; } " > /tmp/userChrome.css diff --git a/.config/init/gen-zathurarc.sh b/.config/init/gen-zathurarc.sh index 9e577b5..6ef7b7b 100644 --- a/.config/init/gen-zathurarc.sh +++ b/.config/init/gen-zathurarc.sh @@ -1,7 +1,7 @@ { echo "\ -set font \"$ttfont $ttfont_size\" +set font \"$mfont $mfont_size\" set highlight-color \"$bg_normal\" set highlight-active-color \"$bg_focus\" diff --git a/.config/init/vars b/.config/init/vars index beda3de..32dd1d2 100644 --- a/.config/init/vars +++ b/.config/init/vars @@ -1,24 +1,3 @@ -############# -# general # -############# - -bheight=20 - -ifont='-*-stlarch-medium-r-*-*-*-*-*-*-*-*-*-*' -ifont_off='-2' - -bfont='Droid Sans Mono' -bfont_size='9' -bfont_off='-1' - -jfont='Togoshi Mono' -jfont_size='10' -jfont_off='0' - - -ttfont='Droid Sans Mono' -ttfont_size='10' - ############ # themes # ############ @@ -88,7 +67,7 @@ wallpaper='kuvshinov-ilya.png' std_black='#262626' std_red='#ed4047' -std_green='#6fbf6d' +std_green='#72c76f' std_yellow='#f0b73d' std_blue='#0075a6' std_magenta='#d95784' @@ -110,3 +89,45 @@ bg_focus="$std_magenta" fg_focus="$light_white" bg_urgent="$std_red" fg_urgent="$light_white" + + +############### +# misc vars # +############### + +bheight=20 + +# icon font +ifont='-*-stlarch-medium-r-*-*-*-*-*-*-*-*-*-*' +ifont_off='-2' + +# bar font +bfont='Droid Sans Mono' +bfont_size='9' +bfont_off='-1' + +# jp font +jfont='Togoshi Mono' +jfont_size='10' +jfont_off='0' + +# backup font +bkfont='Noto Sans' +bkfont_size='10' +bkfont_off='0' + +# main font +mfont='Droid Sans Mono' +mfont_size='10' +dmenu_args=( -fn "${bfont}:size=${bfont_size}" -h "$bheight" + -nb "$bg_normal" -nf "$fg_normal" -sb "$bg_focus" + -sf "$fg_focus" ) + + +############### +# functions # +############### +hc() { + herbstclient "$@" +} + diff --git a/.config/pms/rc b/.config/pms/rc index 78be0e7..88790ae 100644 --- a/.config/pms/rc +++ b/.config/pms/rc @@ -1,7 +1,7 @@ set startuplist=Library -set scroll=centered -set sort=track disc album +set scroll=centred +set sort=track album set ignorecase set noregexsearch @@ -13,6 +13,7 @@ unmap h unmap l unmap F12 map l play +map p toggle-play map > next map < prev map ^N next diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf index 8cdb0b5..b1bea0d 100644 --- a/.config/ranger/rifle.conf +++ b/.config/ranger/rifle.conf @@ -21,6 +21,7 @@ # name <regexp> | The regexp matches the basename of $1 # path <regexp> | The regexp matches the absolute path of $1 # has <program> | The program is installed (i.e. located in $PATH) +# env <variable> | The environment variable "variable" is non-empty # file | $1 is a file # directory | $1 is a directory # number <n> | change the number of this command to n @@ -65,9 +66,11 @@ mime ^text, has urxvt, X, flag f = "urxvt" "-e" "$EDITOR" "$@" ext x?html?, has surf, X, flag f = surf -- file://"$1" ext x?html?, has vimprobable, X, flag f = vimprobable -- "$@" ext x?html?, has vimprobable2, X, flag f = vimprobable2 -- "$@" +ext x?html?, has dwb, X, flag f = dwb -- "$@" ext x?html?, has jumanji, X, flag f = jumanji -- "$@" ext x?html?, has luakit, X, flag f = luakit -- "$@" ext x?html?, has uzbl, X, flag f = uzbl -- "$@" +ext x?html?, has uzbl-tabbed, X, flag f = uzbl-tabbed -- "$@" ext x?html?, has uzbl-browser, X, flag f = uzbl-browser -- "$@" ext x?html?, has uzbl-core, X, flag f = uzbl-core -- "$@" ext x?html?, has firefox, X, flag f = firefox -- "$@" @@ -94,6 +97,7 @@ name ^[mM]akefile$ = make clean ext py = python -- "$1" ext pl = perl -- "$1" ext rb = ruby -- "$1" +ext js = node -- "$1" ext sh = sh -- "$1" ext php = php -- "$1" @@ -112,15 +116,8 @@ mime ^video|audio, has vlc, X, flag f = vlc -- "$@" #-------------------------------------------- # Video without X: #------------------------------------------- -mime ^video, terminal, !X, has mpv = mplayer -- "$@" +mime ^video, terminal, !X, has mpv = mpv -- "$@" -#------------------------------------------- -# Image Viewing: -#------------------------------------------- -ext svg, has inkscape, X, flag f = inkscape -- "$@" -mime ^image, has sxiv, X, flag f = sxiv -a "$@" -mime ^image, has gimp, X, flag f = gimp -- "$@" -ext xcf, X, flag f = gimp -- "$@" #------------------------------------------- # Documents @@ -136,6 +133,14 @@ ext sxc|xlsx?|xlt|xlw|gnm|gnumeric, has kspread, X, fla ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric|rtf, has libreoffice, X, flag f = libreoffice "$@" #------------------------------------------- +# Image Viewing: +#------------------------------------------- +mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" +mime ^image, has sxiv, X, flag f = sxiv -a "$@" +mime ^image, has gimp, X, flag f = gimp -- "$@" +ext xcf, X, flag f = gimp -- "$@" + +#------------------------------------------- # Archives #------------------------------------------- # This requires atool @@ -163,9 +168,12 @@ ext 8xp|8xk|8xv|8xu, has tilp = tilp --no-gui "$@" #------------------------------------------- # Roms #------------------------------------------- -ext s[wmf]c, has snes9x-gtk, X flag f = snes9x-gtk "$1" -ext nes|gb|gb[ca], has mednafen, X, flag f = mednafen "$1" +ext nes|gb|gb[ca]|s[wmf]c, has mednafen, X, flag f = mednafen "$1" -# Define the editor for non-text files as last action +# Define the editor for non-text label editor, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@" label editor, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php, has urxvt, X, flag f = "urxvt" "-e" "$EDITOR" "$@" + +# Send to server & copy to clipboard +has send, X, flag f = send "$@" + diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 6668c36..7b5b3d1 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -11,7 +11,6 @@ while read line; do files=( "${files[@]}" "$line" ) done - if [[ "${#files[@]}" -eq 1 ]]; then case "$1" in "y") @@ -31,26 +30,12 @@ case "$1" in "C-d") rm "${files[@]}" ;; "g") gimp "${files[@]}" & ;; "s") - for file in "${files[@]}"; do - scp "$file" shmibbles.me:http/tmp/ - basename=$(basename $file) - if [[ $? -ne 0 ]]; then - notify-send "uploading $basename to /tmp/ failed" - else - ssh shmibbles.me "cd http/tmp; chmod o+r '$basename'" - name=$(echo "https://shmibbles.me/tmp/$basename"\ - | sed -e 's/ /%20/g' -e 's/?/%3f/g') - echo $name | tr -d '\n' | xclip -i -selection clipboard - echo $name | tr -d '\n' | xclip -i -selection primary - notify-send "uploaded $basename to /tmp/" - fi - done - ;; - "n") - for file in "${files[@]}"; do - notify-send "$file" - done - notify-send "${#files[@]}" + send "${files[@]}" + if [[ $? -ne 0 ]]; then + notify-send "sxiv: send to /tmp/ failed" + else + notify-send "sxiv: sent to /tmp/" + fi ;; *) notify-send "sxiv: command not recognised" ;; @@ -93,7 +93,7 @@ function! s:Lightline_palette_init() let l:p.normal.error = [ [ l:white, l:red ] ] let l:p.normal.warning = [ [ l:white, l:yellow ] ] -let g:lightline#colorscheme#shmibs#palette = lightline#colorscheme#flatten(l:p) + let g:lightline#colorscheme#shmibs#palette = lightline#colorscheme#flatten(l:p) let g:lightline = { 'colorscheme': 'shmibs' } endfunction @@ -2,7 +2,10 @@ emulate sh -c 'source /etc/profile' export QT_STYLE_OVERRIDE=gtk +########## MAKE USER FUNCS AVAILABLE ########## +[[ -d ~/.config/init/funcs/ ]] && \ + PATH="$PATH:$HOME/.config/init/funcs" + ############# CONNECTING OVER SSH ############# -if [[ -a ~/.zprofile-dtach ]]; then +[[ -f ~/.zprofile-dtach ]] && \ source ~/.zprofile-dtach -fi diff --git a/.zshrc-linux-desktop b/.zshrc-linux-desktop index ae5d9e7..9a16304 100644 --- a/.zshrc-linux-desktop +++ b/.zshrc-linux-desktop @@ -11,32 +11,6 @@ alias vumount='udevil umount' ################## FUNCTIONS ################## -# power off after finishing mpd playlist -mpd-sleep() { - mpc play - while true; do - mpc status - mpc idle player - if [[ -z "$(mpc status | grep playing)" ]]; then - poweroff - fi - done -} - -# 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 -mpd-cover-convert() { - local d - find ~/music -type f -regextype posix-extended -regex ".*cover\.(png|jpg)"\ - | while read file; do - d=$(dirname "$file") - if [[ ! -f "$d/cover-small.png" ]]; then - convert "$file" -resize 250x "$d/cover-small.png" - fi - done -} - # list stats about mpd library file types, to motivate me # to do better! mpd-filetypes() { @@ -149,28 +123,6 @@ scap() { -c:v libvpx -b:v 4M -threads 4 /tmp/out.webm > /dev/null 2>&1 } -# quickly send a file to hosted tmp dir -send() { - local name - local basename - if [[ "$1" ]]; then - scp $@ shmibbles.me:http/tmp/ - if [[ $? -eq 0 ]]; then - for name in "$@" - do - basename=$(basename $name) - ssh shmibbles.me "cd http/tmp; chmod o+r '$basename'" - name=$(echo "https://shmibbles.me/tmp/$basename"\ - | sed -e 's/ /%20/g' -e 's/?/%3f/g') - echo $name | tr -d '\n' | xclip -i -selection clipboard - echo $name | tr -d '\n' | xclip -i -selection primary - done - fi - else - echo "specify at least one file to send" - fi -} - # take a screenshot, upload to /img/scrot, and update current symlink ssh-scrot() { archey3 @@ -218,8 +170,7 @@ ssh-scrot() { } -# export a section of a video to gif -make-gif() { +make-gif-old() { if [[ -z "$1" ]]; then break @@ -292,6 +243,143 @@ make-gif() { rm -f make-gif-in } +# export a section of a video to gif +make-gif() { + + local i + + local infile="" + local outfile="out.gif" + local start="00:00:00" + local t="" + local length="" + local fps="10" + typeset -i fps + local width="480" + typeset -i width + local subs="n" + + # parse args + local assign=false + local assignopt="" + local interact=true + for i in "$@"; do + if [[ $assign ]]; then + assign=false + case $assignopt in + # output + -o) outfile="$i" ;; + # start + -s) start="$i" ;; + # length + -l) t="-t"; length="$i" ;; + # fps + -f) fps="$i" ;; + # width + -w) width="$i" ;; + # subs? + -t) subs="y" ;; + *) + >&2 echo "err: unrecognised option" + return + ;; + esac + else + case $i in + -*) + assign=true + assignopt="$i" + interact=false + ;; + *) + if [[ -z "$infile" ]]; then + infile="$i" + else + >&2 echo "err: multiple inputs specified" + return + fi + ;; + esac + fi + done + + if [[ $assign ]]; then + >&2 echo "err: malformed arg" + return + fi + + if [[ -z "$infile" ]]; then + >&2 echo "err: no input specified" + return + fi + + # interactive prompting + if [[ $interact ]]; then + read "i?start [00:00:00]: " + if [[ "$i" ]]; then + start="$i" + fi + + read "i?length [full]: " + if [[ "$i" ]]; then + t="-t" + length="$i" + fi + + read "i?fps [10]: " + if [[ "$i" ]]; then + fps="$i" + fi + + read "i?width [480]: " + if [[ "$i" ]]; then + width="$i" + fi + + read -q "subs?use subtitles? [y/N]: " + >&2 echo -e "\n" + + read "i?write to: " + if [[ "$i" ]]; then + outfile="$i" + fi + fi + + rm -f make-gif-palette.png + rm -f make-gif-palette.png + rm -f make-gif-in + + ln -s "$infile" make-gif-in + + >&2 echo "converting..." + + if [[ "$subs" == "y" ]]; then + ffmpeg -loglevel 0 -y -ss "$start" $t "$length" -i "$infile" \ + -copyts -vf "subtitles=make-gif-in,fps=$fps,scale=$width:-1:flags=lanczos,palettegen" make-gif-palette.png + ffmpeg -loglevel 0 -ss "$start" $t "$length" -i "$infile" -i make-gif-palette.png \ + -copyts -filter_complex \ + "subtitles=make-gif-in,fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" \ + make-gif-out + else + ffmpeg -loglevel 0 -y -ss "$start" $t "$length" -i "$infile" \ + -vf "fps=$fps,scale=$width:-1:flags=lanczos,palettegen" make-gif-palette.png + ffmpeg -loglevel 0 -ss "$start" $t "$length" -i "$infile" -i make-gif-palette.png -filter_complex \ + "fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" \ + make-gif-out + fi + + >&2 echo "optimising..." + + rm -f make-gif-palette.png + rm -f make-gif-in + + gifsicle -O3 -o "$outfile" make-gif-out + + rm -f make-gif-out + + >&2 echo "done!" +} + # um... fuck() { local fuck="fuck" |