Brain Overflow

Making Grim Save to the Right Directory (Sway)

I had this nagging issue with grim where it would dump my screenshots straight into my home directory regardless of what I set the GRIM_DEFAULT_DIR environment variable to.

There's even an issue that describes my exact problem! I use fish just like the issue submitter (so my hopes were up when I found that thread!)...but the solutions described didn't work for me, naturally.

I tried setting the environment variable in as many ways as possible and reloaded my sway config every time I changed something, just in case:

I also checked the user running the sway process -- it was in fact my user.

Eventually I tried comparing running grim in a shell versus hitting the hotkey. It started to work if I ran grim in a shell (both bash and fish), but my hotkey still didn't respect it.

I went for broke and decided to try adding bash -c to my sway config line. This feels stupid, but I was willing to go there.

Didn't help, but...

Finally, I tried fish instead, and it worked. To be crystal clear about it, this is the change I made:

- bindsym Print exec grim
- bindsym Alt+Print exec grim -g "$(slurp -d)"
+ bindsym Print exec fish -c grim
+ bindsym Alt+Print exec fish -c 'grim -g "$(slurp -d)"'

I'm not sure why it was so painful, but maybe this will help someone out there.

#linux #troubleshooting