Screenshot : Group screenshots by focused window id or name.
This commit is contained in:
parent
5b56b00eda
commit
de7cbef664
|
@ -10,18 +10,27 @@
|
||||||
in {
|
in {
|
||||||
text = let
|
text = let
|
||||||
picEdit = ''| swappy -f - -o -'';
|
picEdit = ''| swappy -f - -o -'';
|
||||||
picFile = ''scrFile="''${XDG_PICTURES_DIR[0]}/$(date +${format}).png"'';
|
|
||||||
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
||||||
picSelect = ''-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'';
|
||||||
vidFile = ''scrFile="''${XDG_VIDEOS_DIR[0]}/$(date +${format}).${container}"'';
|
|
||||||
vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
vidFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
||||||
vidSelect = ''--geometry "''${scrSelection}"'';
|
vidSelected = ''--geometry "''${scrSelection}"'';
|
||||||
vidStop = ''pkill -SIGINT wf-recorder'';
|
vidStop = ''pkill -SIGINT wf-recorder'';
|
||||||
|
|
||||||
|
prepFile = path: ext: ''
|
||||||
|
curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .app_id'))
|
||||||
|
[[ "''${curWindow}" = "null" ]] && curWindow=$(parse_snake $(swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .name'))
|
||||||
|
scrDir="${path}/''${curWindow}"
|
||||||
|
mkdir -p "''${scrDir}"
|
||||||
|
scrFile="''${scrDir}/$(date +${format}).${ext}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
vidPrepFile = prepFile "\${XDG_VIDEOS_DIR[0]}" container;
|
||||||
|
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";
|
||||||
|
|
||||||
getSelection = ''
|
getSelection = ''
|
||||||
scrSelection=$(${selection})
|
scrSelection=$(${selection})
|
||||||
[[ -n "''${scrSelection}" ]] || exit
|
[[ -n "''${scrSelection}" ]] || exit
|
||||||
|
@ -70,10 +79,10 @@ in {
|
||||||
SelectRecording = pkgs.writeShellScriptBin "SelectRecording" ''
|
SelectRecording = pkgs.writeShellScriptBin "SelectRecording" ''
|
||||||
${vidStop} || {
|
${vidStop} || {
|
||||||
${getSelection}
|
${getSelection}
|
||||||
${vidFile}
|
|
||||||
${getTransform}
|
${getTransform}
|
||||||
|
${vidPrepFile}
|
||||||
${updateWaybar}
|
${updateWaybar}
|
||||||
${vidStart} ${vidSelect}
|
${vidStart} ${vidSelected}
|
||||||
${vidMuxAudio}
|
${vidMuxAudio}
|
||||||
${vidTransform}
|
${vidTransform}
|
||||||
${updateWaybar}
|
${updateWaybar}
|
||||||
|
@ -82,8 +91,8 @@ in {
|
||||||
|
|
||||||
FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" ''
|
FullscreenRecording = pkgs.writeShellScriptBin "FullscreenRecording" ''
|
||||||
${vidStop} || {
|
${vidStop} || {
|
||||||
${vidFile}
|
|
||||||
${getTransform}
|
${getTransform}
|
||||||
|
${vidPrepFile}
|
||||||
${updateWaybar}
|
${updateWaybar}
|
||||||
${vidStart} ${vidFull}
|
${vidStart} ${vidFull}
|
||||||
${vidMuxAudio}
|
${vidMuxAudio}
|
||||||
|
@ -93,28 +102,22 @@ in {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" ''
|
FullscreenScreenshot = pkgs.writeShellScriptBin "FullscreenScreenshot" ''
|
||||||
${picFile}
|
${picPrepFile}
|
||||||
|
|
||||||
${screenshot} ${picFull} ${picToFile} ${picToBuffer}
|
${screenshot} ${picFull} ${picToFile} ${picToBuffer}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" ''
|
SelectScreenshot = pkgs.writeShellScriptBin "SelectScreenshot" ''
|
||||||
${getSelection}
|
${getSelection}
|
||||||
${picFile}
|
${picPrepFile}
|
||||||
|
|
||||||
${screenshot} ${picSelect} ${picEdit} ${picToFile} ${picToBuffer}
|
${screenshot} ${picSelected} ${picEdit} ${picToFile} ${picToBuffer}
|
||||||
'';
|
'';
|
||||||
in ''
|
in ''
|
||||||
# Fullscreen screenshot.
|
bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot}
|
||||||
bindsym --to-code $mod+y exec ${lib.getExe FullscreenScreenshot}
|
|
||||||
|
|
||||||
# Fullscreen recording.
|
|
||||||
bindsym --to-code $mod+shift+y exec ${lib.getExe FullscreenRecording}
|
bindsym --to-code $mod+shift+y exec ${lib.getExe FullscreenRecording}
|
||||||
|
|
||||||
# Select screenshot.
|
bindsym --to-code $mod+v exec ${lib.getExe SelectScreenshot}
|
||||||
bindsym --to-code $mod+v exec ${lib.getExe SelectScreenshot}
|
|
||||||
|
|
||||||
# Select recording.
|
|
||||||
bindsym --to-code $mod+shift+v exec ${lib.getExe SelectRecording}
|
bindsym --to-code $mod+shift+v exec ${lib.getExe SelectRecording}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue