Add screenshot sync to Mac via niri
This commit is contained in:
@@ -489,7 +489,7 @@ binds {
|
||||
// Mod+Space { switch-layout "next"; }
|
||||
// Mod+Shift+Space { switch-layout "prev"; }
|
||||
|
||||
Mod+P { screenshot; }
|
||||
Mod+P { spawn "sh" "-c" "niri msg action screenshot && ~/.config/niri/copy-latest-screenshot.sh"; }
|
||||
Mod+Ctrl+P { screenshot-screen; }
|
||||
Mod+Alt+P { screenshot-window; }
|
||||
|
||||
|
||||
29
niri/files/copy-latest-screenshot.sh
Executable file
29
niri/files/copy-latest-screenshot.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
screenshot_dir="$HOME/Pictures/Screenshots"
|
||||
remote_target="mac-attio:~/screenshot.png"
|
||||
|
||||
notify() {
|
||||
DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus" \
|
||||
XDG_RUNTIME_DIR="/run/user/$(id -u)" \
|
||||
notify-send "$@"
|
||||
}
|
||||
|
||||
shopt -s nullglob
|
||||
files=("$screenshot_dir"/*.png)
|
||||
latest_file=""
|
||||
if (( ${#files[@]} )); then
|
||||
latest_file=$(ls -1t "${files[@]}" | head -n 1)
|
||||
fi
|
||||
|
||||
if [[ -z "${latest_file:-}" ]]; then
|
||||
notify "Screenshot upload" "No screenshots found in $screenshot_dir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if scp -q "$latest_file" "$remote_target"; then
|
||||
notify "Screenshot upload" "Uploaded $(basename "$latest_file")"
|
||||
else
|
||||
notify "Screenshot upload" "Upload failed"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user