From a263e1c44b3412b7a409fc25fbf31ea82f4f97ca Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Tue, 24 Oct 2023 22:44:05 +0200 Subject: [PATCH] Make AeroSpace version and hash copyable --- src/AeroSpaceApp.swift | 5 ++++- src/util/util.swift | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/AeroSpaceApp.swift b/src/AeroSpaceApp.swift index 7774a091..5f217300 100644 --- a/src/AeroSpaceApp.swift +++ b/src/AeroSpaceApp.swift @@ -28,7 +28,10 @@ struct AeroSpaceApp: App { var body: some Scene { MenuBarExtra { - Text("\(Bundle.appName) v\(Bundle.appVersion) \(gitShortHash)") + let shortIdentification = "\(Bundle.appName) v\(Bundle.appVersion) \(gitShortHash)" + let identification = "\(Bundle.appName) v\(Bundle.appVersion) \(gitHash)" + Text(shortIdentification) + Button("Copy to clipboard") { identification.copyToClipboard() } Divider() Text("Workspaces:") ForEach(Workspace.all) { (workspace: Workspace) in diff --git a/src/util/util.swift b/src/util/util.swift index 16db038e..251718ec 100644 --- a/src/util/util.swift +++ b/src/util/util.swift @@ -67,6 +67,12 @@ extension String { func removePrefix(_ prefix: String) -> String { hasPrefix(prefix) ? String(dropFirst(prefix.count)) : self } + + func copyToClipboard() { + let pasteboard = NSPasteboard.general + pasteboard.declareTypes([.string], owner: nil) + pasteboard.setString(self, forType: .string) + } } extension Double {