~/screenshot
#!/bin/bash
# from http://gentoo-wiki.com/TIP_Make_a_Screenshot_with_PrintScreen_Key
# call as screenshot scr or screenshot win or screenshot area
# Saves to folder, ~/screenshots/, making it if required.
# Map to printscreen key, keycode 111 by mapping it to F13 in ~/.xinitrc by adding,
# xmodmap -e "keycode 111 = F13" before fluxbox is called.
# Then add the line, 'None F13 :execCommand screenshot scr' to ~/.fluxbox/keys
DIR="${HOME}/screenshots"
DATE="$(date +%Y%m%d@%H%M%S)"
NAME="${DIR}/screenshot-${DATE}.png"
LOG="${DIR}/screenshots.log"
# Check if the dir to store the screenshots exists, else create it:
if [ ! -d "${DIR}" ]; then mkdir "${DIR}"; fi
# Screenshot a selected window
if [ "$1" = "win" ]; then import "${NAME}"; fi
# Screenshot the entire screen
if [ "$1" = "scr" ]; then import -window root "${NAME}"; fi
# Screenshot a selected area
if [ "$1" = "area" ]; then import "${NAME}"; fi
if [[ $# = 0 ]]; then
# Display a warning if no area defined
echo "No screenshot area has been specified. Screenshot not taken."
echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
else
# Save the screenshot in the directory and edit the log
echo "${NAME}" >> "${LOG}"
fi
edit ~/.fluxbox/keys to include:
None F13 :execCommand ~/screenshot scr
Edit the startup script, in this case, ~/.fluxbox/startup to include:
xmodmap -e "keycode 111 = F13"
And press PrtScrn after restarting X.
No comments:
Post a Comment