Assorted shell and Python scripts
1#!/usr/bin/env bash 2# 3# Rofi powered menu to take a screenshot of the whole screen, a selected area or 4# the active window. The image is then saved and copied to the clipboard. 5# Uses: date maim notify-send rofi xclip xdotool 6# 7# This is lifted from https://gitlab.com/vahnrr/rofi-menus and modified by 8# hyperreal <hyperreal64@pm.me> on 2023-09-06T15:09:58-05:00 9 10save_location="${HOME}/Nextcloud/pictures/screenshots" 11if ! test -d "${HOME}/Nextcloud/pictures/screenshots"; then 12 mkdir "${HOME}/Nextcloud/pictures/screenshots" 13fi 14screenshot_path="$save_location/$(date +'%Y-%m-%d-%H%M%S').png" 15 16screen=' Screen' 17area=' Select area' 18window=' Window' 19 20chosen=$(printf '%s;%s;%s' "$screen" "$area" "$window" | 21 rofi -theme-str 'window { width: 10em; height: 10em; }' \ 22 -P 'Screenshot' \ 23 -dmenu \ 24 -sep ';' \ 25 -selected-row 1) 26 27case "$chosen" in 28"$screen") extra_args='--delay=1' ;; 29"$area") extra_args='--delay=0.1 --select --highlight --color=0.85,0.87,0.91,0.2' ;; 30"$window") extra_args="--delay=1 --window=$(xdotool getactivewindow)" ;; 31*) exit 1 ;; 32esac 33 34# The variable is used as a command's options, so it shouldn't be quoted. 35# shellcheck disable=2086 36maim --hidecursor --quiet --quality=10 --format='png' $extra_args "$screenshot_path" && { 37 notify-send --icon=org.xfce.screenshooter "Screenshot saved as $screenshot_path" 38}