Added shortcuts for maim

This commit is contained in:
David Thurstenson 2017-04-28 11:58:17 -05:00
parent 6000841c7e
commit 8602033910
1 changed files with 49 additions and 0 deletions

49
.bashrc
View File

@ -106,6 +106,8 @@ alias screenterm='TERM=screen-256color'
# If you are thurstylark-vps, connect to the existing tmux session locally # If you are thurstylark-vps, connect to the existing tmux session locally
[[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat' [[ "$HOSTNAME" = "thurstylark-vps" ]] && alias weechat='tmux attach -dt weechat'
### FUNCTIONS ###
# Print Dell Service Tag # Print Dell Service Tag
getdst() { getdst() {
if [[ "$1" = "-l" ]]; then if [[ "$1" = "-l" ]]; then
@ -114,3 +116,50 @@ getdst() {
sudo dmidecode -s system-serial-number sudo dmidecode -s system-serial-number
fi fi
} }
countdown() {
local secs="$1"
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
}
# Screenshot utils
shot() {
# Usage: shot XY
local destdir="$HOME/Pictures/screenshots"
local fname="screenshot-$(date +%F-%T).png"
local fpath="${destdir}/${fname}"
local pb="fb"
local pipe
local -a opts
# X: What to capture
case ${1:0:1} in
# Active window
w)
countdown 5
opts[0]="-i$(xdotool getactivewindow)"
;;
# All
a) opts[0]="";;
# Mouse selection
s) opts[0]="-s --noopengl";;
esac
#Y: Where to put the result
case ${1:1:1} in
# Save to file
f) [ ! -d "$destdir" ] && mkdir -p "$destdir"
opts[1]="$fpath"
printf "Writing to %s\n" "$fpath"
;;
# Post to a pastebin
p) opts[1]="/tmp/$fname"
pipe="$pb ${opts[1]}";;
esac
maim ${opts[@]}; $pipe
}