diff --git a/scritps/colorgrab b/scritps/colorgrab index 4b25017..3e6bcb8 100755 --- a/scritps/colorgrab +++ b/scritps/colorgrab @@ -58,7 +58,7 @@ done [ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; } # Set color_type if not already set -[ $color_type ] || color_type="hex" +[ "$color_type" ] || color_type="hex" # Get a screenshot of the pixel grim -s 1 -g "$(slurp -b 00000000 -s 00000000 -w -1 -p)" "/tmp/${0##*/}/temp.png" @@ -71,15 +71,15 @@ case $color_type in ;; * ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;; esac -echo "$color" +printf '%s\n' "$color" # Copy color to clipboard -[ $copy_to_clipboard ] && { +[ "$copy_to_clipboard" ] && { wl-copy -n "$color" || printf '%s\n' "${0##*/}: failed to copy color to clipboard" 1>&2 } # Open color image in the user's perfered image viewer -[ $open_color_image ] && { +[ "$open_color_image" ] && { # Create the color image if it doesn't already exist [ -f "/tmp/${0##*/}/o$color.png" ] || { case $color_type in @@ -97,7 +97,7 @@ echo "$color" } # Send a notification with an image of the color aswell as the value -[ $send_notification ] && { +[ "$send_notification" ] && { [ -f "/tmp/${0##*/}/n$color.png" ] || { case $color_type in hex ) ncolor="#$color"; color_prefix="hex:";; diff --git a/scritps/scr b/scritps/scr index 34ebe3f..d991015 100755 --- a/scritps/scr +++ b/scritps/scr @@ -25,6 +25,7 @@ # Source the configuration file # A sample configuration can be found in my dotfiles at: # https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh +# TODO: put an example cofiguration in this repo . "$SCR_CFG_DIR/config.sh" || { printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1 } @@ -72,7 +73,7 @@ do while [ "$args" ] do - a=${args%${args#?}} + a=${args%"${args#?}"} case $a in a ) desktop_audio=true ;; @@ -81,7 +82,7 @@ do h ) usage; exit 0 ;; m ) microphone=true ;; o ) aargs=$* - output=${aargs##*${flag}}; output=${output#\ }; output=${output%%\ *} + output=${aargs##*"${flag}"}; output=${output#\ }; output=${output%%\ *} [ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;; * ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2 usage 1>&2; exit 1 ;; @@ -156,11 +157,11 @@ scr_pic() { grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1 else # Get the geometry of the screenshot from the user and take the screenshot + # TODO: add a SLURP_OPTS environment variable to allow the user to customize slurp if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1 fi - # Copy the image to the system clipboard $copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }