aboutsummaryrefslogtreecommitdiffstats
path: root/bin/qar-scrotmenu.sh
blob: b60cbc847d5fd2042616ffcd3746c43e5ad60363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Screenshot menu, rofi themed by udt.
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
# Licensed under the GNU General Public License v2 only.

# Glyph size follows the monitor rofi opens on (the focused one), in points,
# since rofi cannot size a font by percentage. Each cell gets half the width,
# so a quarter of the smaller of half-width and height fits both a wide and a
# rotated portrait monitor. Odd transforms are 90/270 degree rotations, which
# swap the reported width and height.
size=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .scale as $s
    | (if .transform % 2 == 1 then [.height, .width] else [.width, .height] end)
    | [.[0] / 2, .[1]] | min / $s / 4 | floor' 2>/dev/null)
size=${size:-135}
rofi_command=(rofi -theme ~/.config/rofi/udt/screenshot.rasi
    -theme-str "element-text { font: \"Inconsolata Nerd Font Mono $size\"; }")

### Options ###
screen=""
area=""
# Variable passed to rofi
options="$screen\n$area"

chosen="$(echo -e "$options" | "${rofi_command[@]}" -dmenu -selected-row 1)"
case $chosen in
    $screen)
        grimblast -w 3 -n -t png copysave active
        ;;
    $area)
        grimblast -n -t png copysave area
        ;;
esac