grim-wrapper: add output name to filename and allow out path override
This commit is contained in:
parent
7da04253c3
commit
4c5c775258
1 changed files with 4 additions and 3 deletions
|
@ -5,7 +5,8 @@ let
|
|||
grim-wrapper =
|
||||
pkgs.writeShellScript "grim-wrapper" # bash
|
||||
''
|
||||
OUTPUT_DIR="$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)"
|
||||
OUTPUT_DIR="''${OUTPUT_DIR:-$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)}";
|
||||
OUTPUT_NAME="''${OUTPUT_NAME:-}";
|
||||
DATE="$(${pkgs.coreutils}/bin/date +'%Y-%m-%d;%H:%M:%S;')";
|
||||
WINDOW_LIST="$(${pkgs.sway-unwrapped}/bin/swaymsg -t get_tree | ${pkgs.jq}/bin/jq -r '.. | select(.pid? and .visible?) | "\(.rect.x+.window_rect.x),\(.rect.y+.window_rect.y) \(.window_rect.width)x\(.window_rect.height) \(.app_id):\(.name)"' | ${pkgs.coreutils}/bin/tr -d '"/;\\')";
|
||||
|
||||
|
@ -16,7 +17,7 @@ let
|
|||
SELECTION="$(${pkgs.slurp}/bin/slurp -d -f "''${SELECTION_FORMAT}" <<< ''${WINDOW_LIST})";
|
||||
SELECTION_AREA="$(${pkgs.jq}/bin/jq -r '.area' <<< "''${SELECTION}")";
|
||||
SELECTION_NAME="$(${pkgs.jq}/bin/jq -r '.name' <<< "''${SELECTION}"| ${pkgs.coreutils}/bin/tr ' ' '_')";
|
||||
OUTNAME="''${OUTPUT_DIR}/''${DATE}''${SELECTION_NAME}.png";
|
||||
OUTNAME="''${OUTPUT_DIR}/''${OUTPUT_NAME:-''${DATE}''${SELECTION_NAME}}.png";
|
||||
${pkgs.grim}/bin/grim -g "''${SELECTION_AREA}" "''${OUTNAME}";
|
||||
;;
|
||||
clip)
|
||||
|
@ -26,7 +27,7 @@ let
|
|||
*)
|
||||
DISPLAY="$(${pkgs.sway-unwrapped}/bin/swaymsg -t get_outputs | ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name')";
|
||||
DISPLAY_RES="$(${pkgs.sway-unwrapped}/bin/swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .current_mode | "\(.width)x\(.height)"')";
|
||||
OUTNAME="''${OUTPUT_DIR}/''${DATE}''${DISPLAY_RES};''${DISPLAY};.png"
|
||||
OUTNAME="''${OUTPUT_DIR}/''${OUTPUT_NAME:-''${DATE}''${DISPLAY_RES};''${DISPLAY};}.png"
|
||||
${pkgs.grim}/bin/grim -o "''${DISPLAY}" "''${OUTNAME}";
|
||||
;;
|
||||
esac;
|
||||
|
|
Loading…
Add table
Reference in a new issue