mirror of
https://codeberg.org/hyperreal/bin
synced 2024-11-25 10:23:42 +01:00
Add rofimaim
This commit is contained in:
parent
5aa57d27da
commit
51586f9804
40
rofimaim
Executable file
40
rofimaim
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Rofi powered menu to take a screenshot of the whole screen, a selected area or
|
||||
# the active window. The image is then saved and copied to the clipboard.
|
||||
# Uses: date maim notify-send rofi xclip xdotool
|
||||
#
|
||||
# This is lifted from https://gitlab.com/vahnrr/rofi-menus and modified by
|
||||
# hyperreal <hyperreal64@pm.me> on 2023-09-06T15:09:58-05:00
|
||||
|
||||
save_location="${HOME}/screenshots"
|
||||
if ! test -d "${HOME}/screenshots"; then
|
||||
mkdir "${HOME}/screenshots"
|
||||
fi
|
||||
screenshot_path="$save_location/$(date +'%Y-%m-%d-%H%M%S').png"
|
||||
|
||||
screen=' Screen'
|
||||
area=' Select area'
|
||||
window=' Window'
|
||||
|
||||
chosen=$(printf '%s;%s;%s\n' "$screen" "$area" "$window" \
|
||||
| rofi -theme-str 'window { width: 10em; height: 10em; }' \
|
||||
-P 'Screenshot' \
|
||||
-dmenu \
|
||||
-sep ';' \
|
||||
-selected-row 1)
|
||||
|
||||
case "$chosen" in
|
||||
"$screen") extra_args='--delay=1' ;;
|
||||
"$area") extra_args='--delay=0.1 --select --highlight --color=0.85,0.87,0.91,0.2' ;;
|
||||
"$window") extra_args="--delay=1 --window=$(xdotool getactivewindow)" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
|
||||
# The variable is used as a command's options, so it shouldn't be quoted.
|
||||
# shellcheck disable=2086
|
||||
maim --hidecursor --quiet --quality=3 --format='png' $extra_args "$screenshot_path" && {
|
||||
notify-send --icon=org.xfce.screenshooter "Screenshot saved as $screenshot_path"
|
||||
|
||||
xclip -selection clipboard -target 'image/png' -in "$screenshot_path"
|
||||
}
|
Loading…
Reference in New Issue
Block a user