dotfiles/scripts/screenshot

40 lines
938 B
Bash
Executable file

#!/bin/bash
if [ $(hostname) = "syl" ]; then
if [ $XDG_SESSION_TYPE = "x11" ]; then
style="laptop-search"
else
style="laptop-search-wayland"
fi
else
style="desktop-search"
#echo "this is not hidpi"
fi
timestamp=$(date +%F-%T)
picture=$(maim --hidecursor --select /tmp/$timestamp.png)
declare -a options=(
"clipboard"
"filesave"
"cancel"
)
choice=$(printf '%s\n' "${options[@]}" | rofi -theme /home/chris/.config/rofi/launchers-git/$style.rasi -dmenu -p 'Clip or Save')
if [[ "$choice" == "cancel" ]]; then
rm /tmp/$timestamp.png
echo "Canceled." && exit 1
elif [ "$choice" == "clipboard" ]; then
xclip -selection clipboard -target image/png -i /tmp/$timestamp.png
rm /tmp/$timestamp.png
echo 'saved to clipboard'
elif [ "$choice" == "filesave" ]; then
mv /tmp/$timestamp.png ~/Pictures/$timestamp.png
echo 'saved to ~/Pictures/'$timestamp'.png'
fi