aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2022-03-11 10:12:09 +0300
committerJoursoir <chat@joursoir.net>2022-03-11 10:12:09 +0300
commit55e1b02f7acd76d6c92c6f5b9018bb8d21a96677 (patch)
tree6be17f346b55f63df476666f92e8e8f7a8143f8c
parent6650254ec368fce302201f74aa74a123f1b57bea (diff)
downloaddotfiles-55e1b02f7acd76d6c92c6f5b9018bb8d21a96677.tar.gz
dotfiles-55e1b02f7acd76d6c92c6f5b9018bb8d21a96677.tar.bz2
dotfiles-55e1b02f7acd76d6c92c6f5b9018bb8d21a96677.zip
bin: add scregcp.sh
-rw-r--r--bin/scregcp.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/bin/scregcp.sh b/bin/scregcp.sh
new file mode 100644
index 0000000..2f2bab2
--- /dev/null
+++ b/bin/scregcp.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+# Dependencies: 'imagemagick', 'xclip'
+
+function help_and_exit {
+ if [ -n "${1}" ]; then
+ echo "${1}"
+ fi
+ cat <<-EOF
+ Usage: scregcp [-h|-s] [<screenshots_base_folder>]
+
+ Take screenshot of a whole screen or a specified region,
+ save it to a specified folder (current folder is default)
+ and copy it to a clipboard.
+
+ -h - print help and exit
+ -s - take a screenshot of a screen region
+EOF
+ if [ -n "${1}" ]; then
+ exit 1
+ fi
+ exit 0
+}
+
+if [ "${1}" == '-h' ]; then
+ help_and_exit
+elif [ "${1:0:1}" == '-' ]; then
+ if [ "${1}" != '-s' ]; then
+ help_and_exit "error: unknown option ${1}"
+ fi
+ base_folder="${2}"
+else
+ base_folder="${1}"
+ params="-window root"
+fi
+
+file_path=${base_folder}$( date '+%Y-%m-%d_%H-%M-%S' )_screenshot.png
+import ${params} ${file_path}
+xclip -selection clipboard -target image/png -i < ${file_path}