26 lines
768 B
Bash
Executable file
26 lines
768 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# Load helper functions
|
|
bin_path="$(dirname "$(rreadlink "$0")")"
|
|
source "$bin_path/../lib/utils.sh"
|
|
|
|
if [ -z "$1" ]; then
|
|
NAME="shot_$(date '+%Y%m%d%H%M%S').png"
|
|
else
|
|
NAME="$1"
|
|
fi
|
|
|
|
SCREEN_DIR="$HOME/img/screenshots"
|
|
mkdir -p "$SCREEN_DIR"
|
|
# Let's try to detect Wayland running
|
|
if [ -z "$WAYLAND_DISPLAY" ]; then
|
|
assert_exists "maim"
|
|
maim --hidecursor --select "$SCREEN_DIR/$NAME"
|
|
# Fail silently if xsel isn't installed, the clipboard feature isn't critical
|
|
echo "$SCREEN_DIR/$NAME" | xsel --clipboard --input > /dev/null 2>&1
|
|
else
|
|
assert_exists "grim" "slop"
|
|
slop | awk -F '[x+]' '{printf "%s,%s %sx%s",$3,$4,$1,$2}' | grim -g - "$SCREEN_DIR/$NAME"
|
|
# Same as xsel
|
|
wl-copy -n "$SCREEN_DIR/$NAME" > /dev/null 2>&1
|
|
fi
|