[screenshot.sh]: Merge wl_screenshot.sh and x11_screenshot.sh

This commit is contained in:
2025-01-28 04:25:03 +00:00
parent 8d7b3c4b0f
commit 2f099e145b
3 changed files with 9 additions and 17 deletions

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Screenshot script with selection using grim and slurp.
#
# Script to take a selection screenshot on both Xorg and Wayland
filepath="$HOME/media/images/screenshots/$(date +%Y-%m-%d\ %H:%M:%S).png"
grim -g "$(slurp)" - | tee "$filepath" | wl-copy
if [ $(pgrep -x "Xorg") ]; then
maim --select --hidecursor | tee "$filepath" | xclip -selection clipboard -target image/png
else
grim -g "$(slurp)" - | tee "$filepath" | wl-copy
fi
# if screenshot is cancelled, tee will create an empty file, so checking if the file is empty
if [ -s "$filepath" ]; then

View File

@ -1,12 +0,0 @@
#!/bin/sh
# Screenshot script with selection using maim and notification.
filepath="$HOME/media/images/screenshots/$(date +%Y-%m-%d\ %H:%M:%S).png"
maim --select --hidecursor | tee "$filepath" | xclip -selection clipboard -target image/png
# if maim is cancelled, tee will create an empty file, so checking if the file is empty
if [ -s "$filepath" ]; then
# send notification with a thumbnail of the screenshot taken, the name of the script, and the filepath
notify-send --icon "$filepath" "$(basename "$0")" "Screenshot saved to: $filepath"
else
rm "$filepath"
fi