Closed roland-5 closed 2 years ago
Hi, first of all thank you for the very thorough bug report.
slurp is the external program we call as a helper to grab screen coordinates so if you can run that separately, put it in a variable and then call the variable after the -s
argument, I believe it'll work.
The examples provided in the repo are with a posix shell in mind, there is no shell specific code inside of wayshot itself at the end of the day so I can't really support fish per se. The commands just need to be adapted to it.
Hi, first of all thank you for the very thorough bug report. slurp is the external program we call as a helper to grab screen coordinates so if you can run that separately, put it in a variable and then call the variable after the
-s
argument, I believe it'll work.You mean?
wayshot -f ~/ps_(date +"%Y%m%d%H%M%S").png -s "(slurp -f '%x %y %w %h')"
It gives the same error as previously.
The examples provided in the repo are with a posix shell in mind, there is no shell specific code inside of wayshot itself at the end of the day so I can't really support fish per se. The commands just need to be adapted to it.
The fact that the examples are given as POSIX is fine, because Sway creates its environment anyway: therefore the bindsym I provided for grim work, although they are written for bash and not fish. If fish syntax were important here, they wouldn't work in Sway (the grim shouldn't be able to handle it either). And two converted bindsym are working without problem with Wayshot. In addition, by typing these commands in the console, the errors that show up to me should not show up, so Wayshot has a problem with something that can be seen in the Sway + fish combination, but not with Sway + bash. Or maybe I understating this wrong (I'm not programmer), but if it something wrong in Fish I can't alarm they, as I don't understand what makes errors.
I'm not sure if I completely understand the issue but the error that wayshot threw means that a proper integer wasn't passed by slurp to wayshot
Maybe try notify sending the variable for confirmation? The error code looks fine with respect to the syntax to me but then again I'm not a fish user so you probably know better:D
It will be a tough topic. :P First of all, I can't write commands in Sway config with fish syntax, they will just don't work (Sway will ignore them), that's why I wrote earlier that the examples from README are well written as POSIX. So converting them with fish syntax in Sway config make no much sense. Yeah It looks like problem is in Wayshot with interpretation data from Slurp. My theory is that the data Slurp throws into Wayshot is related to the build of the Fish, even though the Sway commands themselves must be written in Bash. Grim can either process Slurp results from Fish or Grim gets Slurp results differently from Wayshot, so Grim has no problem.
If I write in fish this:
grim -g (slurp) ~/ps_(date +"%Y%m%d%H%M%S").png
It's just do screenshot of selected area without problem.
But for Wayshot, doesn't work:
wayshot -s (slurp) -f ~/ps_(date +"%Y%m%d%H%M%S").png
But this work in console great:
wayshot -s (slurp -f '%x %y %w %h') -f ~/ps_(date +"%Y%m%d%H%M%S").png
So my lazy ass was thinking grim -g (slurp)
work different than wayshot -s (slurp -f '%x %y %w %h')
. So somewere in this is problem (for people using Sway+fish). Why I can just do slurp for grim, but for wayshot I need to add -f '%x %y %w %h'
?
I'm not sure if I completely understand the issue but the error that wayshot threw means that a proper integer wasn't passed by slurp to wayshot
Maybe try notify sending the variable for confirmation? The error code looks fine with respect to the syntax to me but then again I'm not a fish user so you probably know better:D
I was a fish user. lemme try
Where is this bindsym command come from? Sway config does not use fish. So you misunderstood the first two commands as fish running it.
If you want to make it run fish do:
bindsym 2 exec "fish -c 'wayshot --stdout | wl-copy'"
bindsym 3 exec "fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'"
Hi,
I use fish as shell and Sway as WM, and I believe one of it, causing problems with some commands that I try convert from grim to wayshot:
What works:
bindsym 1 exec 'wayshot -f ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default" bindsym 2 exec 'wayshot --stdout | wl-copy', mode "default"
What I couldn't make convert:
bindsym 3 exec 'grim -g "$(slurp)" ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default" bindsym 4 exec 'grim -g "$(slurp)" - | wl-copy', mode "default"
I tried to convert them to like this, but from Sway they don't wont to work (nothing happens):
* For bindsym 3 tried to make it:
wayshot -s "$(slurp -f '%x %y %w %h')" -f ~/ps_$(date +"%Y%m%d%H%M%S").png
If I try from console:
wayshot -s "(slurp -f '%x %y %w %h')" -f ~/ps_(date +"%Y%m%d%H%M%S").png 5m26s/23:53 thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/wayshot.rs:73:69 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
If I try in
bash
wayshot -s "$(slurp -f '%x %y %w %h')" -f ~/ps_$(date +"%Y%m%d%H%M%S").png
It' just working.
* For bindsym 4 tried to make it:
wayshot -s "$(slurp -f '%x %y %w %h')" --stdout | wl-copy
If I try from console:
wayshot -s "(slurp -f '%x %y %w %h')" --stdout | wl-copy thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/wayshot.rs:73:69 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
If I try in
bash
wayshot -s "$(slurp -f '%x %y %w %h')" --stdout | wl-copy
It' just working.
In summary to all the misunderstandings. Fish is not POSIX or has its own syntax not common to POSIX-compliant shells. Sway uses sh
in the backend to call commands through bindsym so using the fish -c "uwu this is my command"
is the only thing u can do here. also to call slurp using fish, just use the parentheses and remove $
since fish does not support $()
-> which is an invocation of a new shell and not to be confused as environmental variables.
I think that pretty much answers it, I'll wait for the author to reply.
Where is this bindsym command come from? Sway config does not use fish. So you misunderstood the first two commands as fish running it.
If you want to make it run fish do:
bindsym 2 exec "fish -c 'wayshot --stdout | wl-copy'" bindsym 3 exec "fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'"
Thank you @uncomfyhalomacro for answers and explonations, but... It didn't help.
Edit: I thought tham maybe wayshot-git package from Arch AUR have problems, but bin versions give me the same error.
Initially the command you ran gave me an error too, but applying some basic debugging knowledge, i removed the \
from the slurp command and it worked.
I copied the @uncomfyhalomacro uncomfyhalomacro proposal but in the video he did not actually give any slashes, and then, indeed it work in console, as you write. But it is not working from Sway.
bindsym 3 exec "fish -c 'wayshot -s (slurp -f "%x %y %w %h") --stdout | wl-copy'", mode "default"
I have no idea how to debbug it and maybe it's time for me to give up. I will try in future.
I get that it's frustrating, but I'm not giving up ;)
bindsym 3 exec 'fish -c wayshot -s (slurp -f "%x %y %w %h") --stdout | wl-copy', mode "default"
what about this?
Worst case scenario, we can just put all of this in a bash script and then call the script with bindkeys.
i will try in sway. zzzz i will report later
I copied the @uncomfyhalomacro uncomfyhalomacro proposal but in the video he did not actually give any slashes, and then, indeed it work in console, as you write. But it is not working from Sway.
bindsym 3 exec "fish -c 'wayshot -s (slurp -f "%x %y %w %h") --stdout | wl-copy'", mode "default"
I have no idea how to debbug it and maybe it's time for me to give up. I will try in future.
i didnt put any slashes because i dont have to escape them. but in bindsym, u have to. i think u have to escape |
as well but imma try sway. later
@roland-rollo here it works. with bindsym Print exec fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | swappy -f -', mode "default"
Tysm cutie @uncomfyhalomacro
@Shinyzenith close this. zzzzzzzzz
lets wait for author to confirm if it's fixed
Sorry for taking so long to answer, but work has sucked my life out of me lately. Something is definitely wrong from my side. If I try
bindsym Print exec fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | swappy -f -', mode "default"
Appear black window that do nothing and I can select any region to copy.
Either I have something strangely set in the fish or something related to the Rust environment is missing, because I typed in the console
fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/wayshot.rs:73:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', src/wayshot.rs:73:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I can select region with slurp but after this it give me this error.
It works for you, so the problem is mine. I do not know if someone from Fish will be able to answer me, but I will send this problem and maybe they will let me know if my configuration file is doing something wrong. I really appreciate your commitment and help. <3
@roland-rollo you should remove the backslashes on the shell. but on the sway config, you should add it. fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'
and it should work well in sway config because the \
escapes the "
. but if you are on fish shell fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'
wont work because fish does not recognize \
trying to escape "
so running fish -c 'wayshot -s (slurp -f "%x %y %w %h") --stdout | wl-copy'
without the backslashes \
will work.
EDIT: if you want to know why i noticed that, it is because of the Error message ParseIntError
. This means that the geometry format is returning something that is not a number. It might be \
or "
or both because like i said before, fish does not know \
is to escape something
Sorry for taking so long to answer, but work has sucked my life out of me lately. Something is definitely wrong from my side. If I try
Take it easy 🫂.
It works for you, so the problem is mine. I do not know if someone from Fish will be able to answer me, but I will send this problem and maybe they will let me know if my configuration file is doing something wrong.
I will install fish and sway tomorrow, get to the bottom of this and let you know.
@roland-rollo you should remove the backslashes on the shell. but on the sway config, you should add it.
fish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'
and it should work well in sway config because the\
escapes the"
. but if you are on fish shellfish -c 'wayshot -s (slurp -f \"%x %y %w %h\") --stdout | wl-copy'
wont work because fish does not recognize\
trying to escape"
so runningfish -c 'wayshot -s (slurp -f "%x %y %w %h") --stdout | wl-copy'
without the backslashes\
will work.EDIT: if you want to know why i noticed that, it is because of the Error message
ParseIntError
. This means that the geometry format is returning something that is not a number. It might be\
or"
or both because like i said before, fish does not know\
is to escape something
I tried with backslashes and without in Sway config and terminal. :P I tried many combinations (changing '
to "
and vice versa and more) and it was always the same results. Adding fish -c
didn't help (bash -c
or sh -c
too), but I updated to Fish 3.4.1 and... It finally works:
# Screen capture
#
set $screenshot 1 selected, 2 whole, 3 selected clipboard, 4 whole clipboard
mode "$screenshot" {
bindsym 1 exec 'wayshot -s "$(slurp -f \"%x %y %w %h\")" -f ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default"
bindsym 2 exec 'wayshot -f ~/ps_$(date +"%Y%m%d%H%M%S").png', mode "default"
bindsym 3 exec 'wayshot -s "$(slurp -f \"%x %y %w %h\")" --stdout | wl-copy', mode "default"
bindsym 4 exec 'wayshot --stdout | wl-copy', mode "default"
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
bindsym $mod+Print mode "default"
}
bindsym $mod+Print mode "$screenshot"
Thank you all! <3
Hi,
I use fish as shell and Sway as WM, and I believe one of it, causing problems with some commands that I try convert from grim to wayshot:
What works:
What I couldn't make convert:
I tried to convert them to like this, but from Sway they don't wont to work (nothing happens):
If I try from console:
If I try in
bash
It' just working.
If I try from console:
If I try in
bash
It' just working.