#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/dump last-arg () { echo ${@:${#@}} } dump-vt () { local vt=$1 local f=$(last-arg $@).png # so it'll also work when $# = 1 case $# in (1) fbgrab $f ;; (2) sudo fbgrab -c $vt $f && sudo chown $USER $f && sudo chgrp $USER $f ;; esac } alias dumpvt=dump-vt # DNC? dump-x () { local name=$1 local f=${name}.png local win_name=$2 case $# in (1) gnome-screenshot -f $f ;; (2) wmctrl -a $win_name; gnome-screenshot -w -B -f $f ;; esac 2> /dev/null } dump () { [[ $DISPLAY ]] && dump-x $@ || dump-vt $@ }