Screenshot: Copy path to clipboard in wayland, rework script for better error detection
also, ostensibly fix clipboard copying for x Signed-off-by: Stacy Harper <contact@stacyharper.net>
This commit is contained in:

committed by
Stacy Harper

parent
86242011a1
commit
576550451d
@@ -2,25 +2,41 @@
|
||||
# scrot refuses to work with double quotes
|
||||
# shellcheck disable=SC2016
|
||||
|
||||
exitMsg(){
|
||||
echo "$1" > /dev/stderr
|
||||
notify-send "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
commandExists(){
|
||||
command -v "$1" 2>/dev/null
|
||||
}
|
||||
|
||||
case "$(sxmo_wm.sh)" in
|
||||
sway)
|
||||
commandExists grim || exitMsg "grim command must be available to take a screenshot."
|
||||
FILENAME="$(date +%Y-%m-%d-%T)_grim.png"
|
||||
SELECTION="slurp | grim -g - ~/$FILENAME"
|
||||
WHOLESCREEN="grim ~/$FILENAME"
|
||||
if [ "$1" = "selection" ]; then
|
||||
commandExists slurp || exitMsg "slurp command must be available to make a selection."
|
||||
COMMAND="notify-send 'select an area' && slurp | grim -g - ~/$FILENAME && (printf ~/$FILENAME | wl-copy)"
|
||||
else
|
||||
COMMAND="grim ~/$FILENAME && (printf ~/$FILENAME | wl-copy)"
|
||||
fi
|
||||
;;
|
||||
xorg|dwm)
|
||||
SELECTION="scrot -e 'echo $f | xsel -i -b' -d 1 -s -q 1"
|
||||
WHOLESCREEN="scrot -e 'echo $f | xsel -i -b' -d 1 -q 1"
|
||||
commandExists scrot || exitMsg "scrot command must be available to take a screenshot"
|
||||
f='$f'
|
||||
if [ "$1" = "selection" ]; then
|
||||
COMMAND="notify-send 'select an area' && scrot -e 'echo $f | xsel -i -b' -d 1 -s -q 1"
|
||||
else
|
||||
COMMAND="scrot -e 'echo $f | xsel -i -b' -d 1 -q 1"
|
||||
fi
|
||||
;;
|
||||
ssh)
|
||||
echo "cannot screenshot ssh ;)"
|
||||
exit 0
|
||||
exitMsg "cannot screenshot ssh ;)"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$1" = "selection" ]; then
|
||||
notify-send "select an area" && eval "$SELECTION" && notify-send "screenshot saved, filename copied to clipboard"
|
||||
else
|
||||
eval "$WHOLESCREEN" && notify-send "screenshot saved, filename copied to clipboard"
|
||||
fi
|
||||
|
||||
eval "$COMMAND" && notify-send "screenshot saved, filename copied to clipboard" && exit 0
|
||||
exitMsg "Screenshot process failure."
|
||||
|
@@ -53,8 +53,8 @@ programchoicesinit() {
|
||||
$icon_mic Record ^ 0 ^ sxmo_record.sh
|
||||
$icon_red Reddit ^ 0 ^ sxmo_reddit.sh
|
||||
$icon_rss RSS ^ 0 ^ sxmo_rss.sh
|
||||
$(command -v scrot >/dev/null && echo $icon_cam Screenshot ^ 0 ^ sxmo_screenshot.sh || notify-send failed to take a screenshot)
|
||||
$(command -v scrot >/dev/null && echo $icon_cam Screenshot \(selection\) ^ 0 ^ sxmo_screenshot.sh selection || notify-send failed to take a screenshot)
|
||||
$icon_cam Screenshot ^ 0 ^ sxmo_screenshot.sh
|
||||
$icon_cam Screenshot (selection) ^ 0 ^ sxmo_screenshot.sh selection
|
||||
$icon_tmr Timer ^ 0 ^ sxmo_timer.sh
|
||||
$icon_ytb Youtube ^ 0 ^ sxmo_youtube.sh video
|
||||
$icon_ytb Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio
|
||||
|
Reference in New Issue
Block a user