dotfiles

My collection of dotfiles
git clone git://git.noxz.tech/dotfiles
Log | Files | Refs

key-handler (1345B)


      1 #!/bin/sh
      2 
      3 while read file; do
      4     path="$(readlink -f "$file")"
      5     case "$1" in
      6  
      7     # set as wallpaper
      8     'w')
      9         if [ "${path#*.ff.gz}" != "$path" ]; then
     10             cp "$path" "$XDG_CONFIG_HOME/wallpaper.ff.gz"
     11         else
     12             tmpfile="$(mktemp /tmp/sxiv-wallpaper.XXXXXX)"
     13             convert "$path" png:- | png2ff | gzip -c > "$tmpfile" && \
     14                 mv "$tmpfile" "$XDG_CONFIG_HOME/wallpaper.ff.gz"
     15         fi
     16         swall "$XDG_CONFIG_HOME/wallpaper.ff.gz"
     17     ;;
     18 
     19     # rotate 90 degrees clockwise
     20     'r')
     21         if [ "${path#*.ff.gz}" != "$path" ]; then
     22             tmpfile="$(mktemp /tmp/sxiv-rotate.XXXXXX)"
     23             gunzip -c < "$path" | ff2png | \
     24                 convert png:- -rotate 90 png:- | \
     25                 png2ff | gzip -c > "$tmpfile" && \
     26                 mv "$tmpfile" "$path"
     27         else
     28             convert -rotate 90 "$path" "$path"
     29         fi
     30     ;;
     31 
     32     # rotate 90 degrees counter-clockwise
     33     'R')
     34         if [ "${path#*.ff.gz}" != "$path" ]; then
     35             tmpfile="$(mktemp /tmp/sxiv-rotate.XXXXXX)"
     36             gunzip -c < "$path" | ff2png | \
     37                 convert png:- -rotate -90 png:- | \
     38                 png2ff | gzip -c > "$tmpfile" && \
     39             mv "$tmpfile" "$path"
     40         else
     41             convert -rotate -90 "$path" "$path"
     42         fi
     43     ;;
     44     esac
     45 done