+5
-5
scritps/colorgrab
+5
-5
scritps/colorgrab
···
58
[ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; }
59
60
# Set color_type if not already set
61
-
[ $color_type ] || color_type="hex"
62
63
# Get a screenshot of the pixel
64
grim -s 1 -g "$(slurp -b 00000000 -s 00000000 -w -1 -p)" "/tmp/${0##*/}/temp.png"
···
71
;;
72
* ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;;
73
esac
74
-
echo "$color"
75
76
# Copy color to clipboard
77
-
[ $copy_to_clipboard ] && {
78
wl-copy -n "$color" || printf '%s\n' "${0##*/}: failed to copy color to clipboard" 1>&2
79
}
80
81
# Open color image in the user's perfered image viewer
82
-
[ $open_color_image ] && {
83
# Create the color image if it doesn't already exist
84
[ -f "/tmp/${0##*/}/o$color.png" ] || {
85
case $color_type in
···
97
}
98
99
# Send a notification with an image of the color aswell as the value
100
-
[ $send_notification ] && {
101
[ -f "/tmp/${0##*/}/n$color.png" ] || {
102
case $color_type in
103
hex ) ncolor="#$color"; color_prefix="hex:";;
···
58
[ -d "/tmp/${0##*/}" ] || { mkdir -p "/tmp/${0##*/}" || exit 1; }
59
60
# Set color_type if not already set
61
+
[ "$color_type" ] || color_type="hex"
62
63
# Get a screenshot of the pixel
64
grim -s 1 -g "$(slurp -b 00000000 -s 00000000 -w -1 -p)" "/tmp/${0##*/}/temp.png"
···
71
;;
72
* ) printf '%s\n' "${0##*/}: invalid color_type: $color_type" 1>&2; exit 1 ;;
73
esac
74
+
printf '%s\n' "$color"
75
76
# Copy color to clipboard
77
+
[ "$copy_to_clipboard" ] && {
78
wl-copy -n "$color" || printf '%s\n' "${0##*/}: failed to copy color to clipboard" 1>&2
79
}
80
81
# Open color image in the user's perfered image viewer
82
+
[ "$open_color_image" ] && {
83
# Create the color image if it doesn't already exist
84
[ -f "/tmp/${0##*/}/o$color.png" ] || {
85
case $color_type in
···
97
}
98
99
# Send a notification with an image of the color aswell as the value
100
+
[ "$send_notification" ] && {
101
[ -f "/tmp/${0##*/}/n$color.png" ] || {
102
case $color_type in
103
hex ) ncolor="#$color"; color_prefix="hex:";;
+4
-3
scritps/scr
+4
-3
scritps/scr
···
25
# Source the configuration file
26
# A sample configuration can be found in my dotfiles at:
27
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
28
. "$SCR_CFG_DIR/config.sh" || {
29
printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
30
}
···
72
73
while [ "$args" ]
74
do
75
-
a=${args%${args#?}}
76
77
case $a in
78
a ) desktop_audio=true ;;
···
81
h ) usage; exit 0 ;;
82
m ) microphone=true ;;
83
o ) aargs=$*
84
-
output=${aargs##*${flag}}; output=${output#\ }; output=${output%%\ *}
85
[ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;;
86
* ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2
87
usage 1>&2; exit 1 ;;
···
156
grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
157
else
158
# Get the geometry of the screenshot from the user and take the screenshot
159
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
160
grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
161
fi
162
-
163
164
# Copy the image to the system clipboard
165
$copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }
···
25
# Source the configuration file
26
# A sample configuration can be found in my dotfiles at:
27
# https://github.com/yemouu/setup/blob/master/home/cfg/scr/config.sh
28
+
# TODO: put an example cofiguration in this repo
29
. "$SCR_CFG_DIR/config.sh" || {
30
printf '%s\n' "${0##*/}: failed to source $SCR_CFG_DIR/config.sh" 1>&2; exit 1
31
}
···
73
74
while [ "$args" ]
75
do
76
+
a=${args%"${args#?}"}
77
78
case $a in
79
a ) desktop_audio=true ;;
···
82
h ) usage; exit 0 ;;
83
m ) microphone=true ;;
84
o ) aargs=$*
85
+
output=${aargs##*"${flag}"}; output=${output#\ }; output=${output%%\ *}
86
[ "${output}" ] || printf '%s\n' "${0##*/}: -o: missing output" 1>&2 ;;
87
* ) printf '%s\n' "${0##*/}: -$a: invalid argument" 1>&2
88
usage 1>&2; exit 1 ;;
···
157
grim "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
158
else
159
# Get the geometry of the screenshot from the user and take the screenshot
160
+
# TODO: add a SLURP_OPTS environment variable to allow the user to customize slurp
161
if [ "$output" ]; then set -- -o "$output"; else set -- -g "$(slurp)"; fi
162
grim "$@" "$filename" > "$SCR_CACHE_DIR/pic.log" 2>&1
163
fi
164
165
# Copy the image to the system clipboard
166
$copy_clipboard && { wl-copy <"$filename" > "$SCR_CACHE_DIR/copy.log" 2>&1; }