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