wayland-screenshot/wayland-screenshot at master · onokatio/wayland-screenshot
2021-11-23 17:24:35 Author: github.com(查看原文) 阅读量:6 收藏

Permalink

Cannot retrieve contributors at this time

#!/bin/bash
FILEDIR=~/Downloads
OPTION=()
values=$(zenity \
--title=wayland-screenshot \
--text="Option" \
--forms \
--add-combo="Mode" \
--combo-values="All screen|Specific window|Specific area" \
--add-combo="Include cursor[default: no]" \
--combo-values="no|yes" \
--add-entry="time to wait[default: 0s]" \
--add-combo="Copy to clipboard[default: yes]" \
--combo-values="yes|no" \
)
result=$?
mode=$(echo $values | cut -d '|' -f 1)
cursor=$(echo $values | cut -d '|' -f 2)
wait=$(echo $values | cut -d '|' -f 3)
clipboard=$(echo $values | cut -d '|' -f 4)
if [ "$result" -eq 1 ];then # select cancel
echo "canceling"
exit
fi
if [ ! -z "$cursor" ] && [ "$cursor" == yes ];then
OPTION+="-c"
fi
if [ -z "$mode" ] ;then # select nothing
echo "mode is null"
zenity \
--title=wayland-screenshot \
--width=200 \
--warning \
--text="Mode empty"
exit
fi
if [ ! -z "$wait" ];then
sleep $wait
fi
if [ "$mode" == "All screen" ];then # select All screen
true
elif [ "$mode" == "Specific window" ];then # select specify window
GEO="$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)"
elif [ "$mode" == "Specific area" ];then # select specfy area
GEO="$(slurp)"
else # error
echo $mode
fi
if [ -z "$clipboard" ] || [ "$clipboard" == yes ];then
if [ -z "$GEO" ]; then
grim $OPTION - | wl-copy;
else
grim $OPTION -g "$GEO" - | wl-copy;
fi
else
if [ -z "$GEO" ]; then
grim $OPTION $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png
else
grim $OPTION -g "$GEO" $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png
fi
fi

文章来源: https://github.com/onokatio/wayland-screenshot/blob/master/wayland-screenshot
如有侵权请联系:admin#unsafe.sh