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

[Grimblast] Error notification when taking a screenshot on second monitor. #137

Open
Atemo-C opened this issue Mar 4, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Atemo-C
Copy link

Atemo-C commented Mar 4, 2025

Program

grimblast

Maintainers of the program

@fufexan @Misterio77

Bug or Regression?

Bug

Description

Image

The screenshot is copied/saved properly, but an error appears.
This only happens when my cursor is on my second monitor when taking a screenshot.

How to reproduce

Command to reproduce

grimblast --notify copy area, and either take a screenshot only on a secondary display, or from the first to the second one.

This happens with area, active, and output.


Relevant part of the script:

takeScreenshot() {
  FILE=$1
  GEOM=$2
  OUTPUT=$3
  if [ -n "$OUTPUT" ]; then
    moveCursorPosition && grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} -o "$OUTPUT" "$FILE" && restoreCursorPosition || die "Unable to invoke grim"
  elif [ -z "$GEOM" ]; then
    grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} "$FILE" || die "Unable to invoke grim"
  else
    moveCursorPosition && grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} -g "$GEOM" "$FILE" && restoreCursorPosition || die "Unable to invoke grim"
  fi
}

(A) Possible solution:

This seems, to my uneducated eyes, like the good old "A && B || C is not if-then-else. C may run when A is true."
if statements may just save our day:

takeScreenshot() {
  FILE=$1
  GEOM=$2
  OUTPUT=$3
  if [ -n "$OUTPUT" ]; then
    moveCursorPosition
    if grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} -o "$OUTPUT" "$FILE"; then
      restoreCursorPosition
    else
      die "Unable to invoke grim"
    fi
  elif [ -z "$GEOM" ]; then
    grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} "$FILE" || die "Unable to invoke grim"
  else
    moveCursorPosition
    if grim ${CURSOR:+-c} ${SCALE:+-s "$SCALE"} -g "$GEOM" "$FILE"; then
      restoreCursorPosition
    else
      die "Unable to invoke grim"
    fi
  fi
}

I am an absolute noob when it comes to shell scripting, so feel free to roast and improve upon this, as long as the error is withered away.

Hyprland crash reports, program logs, images, videos

No response

@fufexan
Copy link
Member

fufexan commented Mar 6, 2025

I cannot reproduce this with your instructions.

@Atemo-C
Copy link
Author

Atemo-C commented Mar 6, 2025

I cannot reproduce this with your instructions.

https://www.youtube.com/watch?v=4I6-rSbFppM
Excuse the poor quality, my phone is very ass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants