From d34f01f21b5f64620c3207b9807c37c987e84dde Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 27 Mar 2017 08:29:04 +1100 Subject: [PATCH 1/3] Scrot: Make scrot easier to use --- config/config | 10 ---------- neofetch | 12 +++++------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/config/config b/config/config index d1621962..0e11e354 100644 --- a/config/config +++ b/config/config @@ -681,16 +681,6 @@ scrot="off" # Flag: --scrot_cmd scrot_cmd="auto" -# Screenshot Directory -# Where to save the screenshots -# -# Default: '~/Pictures/' -# Values: 'dir' -# Flag: --scrot_dir -# -# Note: Neofetch won't create the directory if it doesn't exist. -scrot_dir="$HOME/Pictures/" - # Screenshot Filename # What to name the screenshots # diff --git a/neofetch b/neofetch index a3690aa9..1fd40c24 100755 --- a/neofetch +++ b/neofetch @@ -637,13 +637,13 @@ get_wm() { case "$os" in "Mac OS X") ps_line="$(ps -e | grep -o '[S]pectacle\|[A]methyst\|[k]wm')" - + case "$ps_line" in *"kwm"*) wm="Kwm" ;; *"Amethyst"*) wm="Amethyst" ;; *"Spectacle"*) wm="Spectacle" ;; *) wm="Quartz Compositor" ;; - esac + esac ;; "Windows") @@ -2516,11 +2516,7 @@ to_off() { # SCREENSHOT take_scrot() { - if [[ -d "$scrot_dir" ]]; then - scrot_program "${scrot_dir}${scrot_name}" 2>/dev/null - else - printf "%s\n" "Screenshot: $scrot_dir doesn't exist. Edit the config file or create the directory to take screenshots." - fi + scrot_program "${scrot_dir}${scrot_name}" 2>/dev/null [[ "$scrot_upload" == "on" ]] && scrot_upload } @@ -2568,6 +2564,8 @@ scrot_args() { scrot_dir="${2/$scrot_name}" ;; esac + + [[ -z "$@" ]] && scrot_dir="${PWD:+${PWD}/}" } scrot_program() { From 4659863737fba40ab97387d56869a533db8b112d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 27 Mar 2017 08:33:13 +1100 Subject: [PATCH 2/3] Scrot: Unset scrot_dir if the user has set it --- neofetch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neofetch b/neofetch index 1fd40c24..2f397053 100755 --- a/neofetch +++ b/neofetch @@ -3651,6 +3651,9 @@ old_options() { # Birthday was renamed to Install Date in 3.0 [[ -n "$birthday_time" ]] && { err "Config: \$birthday_time is deprecated, use \3install_time instead."; install_time="$birthday_time"; } + + # Scrot dir was removed in 3.1.0. + [[ -n "$scrot_dir" ]] && scrot_dir= } cache_uname() { From 1e6804f54af382fa0a176444430461d2e3120a4d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 27 Mar 2017 08:45:12 +1100 Subject: [PATCH 3/3] Scrot: Log where the file was saved and fix bug with empty filename --- neofetch | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/neofetch b/neofetch index 2f397053..6a157658 100755 --- a/neofetch +++ b/neofetch @@ -2518,6 +2518,8 @@ to_off() { take_scrot() { scrot_program "${scrot_dir}${scrot_name}" 2>/dev/null + err "Scrot: Saved screenshot as: ${scrot_dir}${scrot_name}" + [[ "$scrot_upload" == "on" ]] && scrot_upload } @@ -2557,15 +2559,16 @@ scrot_upload() { scrot_args() { scrot="on" - case "$2" in - "-"* | "") ;; - *) - scrot_name="${2##*/}" - scrot_dir="${2/$scrot_name}" - ;; - esac - [[ -z "$@" ]] && scrot_dir="${PWD:+${PWD}/}" + if [[ "$2" =~ \.(png|jpg|jpe|jpeg|gif)$ ]]; then + scrot_name="${2##*/}" + scrot_dir="${2/$scrot_name}" + + elif [[ -d "$2" ]]; then + scrot_dir="$2" + else + scrot_dir="${PWD:+${PWD}/}" + fi } scrot_program() {