Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-monitor support #1

Merged
merged 2 commits into from Jul 9, 2021
Merged

Conversation

adamhotep
Copy link
Contributor

Added (slightly better) support for multiple monitors. When sxiv goes full-screen, it is on a per-monitor basis. Adding -Z ensures that if you're on the top-left monitor, this works as expected. Monitors will open full-screen views of the screenshot with the top left pixel of the monitor showing the top left pixel of the screenshot, so you'll see the wrong content on any other monitor.

I also used trap to ensure $tmpfile is cleaned up regardless of whether the script is terminated.

Nice observations on speed! maim is a lot faster than ImageMagick's import and sxiv is quite speedy as well. The script will be slightly faster using /bin/sh over /bin/bash (which would be slightly faster than /usr/bin/env bash), and since there are no bashisms, the more basic POSIX shell is functionally identical.

Added support for multiple monitors. While sxiv defaults to full-screen, this is limited to the current monitor. Adding `-Z` ensures that if you're on the top-left monitor, this works as expected. Monitors will open full-screen views of the screenshot with the top left pixel of the _monitor_ showing the top left pixel of the screenshot, which is only appropriate on the top-left-most monitor.

I also used `trap` to ensure `$tmpfile` is cleaned up regardless of whether the script is terminated. 

Nice observations on speed! `maim` is a _lot_ faster than ImageMagick's `import` and `sxiv` is quite speedy as well. The script will be slightly faster using `/bin/sh` over `/bin/bash` (which would be slightly faster than `/usr/bin/env bash`), and since there are no bashisms, the more basic POSIX shell is functionally identical.
@yassinebridi
Copy link
Owner

These are some really good remarks, things that I haven't thought about.

One thing though, have you checked if this script is working without any error?
Apparently the trap command fails to execute the removing of the file, and just throws an error instantly.

@adamhotep
Copy link
Contributor Author

Yeah, you caught me having not tested my code. I'm not sure how the CHLD signal got in there, it triggered on each child process termination (including itself‽), which was not desired. I've fixed that and actually tested. I also added -f just to be sure it doesn't generate an error, though that shouldn't happen any more.

@yassinebridi yassinebridi merged commit abf9fb5 into yassinebridi:master Jul 9, 2021
@yassinebridi
Copy link
Owner

Thank you @adamhotep for this change.

@adamhotep adamhotep deleted the patch-1 branch November 8, 2021 00:57
@what-the-diff
Copy link

what-the-diff bot commented Nov 28, 2022

  • The shebang was changed from bash to sh
  • A trap command was added that removes the temp file on exit
  • The rm "$tmpfile" line at the end of the script is removed, as it's no longer needed with our new trap statement in place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants