diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-20 23:01:09 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-06-20 23:01:09 +0200 |
| commit | 581865ee0c8b8aea872f053d804a41fb5f416b17 (patch) | |
| tree | 9a2f99ea48c31629a5c3c42b0454483982cdbfed /dmenu-screenshot | |
| parent | c5d101ab2c9db3b1a001cb56953cb90b24f8fdcf (diff) | |
| download | scripts-581865ee0c8b8aea872f053d804a41fb5f416b17.tar.gz scripts-581865ee0c8b8aea872f053d804a41fb5f416b17.zip | |
Various shellcheck fixes (www.shellcheck.net)
Diffstat (limited to '')
| -rwxr-xr-x | dmenu-screenshot | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/dmenu-screenshot b/dmenu-screenshot index 00d6c40..c899f1a 100755 --- a/dmenu-screenshot +++ b/dmenu-screenshot | |||
| @@ -1,9 +1,14 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Screenshot utility | 3 | # Screenshot utility |
| 4 | # Usage: dmenu-screenshot [-m menu] | ||
| 5 | # Requires: dmenu (or similar), imagemagick | 4 | # Requires: dmenu (or similar), imagemagick |
| 6 | 5 | ||
| 6 | # Usage: dmenu-screenshot [-m menu] | ||
| 7 | |||
| 8 | usage() { | ||
| 9 | echo "Usage: dmenu-screenshot [-m MENU]" | ||
| 10 | } | ||
| 11 | |||
| 7 | menu="dmenu -i" | 12 | menu="dmenu -i" |
| 8 | prompt="Select type of screenshot:" | 13 | prompt="Select type of screenshot:" |
| 9 | 14 | ||
| @@ -12,21 +17,24 @@ while getopts "m:" opt; do | |||
| 12 | m) | 17 | m) |
| 13 | menu="$OPTARG" | 18 | menu="$OPTARG" |
| 14 | ;; | 19 | ;; |
| 20 | *) | ||
| 21 | usage | ||
| 22 | exit 1 | ||
| 23 | ;; | ||
| 15 | esac | 24 | esac |
| 16 | done | 25 | done |
| 17 | shift `expr $OPTIND - 1` | 26 | shift $((OPTIND - 1)) |
| 18 | 27 | ||
| 19 | folder="$HOME/pictures/screenshots" | 28 | folder="$HOME/pictures/screenshots" |
| 20 | filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png" | 29 | filename="screenshot_$(date +%Y-%m-%d-%H%M%S).png" |
| 21 | filepath="${folder}/${filename}" | 30 | filepath="${folder}/${filename}" |
| 22 | 31 | ||
| 23 | t=$(echo "Full\nSelection" | $menu -p "$prompt") | 32 | t=$(printf 'Full\nSelection\n' | $menu -p "$prompt") |
| 24 | #op="" TODO: remove if not needed | ||
| 25 | if [ "$t" = "Full" ]; then | 33 | if [ "$t" = "Full" ]; then |
| 26 | op="-window root" | 34 | op="-window root" |
| 27 | else | 35 | else |
| 28 | pkill xbanish # otherwise I can't use mouse to select area | 36 | pkill xbanish # otherwise I can't use mouse to select area |
| 29 | fi | 37 | fi |
| 30 | 38 | ||
| 31 | [ -n "$t" ] && sleep 0.1 && import $op $filepath | 39 | [ -n "$t" ] && sleep 0.1 && import "$op" "$filepath" |
| 32 | spawn xbanish # This can be removed if you don't use xbanish | 40 | spawn xbanish # This can be removed if you don't use xbanish |
