From 04fe44859e4caef4a0b8300509e72d13a0108630 Mon Sep 17 00:00:00 2001 From: Sebastian Schulze Date: Wed, 5 Jun 2019 13:22:08 +0200 Subject: [PATCH] [bin] Make screenshoter Wayland compatible --- home/bin/drop | 7 ++++++- home/bin/i3-dropshot | 4 +++- home/bin/i3-screenshot | 10 +++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/home/bin/drop b/home/bin/drop index 3be5c7a..2df93cd 100755 --- a/home/bin/drop +++ b/home/bin/drop @@ -16,5 +16,10 @@ Net::SCP.start("drop.bascht.space", "bascht") do |scp| scp.upload(file.expand_path.to_s, "/home/bascht/drop/#{new_name}") end -Open3.popen3( "xclip -i -selection clipboard" ){ |input, _, _| input << url } +if ENV["WAYLAND_DISPLAY"].nil? + Open3.popen3( "xclip -i -selection clipboard" ){ |input, _, _| input << url } +else + system "wl-copy #{url}" +end + system("notify-send 'Uploaded successfully' 'drop.bascht.space'") diff --git a/home/bin/i3-dropshot b/home/bin/i3-dropshot index 07caba9..ec2ddaa 100755 --- a/home/bin/i3-dropshot +++ b/home/bin/i3-dropshot @@ -1,3 +1,5 @@ #!/bin/bash -drop $(i3-screenshot -s) \ No newline at end of file +SHOT=$(i3-screenshot -s) +chmod o+r $SHOT +drop $SHOT diff --git a/home/bin/i3-screenshot b/home/bin/i3-screenshot index 9363f91..8381e86 100755 --- a/home/bin/i3-screenshot +++ b/home/bin/i3-screenshot @@ -1,4 +1,12 @@ #!/bin/bash FOLDER="/home/bascht/Pictures/Screenshots/$(date +'%Y-%m')" mkdir -p ${FOLDER} -escrotum "${FOLDER}/Screenshot-%Y-%m-%d-%H%M%S-\$wx\$h.png" $* + +if [ -z "$WAYLAND_DISPLAY" ]; then + NAME="${FOLDER}/Screenshot-%Y-%m-%d-%H%M%S-\$wx\$h.png" + exec escrotum "$NAME" $* +else + NAME="${FOLDER}/Screenshot-$(date +%Y-%m-%d-%H%M%S).png" + grim -g "$(slurp)" "$NAME"; + echo $NAME +fi;