aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/xmonad/xmonad.hs1
-rwxr-xr-xlocal/bin/screenshot-prompt35
2 files changed, 36 insertions, 0 deletions
diff --git a/config/xmonad/xmonad.hs b/config/xmonad/xmonad.hs
index 7d95f03..d62e2c6 100644
--- a/config/xmonad/xmonad.hs
+++ b/config/xmonad/xmonad.hs
@@ -101,6 +101,7 @@ keys' = [ ("<XF86AudioLowerVolume>", spawn "pulseaudio-ctl down")
, ("M-i", spawn "insert-special-character")
, ("M-S-i", spawn "insert-special-character copy")
, ("M-S-t", spawn "translate-prompt")
+ , ("M-a", spawn "screenshot-prompt")
, ("M-S-d", spawn "notify-send -i x-office-calendar \"$(date +\"%H:%M %A %d/%m/%Y %B\")\"")
, ("M-S-b", spawn $ "notify-send --hint=int:transient:1 " ++
"--hint=int:value:\"$(cat /sys/class/power_supply/BAT0/capacity)\" " ++
diff --git a/local/bin/screenshot-prompt b/local/bin/screenshot-prompt
new file mode 100755
index 0000000..7d4f1a7
--- /dev/null
+++ b/local/bin/screenshot-prompt
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+command -v scrot > /dev/null ||
+ { echo "scrot not installed" ; exit 1 ; }
+command -v rofi > /dev/null &&
+ menu_exec='rofi -dmenu' ||
+ menu_exec='dmenu'
+
+choice="$(
+$menu_exec <<EOF
+Crop to file
+Crop to clipboard
+Fullscreen to file
+Fullscreen to clipboard
+EOF
+)"
+
+screenshot_dir="$HOME/screenshots"
+
+case "$choice" in
+ 'Crop to file')
+ scrot --select
+ ;;
+ 'Crop to clipboard')
+ scrot --select - | xclip -selection clipboard -target image/png
+ ;;
+ 'Fullscreen to file')
+ scrot
+ ;;
+ 'Fullscreen to clipboard')
+ scrot - | xclip -selection clipboard -target image/png
+ ;;
+esac