···5858[ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; }
59596060# Set color_type if not already set
6161-[ $color_type ] || color_type="hex"
6161+[ "$color_type" ] || color_type="hex"
62626363# Get a screenshot of the pixel
6464grim -s 1 -g "$(slurp -b 00000000 -s 00000000 -w -1 -p)" "/tmp/${0##*/}/temp.png"
···7171 ;;
7272 * ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;;
7373esac
7474-echo "$color"
7474+printf '%s\n' "$color"
75757676# Copy color to clipboard
7777-[ $copy_to_clipboard ] && {
7777+[ "$copy_to_clipboard" ] && {
7878 wl-copy -n "$color" || printf '%s\n' "${0##*/}: failed to copy color to clipboard" 1>&2
7979}
80808181# Open color image in the user's perfered image viewer
8282-[ $open_color_image ] && {
8282+[ "$open_color_image" ] && {
8383 # Create the color image if it doesn't already exist
8484 [ -f "/tmp/${0##*/}/o$color.png" ] || {
8585 case $color_type in
···9797}
98989999# Send a notification with an image of the color aswell as the value
100100-[ $send_notification ] && {
100100+[ "$send_notification" ] && {
101101 [ -f "/tmp/${0##*/}/n$color.png" ] || {
102102 case $color_type in
103103 hex ) ncolor="#$color"; color_prefix="hex:";;
+4-3
scritps/scr
···2525# Source the configuration file
2626# A sample configuration can be found in my dotfiles at:
2727# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
2828+# TODO: put an example cofiguration in this repo
2829. "$SCR_CFG_DIR/config.sh" || {
2930 printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
3031}
···72737374 while [ "$args" ]
7475 do
7575- a=${args%${args#?}}
7676+ a=${args%"${args#?}"}
76777778 case $a in
7879 a ) desktop_audio=true ;;
···8182 h ) usage; exit 0 ;;
8283 m ) microphone=true ;;
8384 o ) aargs=$*
8484- output=${aargs##*${flag}}; output=${output#\ }; output=${output%%\ *}
8585+ output=${aargs##*"${flag}"}; output=${output#\ }; output=${output%%\ *}
8586 [ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;;
8687 * ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2
8788 usage 1>&2; exit 1 ;;
···156157 grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
157158 else
158159 # Get the geometry of the screenshot from the user and take the screenshot
160160+ # TODO: add a SLURP_OPTS environment variable to allow the user to customize slurp
159161 if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
160162 grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
161163 fi
162162-163164164165 # Copy the image to the system clipboard
165166 $copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }