From 69da68576ed38fc325c8f29c7c25aa978e314665 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Fri, 26 Jun 2026 09:52:47 +0900 Subject: modified bin/maimpick, created alacritty/ --- ar/.local/bin/maimpick | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'ar/.local/bin/maimpick') diff --git a/ar/.local/bin/maimpick b/ar/.local/bin/maimpick index 06d9092..ea227ae 100755 --- a/ar/.local/bin/maimpick +++ b/ar/.local/bin/maimpick @@ -12,12 +12,44 @@ ocr_cmd="xclip -sel clip" [ -d "$output_dir" ] || mkdir -p "$output_dir" -case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\ncopy selected image to text" | dmenu -l 7 -i -p "Screenshot which area?")" in +# Number of connected monitors (first line of xrandr --listmonitors). +mon_count="$(xrandr --listmonitors | awk 'NR==1{print $2}')" + +# Prompt for a monitor and print its maim -g geometry (WxH+X+Y), or nothing if +# the picker is cancelled. +pick_monitor() { + monitors="$(xrandr --listmonitors | tail -n +2)" + name="$(printf '%s\n' "$monitors" | awk '{print $NF}' | dmenu -i -p "Which monitor?")" || return 1 + [ -z "$name" ] && return 1 + printf '%s\n' "$monitors" | awk -v n="$name" '$NF==n {gsub(/\/[0-9]+/,"",$3); print $3}' +} + +# Build the menu, only offering the monitor entries when more than one is +# connected. +options="a selected area +current window +full screen" +[ "$mon_count" -gt 1 ] 2>/dev/null && options="$options +selected monitor" +options="$options +a selected area (copy) +current window (copy) +full screen (copy)" +[ "$mon_count" -gt 1 ] 2>/dev/null && options="$options +selected monitor (copy)" +options="$options +copy selected image to text" + +lines="$(printf '%s\n' "$options" | wc -l)" + +case "$(printf '%s\n' "$options" | dmenu -l "$lines" -i -p "Screenshot which area?")" in "a selected area") maim -u -s "$output_dir"pic-selected-"${output}" ;; "current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" "$output_dir"pic-window-"${output}" ;; "full screen") maim -q -d 0.2 "$output_dir"pic-full-"${output}" ;; +"selected monitor") geo="$(pick_monitor)" && [ -n "$geo" ] && maim -q -d 0.2 -g "$geo" "$output_dir"pic-monitor-"${output}" ;; "a selected area (copy)") maim -u -s | ${xclip_cmd} ;; "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;; "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;; +"selected monitor (copy)") geo="$(pick_monitor)" && [ -n "$geo" ] && maim -q -d 0.2 -g "$geo" | ${xclip_cmd} ;; "copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && maim -u -s >"$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; esac -- cgit v1.2.3