Skip to content

Instantly share code, notes, and snippets.

@Enzime
Created August 21, 2015 21:58
Show Gist options
  • Save Enzime/8b372b58834abbe93b7e to your computer and use it in GitHub Desktop.
Save Enzime/8b372b58834abbe93b7e to your computer and use it in GitHub Desktop.
Small script that uses maim and xclip (and xwininfo and xdotool) to take screenshots and upload them to pomf clones (with limf)
#!/bin/bash
file=~/Pictures/Screenshots/$(date +%y-%m-%d_%H-%M-%S).png
if [[ "$1" == "desktop" ]]; then
maim $file
elif [[ "$1" == "current" ]]; then
# maim -i $(xdotool getactivewindow) $file
maim -i $(xwininfo -id $(xwininfo -id $(xdotool getactivewindow) -children | grep "Parent window id" | sed -r "s/.*: (0x[0-9a-f]+) .*/\1/") | sed -r "s/.*: (0x[0-9a-f]+) .*/\1/" | head -n2 | tail -n1) -g $(xwininfo -id $(xwininfo -id $(xdotool getactivewindow) -children | grep "Parent window id" | sed -r "s/.*: (0x[0-9a-f]+) .*/\1/") | tail -n3 | head -n2 | py -l 'list(map(str.split,l))[1][1].replace("-","+").split("+")[0]+list(map(str.split,l))[0][1]') $file
else
maim -s $file
fi
if [ -f $file ]; then
url=$(limf -l -c 0 $file)
echo $url | xclip -selection clipboard
firefox $url
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment