Skip to content

Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.

Swift

Also watch a folder, like the one another screenshot app saves to

Alejandro Bujánf60d3d9babcd
diff --git a/Sources/Tendedero/AppDelegate.swift b/Sources/Tendedero/AppDelegate.swift
index 9007d2f..4ea2900 100644
--- a/Sources/Tendedero/AppDelegate.swift
+++ b/Sources/Tendedero/AppDelegate.swift
@@ -14,6 +14,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
/// ignores the screenshot settings (macOS 27 renamed one), captures keep
/// landing on the Desktop, and they still hang on the line.
private var safetyWatcher: ScreenshotWatcher?
+ /// A folder chosen in "Also watch a folder", like the one another
+ /// screenshot app saves to.
+ private var folderWatcher: ScreenshotWatcher?
private var clipboardWatcher: ClipboardWatcher!
private var signalSources: [DispatchSourceSignal] = []
private var hotKey: HotKey?
@@ -153,6 +156,42 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
safety.start()
safetyWatcher = safety
}
+ folderWatcher?.stop()
+ folderWatcher = nil
+ if let folder = Self.extraFolder,
+ ![watcher.folder, safetyWatcher?.folder].contains(where: { $0?.standardizedFileURL == folder.standardizedFileURL }) {
+ let extra = ScreenshotWatcher(
+ folder: folder,
+ onNew: { [weak self] url in self?.hangCapture(url) },
+ onChange: { [weak self] in self?.line.prune() })
+ extra.start()
+ folderWatcher = extra
+ }
+ }
+
+ /// The folder from "Also watch a folder", if it still exists. New images
+ /// in it hang like screenshots; taking one down leaves the file there.
+ static var extraFolder: URL? {
+ get {
+ guard let path = UserDefaults.standard.string(forKey: "extraFolder") else { return nil }
+ var isDir: ObjCBool = false
+ guard FileManager.default.fileExists(atPath: path, isDirectory: &isDir), isDir.boolValue else { return nil }
+ return URL(fileURLWithPath: path, isDirectory: true)
+ }
+ set { UserDefaults.standard.set(newValue?.path, forKey: "extraFolder") }
+ }
+
+ private func chooseExtraFolder() {
+ let panel = NSOpenPanel()
+ panel.canChooseDirectories = true
+ panel.canChooseFiles = false
+ panel.allowsMultipleSelection = false
+ panel.prompt = L("Watch")
+ panel.message = L("New images saved to this folder will hang on the line.")
+ NSApp.activate(ignoringOtherApps: true)
+ guard panel.runModal() == .OK, let url = panel.url else { return }
+ Self.extraFolder = url
+ startWatcher()
}
private func setInbox(_ on: Bool) {
@@ -601,6 +640,26 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
bringDown.submenu = options
menu.addItem(bringDown)
+ let folderItem = NSMenuItem(title: L("Also watch a folder"), action: nil, keyEquivalent: "")
+ let folderMenu = NSMenu()
+ if let folder = Self.extraFolder {
+ let current = ClosureMenuItem(FileManager.default.displayName(atPath: folder.path)) {
+ NSWorkspace.shared.open(folder)
+ }
+ current.state = .on
+ folderMenu.addItem(current)
+ folderMenu.addItem(.separator())
+ }
+ folderMenu.addItem(ClosureMenuItem(L("Choose Folder…")) { [weak self] in self?.chooseExtraFolder() })
+ if Self.extraFolder != nil {
+ folderMenu.addItem(ClosureMenuItem(L("Stop Watching")) { [weak self] in
+ AppDelegate.extraFolder = nil
+ self?.startWatcher()
+ })
+ }
+ folderItem.submenu = folderMenu
+ menu.addItem(folderItem)
+
let sizeItem = NSMenuItem(title: L("Size"), action: nil, keyEquivalent: "")
let sizes = NSMenu()
for (size, title) in [(Layout.Size.small, L("Small")), (.medium, L("Medium")), (.large, L("Large"))] {
diff --git a/Sources/Tendedero/Resources/az.lproj/Localizable.strings b/Sources/Tendedero/Resources/az.lproj/Localizable.strings
index d40cb20..6ccbef9 100644
--- a/Sources/Tendedero/Resources/az.lproj/Localizable.strings
+++ b/Sources/Tendedero/Resources/az.lproj/Localizable.strings
@@ -18,6 +18,11 @@
"Quit Tendedero" = "Tendedero-dan çıx";
"Could not change the login setting" = "Giriş ayarını dəyişmək alınmadı";
"Move Tendedero to the Applications folder and try again." = "Tendedero-nu Applications (Proqramlar) qovluğuna köçürün və yenidən cəhd edin.";
+"Also watch a folder" = "Bir qovluğu da izlə";
+"Choose Folder…" = "Qovluq seç…";
+"Stop Watching" = "İzləməyi dayandır";
+"Watch" = "İzlə";
+"New images saved to this folder will hang on the line." = "Bu qovluğa saxlanan yeni şəkillər ipdən asılacaq.";
"Shortcut" = "Qısayol";
"Change Shortcut…" = "Qısayolu dəyiş…";
"Change Shortcut" = "Qısayolu dəyiş";
diff --git a/Sources/Tendedero/Resources/en.lproj/Localizable.strings b/Sources/Tendedero/Resources/en.lproj/Localizable.strings
index dfb0639..4c145ac 100644
--- a/Sources/Tendedero/Resources/en.lproj/Localizable.strings
+++ b/Sources/Tendedero/Resources/en.lproj/Localizable.strings
@@ -18,6 +18,11 @@
"Quit Tendedero" = "Quit Tendedero";
"Could not change the login setting" = "Could not change the login setting";
"Move Tendedero to the Applications folder and try again." = "Move Tendedero to the Applications folder and try again.";
+"Also watch a folder" = "Also watch a folder";
+"Choose Folder…" = "Choose Folder…";
+"Stop Watching" = "Stop Watching";
+"Watch" = "Watch";
+"New images saved to this folder will hang on the line." = "New images saved to this folder will hang on the line.";
"Shortcut" = "Shortcut";
"Change Shortcut…" = "Change Shortcut…";
"Change Shortcut" = "Change Shortcut";
diff --git a/Sources/Tendedero/Resources/es.lproj/Localizable.strings b/Sources/Tendedero/Resources/es.lproj/Localizable.strings
index 5d1006d..c24f952 100644
--- a/Sources/Tendedero/Resources/es.lproj/Localizable.strings
+++ b/Sources/Tendedero/Resources/es.lproj/Localizable.strings
@@ -16,6 +16,11 @@
"Quit Tendedero" = "Salir de Tendedero";
"Could not change the login setting" = "No se pudo cambiar el inicio de sesión";
"Move Tendedero to the Applications folder and try again." = "Mueve Tendedero a la carpeta Aplicaciones y vuelve a intentarlo.";
+"Also watch a folder" = "Vigilar también una carpeta";
+"Choose Folder…" = "Elegir carpeta…";
+"Stop Watching" = "Dejar de vigilar";
+"Watch" = "Vigilar";
+"New images saved to this folder will hang on the line." = "Las imágenes nuevas que se guarden en esta carpeta se colgarán en la cuerda.";
"Shortcut" = "Atajo";
"Change Shortcut…" = "Cambiar atajo…";
"Change Shortcut" = "Cambiar atajo";
diff --git a/Sources/Tendedero/Resources/tr.lproj/Localizable.strings b/Sources/Tendedero/Resources/tr.lproj/Localizable.strings
index 0ebe725..221c9fb 100644
--- a/Sources/Tendedero/Resources/tr.lproj/Localizable.strings
+++ b/Sources/Tendedero/Resources/tr.lproj/Localizable.strings
@@ -16,6 +16,11 @@
"Quit Tendedero" = "Tendedero'yu kapat";
"Could not change the login setting" = "Giriş ayarı değiştirilemedi";
"Move Tendedero to the Applications folder and try again." = "Tendedero'yu Uygulamalar klasörüne taşıyın ve tekrar deneyin.";
+"Also watch a folder" = "Bir klasörü de izle";
+"Choose Folder…" = "Klasör seç…";
+"Stop Watching" = "İzlemeyi durdur";
+"Watch" = "İzle";
+"New images saved to this folder will hang on the line." = "Bu klasöre kaydedilen yeni görseller ipe asılır.";
"Shortcut" = "Kısayol";
"Change Shortcut…" = "Kısayolu değiştir…";
"Change Shortcut" = "Kısayolu değiştir";
diff --git a/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings b/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings
index 3e5f75b..b2f4bbf 100644
--- a/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings
+++ b/Sources/Tendedero/Resources/zh-Hans.lproj/Localizable.strings
@@ -16,6 +16,11 @@
"Quit Tendedero" = "退出 Tendedero";
"Could not change the login setting" = "无法更改登录项设置";
"Move Tendedero to the Applications folder and try again." = "请先把 Tendedero 移到「应用程序」文件夹,再试一次。";
+"Also watch a folder" = "同时监视一个文件夹";
+"Choose Folder…" = "选择文件夹…";
+"Stop Watching" = "停止监视";
+"Watch" = "监视";
+"New images saved to this folder will hang on the line." = "保存到此文件夹的新图片会挂到晾衣绳上。";
"Shortcut" = "快捷键";
"Change Shortcut…" = "更改快捷键…";
"Change Shortcut" = "更改快捷键";
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index ec61d43..d27f865 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -76,6 +76,10 @@ cat > "$APP/Contents/Info.plist" <<PLIST
<key>NSHighResolutionCapable</key><true/>
<key>NSDesktopFolderUsageDescription</key>
<string>Tendedero watches the folder where macOS saves your screenshots so it can hang them on the line.</string>
+ <key>NSDocumentsFolderUsageDescription</key>
+ <string>Tendedero watches the folder you chose so it can hang new images on the line.</string>
+ <key>NSDownloadsFolderUsageDescription</key>
+ <string>Tendedero watches the folder you chose so it can hang new images on the line.</string>
</dict>
</plist>
PLIST