Screenshot
From Gentoo Linux Wiki
Contents |
[edit] Initial Configuration
To make the Print Screen key take a screen shot: first create the following script, then copy it to /usr/bin/ and make it executable.
Install media-gfx/imagemagick.
| Code: /usr/bin/screenshot |
#!/bin/bash
DIR="${HOME}/images/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 -p "${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
|
You can, of course, modify the file path to suit your needs.
The above script can be called with three different arguments: win, scr and area. The win argument will take a screen shot of a single window. The scr argument will take a screen shot of the entire desktop, and the area argument will allow you to click and drag to capture a rectangular region of the desktop.
Please note that while the script accepts three arguments, screenshot win and screenshot area behave the same. If a window is clicked, a screen shot of the window is taken. If an area is selected with the mouse by clicking and dragging, the selected region is saved as the screen shot. As such, only two arguments (scr and either win or area) are needed to achieve full functionality.
[edit] Desktop Setup
The next step is to simply tie the Print Screen key to the screen shot command in your window manager.
[edit] Xfce
In Xfce, go to the Settings Manager and then choose Keyboard. Click the Shortcuts tab, then click Add. For Command, input screenshot scr and then click OK. A second window will come up, prompting for a key combination for this command. Press and release the Print Screen key. Repeat this process for the command screenshot win, but make the shortcut combination different from the previous one, e.g., Shift + Print Screen.
[edit] Openbox
Add these lines.
...
<keyboard>
...
<keybind key="Print">
<action name="Execute"><execute>/usr/bin/screenshot scr</execute></action>
</keybind>
<keybind key="C-Print">
<action name="Execute"><execute>/usr/bin/screenshot win</execute></action>
</keybind>
...
</keyboard>
...
Save, reconfigure, and use.
[edit] KDE
| Fix me: Please update this section if you know how to configure shortcuts in KDE. |
[edit] Gnome
| Fix me: Please update this section if you know how to configure shortcuts in Gnome. |
directly emerge the gnome-extra/gnome-utils
[edit] Other
The easiest way to take a screenshot of full desktop is run the follow command in your terminal. If you have media-gfx/imagemagick you can also run:
[edit] Xmonad
add the following to your xmonad.hs file:
...
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
...
-- screenshot screen
, ((modMask, xK_Print ), spawn "/usr/bin/screenshot scr")
-- screenshot window or area
, ((modMask .|. shiftMask, xK_Print ), spawn "/usr/bin/screenshot win")
...
Reload xmonad (usually mod-q), and test it out.
