A collection of scripts

colorgrab & scr: shellcheck fixes

yemou 8807ff74 be6ec060

Changed files
+9 -8
scritps
+5 -5
scritps/colorgrab
···
[ -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"
···
;;
* ) 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
···
}
# 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:";;
+4 -3
scritps/scr
···
# 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
}
···
while [ "$args" ]
do
-
a=${args%${args#?}}
+
a=${args%"${args#?}"}
case $a in
a ) desktop_audio=true ;;
···
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 ;;
···
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; }