You are not logged in.

#1 2019-02-03 15:01:36

damo
....moderator....
Registered: 2015-08-20
Posts: 5,098

Screenshot to Clipboard

There were some ideas about this previously here: https://forums.bunsenlabs.org/viewtopic.php?id=276

This little script uses maim (scrot on steroids), xclip and xdotool (all available in the repos). Either the full desktop, active window or selected area is saved to the clipboard as png (could be changed to jpg if you want) - the image can then be pasted into an application (gimp, gmail, LO Writer etc).

scrotclip.sh     NB not much in the way of error-checking yikes

#!/bin/bash
##
## scrotclip.sh by damo Feb 2019

# Requires maim, xclip, xdotool

# USAGE: scrotclip.sh [clipwin|clipall|clipsel]

arg="$1"
if [[ $arg = "clipwin" ]];then
	maim -i $(xdotool getactivewindow) | xclip -selection clipboard -target image/png
	notify-send -t 6000 "Active window screenshot saved to clipboard"
elif [[ $arg = "clipall" ]];then
	maim | xclip -selection clipboard -target image/png
	notify-send -t 6000 "Desktop screenshot saved to clipboard"
elif [[ $arg = "clipsel" ]];then
	maim -s | xclip -selection clipboard -target image/png
	notify-send -t 6000 "Selected area screenshot saved to clipboard"
else
	notify-send -t 6000 "Nothing saved to clipboard..."	
fi

exit

To access it from the menu I edited the writeScrot() function in bl-graphics-pipemenu

writeScrot() {                  # Write scrot submenu items
    IMG="$SCROTSDIR/%F-%H-%M-%S_scrot.png"
    VIEW="'bl-image-viewer $IMG'"
    
    menuSubmenu 'clipscrot' 'Clipboard Screenshots'
		menuItem "Desktop Window Screenshot" "scrotclip.sh clipall"
		menuItem "Active Window Screenshot" "scrotclip.sh clipwin"
		menuItem "Select Area Screenshot" "scrotclip.sh clipsel"
    menuSubmenuEnd

    menuSubmenu 'scrot' 'scrot Screenshooter'
        menuItem "scrot Now" "scrot $IMG -e $VIEW"
        menuItem "scrot In 5 secs..." "scrot -d 5 $IMG -e $VIEW"
        menuItem "scrot In 10 secs..." "scrot -d 10 $IMG -e $VIEW"
        menuItem "scrot Select Area" "scrot -s $IMG -e $VIEW"
        menuItem "scrot Current Focus" "scrot -u $IMG -e $VIEW"
        menuItem "scrot Multi-Monitor" "scrot -m $IMG -e $VIEW"
    menuSubmenuEnd
}

Be Excellent to Each Other...

FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

Board footer

Powered by FluxBB