summaryrefslogtreecommitdiff
path: root/polybar/scripts/screenshot-menu.sh
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-05-24 11:48:07 +0200
committerDavid Moc <personal@cdatgoose.org>2026-05-24 11:48:07 +0200
commit5fb19f10389b70ee2389755106092a9ef6c64598 (patch)
tree969eb0466de581cb14aa09f751a95138620fc720 /polybar/scripts/screenshot-menu.sh
Go
Diffstat (limited to 'polybar/scripts/screenshot-menu.sh')
-rwxr-xr-xpolybar/scripts/screenshot-menu.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/polybar/scripts/screenshot-menu.sh b/polybar/scripts/screenshot-menu.sh
new file mode 100755
index 0000000..b3064a9
--- /dev/null
+++ b/polybar/scripts/screenshot-menu.sh
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+dir="${XDG_PICTURES_DIR:-$HOME/Pictures}/Screenshots"
+mkdir -p "$dir" 2>/dev/null || true
+if [ ! -w "$dir" ]; then
+ dir="/tmp"
+fi
+
+export DISPLAY="${DISPLAY:-:0}"
+if [ -z "${XAUTHORITY:-}" ] && [ -r "$HOME/.Xauthority" ]; then
+ export XAUTHORITY="$HOME/.Xauthority"
+fi
+
+notify() {
+ if command -v dunstify >/dev/null 2>&1; then
+ dunstify -a polybar -u low "Screenshot" "$1"
+ fi
+}
+
+menu() {
+ printf '%s\n' full selection window |
+ dmenu -i -p screenshot \
+ -fn "FiraCode Nerd Font-14" \
+ -nb "#282828" -nf "#ebdbb2" \
+ -sb "#d79921" -sf "#282828"
+}
+
+file="$dir/shot-$(date +%Y%m%d-%H%M%S).png"
+choice="$(menu)"
+
+case "$choice" in
+ full)
+ if command -v scrot >/dev/null 2>&1; then
+ scrot "$file"
+ elif command -v import >/dev/null 2>&1; then
+ import -window root "$file"
+ else
+ notify "No screenshot tool found"
+ exit 1
+ fi
+ ;;
+ selection)
+ if command -v flameshot >/dev/null 2>&1; then
+ flameshot gui -p "$dir"
+ exit 0
+ elif command -v maim >/dev/null 2>&1; then
+ maim -s "$file"
+ elif command -v scrot >/dev/null 2>&1; then
+ scrot -s "$file"
+ elif command -v import >/dev/null 2>&1; then
+ import "$file"
+ else
+ notify "No selection screenshot tool found"
+ exit 1
+ fi
+ ;;
+ window)
+ if command -v scrot >/dev/null 2>&1; then
+ scrot -u "$file"
+ elif command -v import >/dev/null 2>&1; then
+ import "$file"
+ else
+ notify "No window screenshot tool found"
+ exit 1
+ fi
+ ;;
+ *)
+ exit 0
+ ;;
+esac
+
+notify "$file"