aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2020-05-01 10:51:18 +0200
committerFurkan Sahin <furkan-dev@proton.me>2020-05-01 10:51:18 +0200
commit89e0f6202144fccece5a064261ffe57c2dbcc8ad (patch)
tree6c5d40fe992ec7f359b6569205f819142a408592 /contrib
parent3e8f8145f33181f2455dc28f766337da2c2f75b2 (diff)
grimshot: Allow configuring default directory
`$XDG_PICTURES_DIR` is a very loosely defined thing; it's a directory where "pictures" are stored, which no clearer definition. Some people use it for photographs they take, other use it for images they save from the internet, and others use it for screenshots. Having lots of tools save their output there (anything that's an image goes there) can easily make it a kitchen sink. To work around this, use `$XDG_SCREENSHOTS_DIR` as a target directory for screenshots by default. If not-so-standard variable is unset, fall back to the previous setting; `$XDG_PICTURES_DIR`. This also drops an external dependency, which was (a) an overkill (b) not flexible enough.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/grimshot10
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/grimshot b/contrib/grimshot
index fcd2dbca..3ef18ce6 100755
--- a/contrib/grimshot
+++ b/contrib/grimshot
@@ -19,9 +19,17 @@
## `grimshot` - usage
## `grimshot check` - verify if tools are installed
+getTargetDirectory() {
+ test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \
+ source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
+
+ echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
+}
+
ACTION=${1:-usage}
SUBJECT=${2:-screen}
-FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')}
+FILE=${3:-$(getTargetDirectory)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')}
+
if [ "$ACTION" = "usage" ] ; then
echo "Usage:"
echo " grimshot copy|save win|screen|output|area [FILE]"