openSUSE / openSUSEway

dotfiles for Sway on openSUSE
MIT License
82 stars 17 forks source link

Add screenshot utility configuration #117

Closed FilippoBonazziSUSE closed 5 months ago

FilippoBonazziSUSE commented 1 year ago

This is my screenshot configuration using grim and slurp. It allows to:

Before I merge this PR, I want to open this to contributions if others have better configurations.

FilippoBonazziSUSE commented 1 year ago

I just realized I have one more change on my side: I have also set the environment variable

GRIM_DEFAULT_DIR="$HOME/Pictures/screenshots/"

Otherwise, if not configured, I think grim pollutes your home directory with your screenshots. Suggestions on how to handle this?

I would propose to set this environment variable as a default, and users can then easily override it. I think $HOME/Pictures/screenshots/ is a decent default, so I would go with that unless there are other suggestions.

denisok commented 1 year ago

I just realized I have one more change on my side: I have also set the environment variable

GRIM_DEFAULT_DIR="$HOME/Pictures/screenshots/"

Otherwise, if not configured, I think grim pollutes your home directory with your screenshots. Suggestions on how to handle this?

yeah, I have it like that and am just used to it. But you are right - having a special directory for it - is handy.

I would propose to set this environment variable as a default, and users can then easily override it. I think $HOME/Pictures/screenshots/ is a decent default, so I would go with that unless there are other suggestions.

The problem with that - the directory could be absent, so grim will fail and ppl will be confused about screenshots aren't taken.

https://wiki.archlinux.org/title/XDG_user_directories

one hacky way is probably to detect if XDG_PICTURES_DIR is empty and set some default one in https://github.com/openSUSE/openSUSEway/blob/main/sway/sway-run.sh that we know exists (also could be checked). Maybe even create one :) $XDG_PICTURES_DIR/screenshots.

FilippoBonazziSUSE commented 1 year ago

Launching grim with an invalid GRIM_DEFAULT_DIR will place the screenshot in the current directory, when launched on the command line. I see how this could break when grim is launched from within sway... what would be the current directory in that case? Would it be writable?

If we need to create one folder I would agree to go through the XDG folders.

denisok commented 1 year ago

ok, I didn't notice that it is a standard env for grim:

grim will write an image to _output-file_, or to a timestamped file name in
*$GRIM_DEFAULT_DIR* if not specified. If *$GRIM_DEFAULT_DIR* is not set, it
falls back first to *$XDG_PICTURES_DIR* and then to the current working
directory. If _output-file_ is *-*, grim will write the image to the standard
output instead.

So I think we shouldn't care now. But when we do the proper installation that is probably on of the ToDo - to create standard dirs and set up XDG vars.

FilippoBonazziSUSE commented 5 months ago

Follow up in #131