Scrot: Automatically detect tools

This commit is contained in:
Dylan Araps 2016-12-05 15:14:44 +11:00
parent e5717904e8
commit 3f3326ca29
2 changed files with 45 additions and 9 deletions

View file

@ -629,16 +629,20 @@ ascii_bold="on"
# -s # -s
scrot="off" scrot="off"
# Screenshot program to launch # Screenshot Program
# If you're not using 'scrot' change this to your screenshot # Neofetch will automatically use whatever screenshot tool
# program. # is installed on your system.
# #
# Default: 'scrot -c -d 3' # If 'neofetch -v' says that it couldn't find a screenshot
# Values: 'cmd -flags' # tool or you're using a custom tool then you can change
# the option below to a custom command.
#
# Default: 'auto'
# Values: 'auto' 'cmd -flags'
# Flag: --scrot_cmd # Flag: --scrot_cmd
scrot_cmd="scrot -c -d 3" scrot_cmd="auto"
# Scrot dir # Screenshot Directory
# Where to save the screenshots # Where to save the screenshots
# #
# Default: '~/Pictures/' # Default: '~/Pictures/'
@ -648,7 +652,7 @@ scrot_cmd="scrot -c -d 3"
# Note: Neofetch won't create the directory if it doesn't exist. # Note: Neofetch won't create the directory if it doesn't exist.
scrot_dir="$HOME/Pictures/" scrot_dir="$HOME/Pictures/"
# Scrot filename # Screenshot Filename
# What to name the screenshots # What to name the screenshots
# #
# Default: 'neofetch-$(date +%F-%I-%M-%S-${RANDOM}).png' # Default: 'neofetch-$(date +%F-%I-%M-%S-${RANDOM}).png'

View file

@ -2328,7 +2328,7 @@ to_off() {
take_scrot() { take_scrot() {
if [[ -d "$scrot_dir" ]]; then if [[ -d "$scrot_dir" ]]; then
$scrot_cmd "${scrot_dir}${scrot_name}" scrot_program "${scrot_dir}${scrot_name}"
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
@ -2372,6 +2372,38 @@ scrot_args() {
esac esac
} }
scrot_program() {
if [[ -n "$DISPLAY" ]]; then
if [[ "$scrot_cmd" != "auto" ]] && type -p "$scrot_cmd" >/dev/null; then
scrot_program="scrot_cmd"
elif type -p scrot >/dev/null; then
scrot_program="scrot"
elif type -p maim >/dev/null; then
scrot_program="maim"
elif type -p import >/dev/null; then
scrot_program="import -window root"
elif type -p imlib2_grab >/dev/null; then
scrot_program="imlib2_grab"
elif type -p gnome-screenshot >/dev/null; then
scrot_program="gnome-screenshot -f"
else
err "Scrot: No screen capture tool found."
return
fi
# Take the scrot.
$scrot_program "$1"
err "Scrot: Screen captured using $scrot_program"
fi
}
# TEXT FORMATTING # TEXT FORMATTING
info() { info() {