aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Hugo Osvaldo Barrera <hugo@barrera.io>2020-05-01 10:51:18 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2020-05-05 20:18:19 +0200
commitdce8abcdab7a0a65c27e5280b702a592ab557be6 (patch)
tree6c5d40fe992ec7f359b6569205f819142a408592
parentDon't unhide cursor on touch events (diff)
downloadsway-dce8abcdab7a0a65c27e5280b702a592ab557be6.tar.gz
sway-dce8abcdab7a0a65c27e5280b702a592ab557be6.tar.zst
sway-dce8abcdab7a0a65c27e5280b702a592ab557be6.zip
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.
-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 @@
19## `grimshot` - usage 19## `grimshot` - usage
20## `grimshot check` - verify if tools are installed 20## `grimshot check` - verify if tools are installed
21 21
22getTargetDirectory() {
23 test -f ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs && \
24 source ${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs
25
26 echo ${XDG_SCREENSHOTS_DIR:-${XDG_PICTURES_DIR:-$HOME}}
27}
28
22ACTION=${1:-usage} 29ACTION=${1:-usage}
23SUBJECT=${2:-screen} 30SUBJECT=${2:-screen}
24FILE=${3:-$(xdg-user-dir PICTURES)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')} 31FILE=${3:-$(getTargetDirectory)/$(date +'Grimshot %Y-%m-%d %H-%M-%S.png')}
32
25if [ "$ACTION" = "usage" ] ; then 33if [ "$ACTION" = "usage" ] ; then
26 echo "Usage:" 34 echo "Usage:"
27 echo " grimshot copy|save win|screen|output|area [FILE]" 35 echo " grimshot copy|save win|screen|output|area [FILE]"