Screenshot : Add Latest ref file for easy edit.
This commit is contained in:
parent
6ca438ed37
commit
7451477d06
|
@ -9,14 +9,18 @@
|
||||||
pixfmt = "yuv420p10le";
|
pixfmt = "yuv420p10le";
|
||||||
in {
|
in {
|
||||||
text = let
|
text = let
|
||||||
picEdit = ''| swappy -f - -o -'';
|
picEdit = ''swappy -f - -o -'';
|
||||||
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
||||||
|
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";
|
||||||
|
picRefLatestFile = refLatestFile "png";
|
||||||
picSelected = ''-g "''${scrSelection}" -'';
|
picSelected = ''-g "''${scrSelection}" -'';
|
||||||
picToBuffer = ''| wl-copy -t image/png'';
|
picToBuffer = ''wl-copy -t image/png'';
|
||||||
picToFile = ''| tee "''${scrFile}"'';
|
picToFile = ''tee "''${scrFile}"'';
|
||||||
screenshot = ''grim'';
|
screenshot = ''grim'';
|
||||||
updateWaybar = ''pkill -RTMIN+4 waybar'';
|
updateWaybar = ''pkill -RTMIN+4 waybar'';
|
||||||
vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
||||||
|
vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container;
|
||||||
|
vidRefLatestFile = refLatestFile container;
|
||||||
vidSelected = ''--geometry "''${scrSelection}"'';
|
vidSelected = ''--geometry "''${scrSelection}"'';
|
||||||
vidStop = ''pkill -SIGINT wf-recorder'';
|
vidStop = ''pkill -SIGINT wf-recorder'';
|
||||||
|
|
||||||
|
@ -28,16 +32,22 @@ in {
|
||||||
[[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name'))
|
[[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name'))
|
||||||
|
|
||||||
# If no app in focus, use "unknown" dir.
|
# If no app in focus, use "unknown" dir.
|
||||||
[[ "''${curWindow}" -eq "''${curWindow}" ]] && curWindow="unknown"
|
[[ "''${curWindow}" =~ ^[0-9]+$ ]] && curWindow="unknown"
|
||||||
|
|
||||||
# Prepare dir and file path.
|
# Prepare dir and file path.
|
||||||
|
scrPath="${path}"
|
||||||
scrDir="${path}/''${curWindow}"
|
scrDir="${path}/''${curWindow}"
|
||||||
mkdir -p "''${scrDir}"
|
mkdir -p "''${scrDir}"
|
||||||
scrFile="''${scrDir}/$(date +${format}).${ext}"
|
scrName="$(date +${format}).${ext}"
|
||||||
|
scrFile="''${scrDir}/''${scrName}"
|
||||||
|
scrLatestRef="./''${curWindow}/''${scrName}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container;
|
refLatestFile = ext: ''
|
||||||
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";
|
scrLatest="''${scrPath}/Latest.${ext}"
|
||||||
|
rm "''${scrLatest}"
|
||||||
|
ln -s "''${scrLatestRef}" "''${scrLatest}"
|
||||||
|
'';
|
||||||
|
|
||||||
getSelection = ''
|
getSelection = ''
|
||||||
scrSelection=$(${selection})
|
scrSelection=$(${selection})
|
||||||
|
@ -93,6 +103,7 @@ in {
|
||||||
${vidStart} ${vidSelected}
|
${vidStart} ${vidSelected}
|
||||||
${vidMuxAudio}
|
${vidMuxAudio}
|
||||||
${vidTransform}
|
${vidTransform}
|
||||||
|
${vidRefLatestFile}
|
||||||
${updateWaybar}
|
${updateWaybar}
|
||||||
};
|
};
|
||||||
'';
|
'';
|
||||||
|
@ -105,6 +116,7 @@ in {
|
||||||
${vidStart} ${vidFull}
|
${vidStart} ${vidFull}
|
||||||
${vidMuxAudio}
|
${vidMuxAudio}
|
||||||
${vidTransform}
|
${vidTransform}
|
||||||
|
${vidRefLatestFile}
|
||||||
${updateWaybar}
|
${updateWaybar}
|
||||||
};
|
};
|
||||||
'';
|
'';
|
||||||
|
@ -112,14 +124,14 @@ in {
|
||||||
FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" ''
|
FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" ''
|
||||||
${picPrepFile}
|
${picPrepFile}
|
||||||
|
|
||||||
${screenshot} ${picFull} ${picToFile} ${picToBuffer}
|
${screenshot} ${picFull} | ${picToFile} | ${picToBuffer} && ${picRefLatestFile}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" ''
|
SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" ''
|
||||||
${getSelection}
|
${getSelection}
|
||||||
${picPrepFile}
|
${picPrepFile}
|
||||||
|
|
||||||
${screenshot} ${picSelected} ${picEdit} ${picToFile} ${picToBuffer}
|
${screenshot} ${picSelected} | ${picEdit} | ${picToFile} | ${picToBuffer} && ${picRefLatestFile}
|
||||||
'';
|
'';
|
||||||
in ''
|
in ''
|
||||||
bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot}
|
bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot}
|
||||||
|
|
Loading…
Reference in a new issue