Screenshot: Add support for macOS and Haiku

This commit is contained in:
Dylan Araps 2016-12-05 15:42:32 +11:00
parent 3f3326ca29
commit cf57ebe7f7
1 changed files with 16 additions and 7 deletions

View File

@ -2328,7 +2328,7 @@ to_off() {
take_scrot() { take_scrot() {
if [[ -d "$scrot_dir" ]]; then if [[ -d "$scrot_dir" ]]; then
scrot_program "${scrot_dir}${scrot_name}" scrot_program "${scrot_dir}${scrot_name}" 2>/dev/null
else else
printf "%s\n" "Screenshot: $scrot_dir doesn't exist. Edit the config file or create the directory to take screenshots." printf "%s\n" "Screenshot: $scrot_dir doesn't exist. Edit the config file or create the directory to take screenshots."
fi fi
@ -2373,9 +2373,13 @@ scrot_args() {
} }
scrot_program() { scrot_program() {
# Detect screenshot program.
#
# We first check to see if an X server is running before
# falling back to OS specific screenshot tools.
if [[ -n "$DISPLAY" ]]; then if [[ -n "$DISPLAY" ]]; then
if [[ "$scrot_cmd" != "auto" ]] && type -p "$scrot_cmd" >/dev/null; then if [[ "$scrot_cmd" != "auto" ]] && type -p "$scrot_cmd" >/dev/null; then
scrot_program="scrot_cmd" scrot_program="$scrot_cmd"
elif type -p scrot >/dev/null; then elif type -p scrot >/dev/null; then
scrot_program="scrot" scrot_program="scrot"
@ -2396,12 +2400,17 @@ scrot_program() {
err "Scrot: No screen capture tool found." err "Scrot: No screen capture tool found."
return return
fi fi
else
# Take the scrot. case "$os" in
$scrot_program "$1" "Mac OS X") scrot_program="screencapture -S" ;;
"Haiku") scrot_program="screenshot -s" ;;
err "Scrot: Screen captured using $scrot_program" esac
fi fi
# Take the scrot.
$scrot_program "$1"
err "Scrot: Screen captured using $scrot_program"
} }
# TEXT FORMATTING # TEXT FORMATTING