├── Screenshot_2020-05-13_01:45:50.png ├── wayland-screenshot.desktop ├── README.md └── wayland-screenshot /Screenshot_2020-05-13_01:45:50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onokatio/wayland-screenshot/HEAD/Screenshot_2020-05-13_01:45:50.png -------------------------------------------------------------------------------- /wayland-screenshot.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=wayland-screenshot 3 | Comment=Take screenshot on wayland 4 | Exec=wayland-screenshot 5 | Terminal=false 6 | Type=Application 7 | Encoding=UTF-8 8 | Icon=xterm-color_48x48 9 | Categories=System;TerminalEmulator; 10 | Keywords=screenshot;wayland; 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wayland-screenshot 2 | 3 | ## Depends 4 | 5 | - grim 6 | - slurp 7 | - zenity 8 | - jq 9 | - wl-clipboard 10 | 11 | ## Install 12 | 13 | - Archlinux(AUR) 14 | 15 | ``` 16 | $ yay -S wayland-screenshot-git 17 | ``` 18 | 19 | - Manual 20 | 21 | ``` 22 | $ sudo cp ./wayland-screenshot /usr/local/bin/ 23 | $ sudo cp ./wayland-screenshot.desktop /usr/local/share/applications/ 24 | ``` 25 | 26 | 27 | ## Usage 28 | 29 | Run `wayland-screenshot.desktop` from menu entry, or run `wayland-screenshot` on terminal. 30 | Select mode, then press OK. 31 | Screenshots are saved to `~/Downloads/Screenshot_*`. 32 | 33 | ![](/Screenshot_2020-05-13_01:45:50.png) 34 | 35 | ## Use floting window on sway 36 | 37 | ``` 38 | for_window [app_id="zenity"] floating enable 39 | ``` 40 | -------------------------------------------------------------------------------- /wayland-screenshot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FILEDIR=~/Downloads 4 | OPTION=() 5 | 6 | values=$(zenity \ 7 | --title=wayland-screenshot \ 8 | --text="Option" \ 9 | --forms \ 10 | --add-combo="Mode" \ 11 | --combo-values="All screen|Specific window|Specific area" \ 12 | --add-combo="Include cursor[default: no]" \ 13 | --combo-values="no|yes" \ 14 | --add-entry="time to wait[default: 0s]" \ 15 | --add-combo="Copy to clipboard[default: yes]" \ 16 | --combo-values="yes|no" \ 17 | ) 18 | 19 | result=$? 20 | 21 | mode=$(echo $values | cut -d '|' -f 1) 22 | cursor=$(echo $values | cut -d '|' -f 2) 23 | wait=$(echo $values | cut -d '|' -f 3) 24 | clipboard=$(echo $values | cut -d '|' -f 4) 25 | 26 | if [ "$result" -eq 1 ];then # select cancel 27 | echo "canceling" 28 | exit 29 | fi 30 | 31 | if [ ! -z "$cursor" ] && [ "$cursor" == yes ];then 32 | OPTION+="-c" 33 | fi 34 | 35 | if [ -z "$mode" ] ;then # select nothing 36 | echo "mode is null" 37 | zenity \ 38 | --title=wayland-screenshot \ 39 | --width=200 \ 40 | --warning \ 41 | --text="Mode empty" 42 | exit 43 | fi 44 | 45 | if [ ! -z "$wait" ];then 46 | sleep $wait 47 | fi 48 | 49 | if [ "$mode" == "All screen" ];then # select All screen 50 | true 51 | elif [ "$mode" == "Specific window" ];then # select specify window 52 | GEO="$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)" 53 | elif [ "$mode" == "Specific area" ];then # select specfy area 54 | GEO="$(slurp)" 55 | else # error 56 | echo $mode 57 | fi 58 | 59 | if [ -z "$clipboard" ] || [ "$clipboard" == yes ];then 60 | if [ -z "$GEO" ]; then 61 | grim $OPTION - | wl-copy; 62 | else 63 | grim $OPTION -g "$GEO" - | wl-copy; 64 | fi 65 | else 66 | if [ -z "$GEO" ]; then 67 | grim $OPTION $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png 68 | else 69 | grim $OPTION -g "$GEO" $FILEDIR/Screenshot_$(date +%F_%H.%M.%S).png 70 | fi 71 | fi 72 | --------------------------------------------------------------------------------