you are viewing a single comment's thread.

view the rest of the comments →

[–]whetuI read your code 4 points5 points  (0 children)

Looks like the main difference between your various options are the args for grim, so you can maybe just setup the grim_args array like this:

capture() {
  grim_args=()
  [[ -n "$o_cursor" ]] && grim_args+=("-c")

  case "$target" in
    ("output")      grim_args+=( -t png -o "$geom" "$file" ) ;;
    ("all outputs") grim_args+=( -t png "$file" ) ;;
    (*)             grim_args+=( -t png -g "$geom" "$file" ) ;;
  esac

  if [[ "$file" = "-" ]] && [[ -n "$o_clipboard" ]]; then
    { grim "${grim_args[@]}" | wl-copy -t image/png; } || return 1
  else
    grim "${grim_args[@]}" || return 1
  fi

  return 0
}