I’m trying to invoke scrot with a bindsym so I have a keyboard shortcut to take screenshots

This command works when run as a one-liner or as a bash .sh:

save_dir="/home/dork/apache/drkt.eu/subdomains/u/";
random_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1).png;
scrot -s "$save_dir/$random_name";
echo -n "https://u.drkt.eu/$random_name" | xsel --clipboard

It does not work when ran by i3 bindsym $mod+Shift+Z exec bash -c save_dir="/home/dork/apache/drkt.eu/subdomains/u/"; random_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1).png; scrot -s "$save_dir/$random_name"; echo -n "https://u.drkt.eu/$random_name" | xsel --clipboard

i3 reports an error when the above is run, but not when as a shell script, though neither work. I assume that’s just because bash is eating the error and not reporting it back to i3

This is the error when ran as a one-liner:

ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ExposeEvent for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600000
ERROR: Received ConfigureNotify for unknown window 0x00600007
ERROR: Received ExposeEvent for unknown window 0x00600007
ERROR: Received ConfigureNotify for unknown window 0x00600007
ERROR: Received ConfigureNotify for unknown window 0x0060000a
ERROR: Received ExposeEvent for unknown window 0x0060000a
ERROR: Received ConfigureNotify for unknown window 0x0060000a
ERROR: Received ConfigureNotify for unknown window 0x0060000d
ERROR: Received ExposeEvent for unknown window 0x0060000d
ERROR: Received ConfigureNotify for unknown window 0x0060000d
ERROR: Received ConfigureNotify for unknown window 0x00600010
ERROR: Received ConfigureNotify for unknown window 0x00600010
ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'sticky', 'split', 'floating', 'mark', 'unmark', 'resize', 'rename', 'nop', 'scratchpad', 'swap', 'title_format', 'title_window_icon', 'mode', 'bar', 'gaps'
ERROR: Your command: exec bash -c save_dir="/home/dork/apache/drkt.eu/subdomains/u/"; random_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1).png; scrot -s "$save_dir/$random_name"; echo -n "https://u.drkt.eu/$random_name" | xsel --clipboard
ERROR:                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/run/user/1000/i3/errorlog.1235 (END)

I am open to alternatives if there is a better way to do this than the i3 config!

Thank you for reading <3