memo-clipboard 0.0.0-stage → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +243 -2
- package/assets/memo.ico +0 -0
- package/assets/memo.png +0 -0
- package/assets/preview.png +0 -0
- package/bin/memo.js +424 -0
- package/package.json +60 -4
- package/prebuilds/memo-linux-x64 +0 -0
- package/prebuilds/memo-macos-arm64 +0 -0
- package/prebuilds/memo-macos-x64 +0 -0
- package/prebuilds/memo-windows-x64.exe +0 -0
- package/scripts/install.ps1 +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Memo Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,244 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/onursercanyilmaz/memo/main/assets/memo.png" alt="Memo Logo" width="120" height="120" />
|
|
3
|
+
<h1>Memo</h1>
|
|
4
|
+
<p><strong>Ultra-lightweight, blazing-fast native clipboard manager for Windows, macOS & Linux — built with pure Rust.</strong></p>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://onursercanyilmaz.github.io/memo/"><img src="https://img.shields.io/badge/Website-GitHub%20Pages-4F8CFF?style=flat-square" alt="Website" /></a>
|
|
8
|
+
<a href="https://github.com/onursercanyilmaz/memo/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/onursercanyilmaz/memo/ci.yml?style=flat-square&label=CI" alt="CI" /></a>
|
|
9
|
+
<a href="https://github.com/onursercanyilmaz/memo/releases"><img src="https://img.shields.io/github/v/release/onursercanyilmaz/memo?style=flat-square&color=blue&label=Release" alt="Release" /></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/memo-clipboard"><img src="https://img.shields.io/badge/npm-memo--clipboard-CB3837?style=flat-square&logo=npm" alt="npm" /></a>
|
|
11
|
+
<a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/Rust-1.80%2B-orange?style=flat-square&logo=rust" alt="Rust" /></a>
|
|
12
|
+
<img src="https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-0078D4?style=flat-square" alt="Platforms" />
|
|
13
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-lightgrey?style=flat-square" alt="License" /></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
<a href="#highlights">Highlights</a> •
|
|
18
|
+
<a href="#installation">Installation</a> •
|
|
19
|
+
<a href="#comparison">Comparison</a> •
|
|
20
|
+
<a href="#keyboard-shortcuts">Shortcuts</a> •
|
|
21
|
+
<a href="#privacy--security">Security</a> •
|
|
22
|
+
<a href="#building-from-source">Build</a>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
**Memo** is a modern, privacy-first, open-source clipboard manager written in **pure Rust** — designed with zero Electron/WebView bloat and instant keyboard-driven workflows across **Windows, macOS, and Linux**:
|
|
29
|
+
|
|
30
|
+
- **Windows:** Native **Win32 API + Direct2D / DirectWrite** (`~1.5 MB` single `.exe`, `~2.4 MB` idle RAM, `0%` idle CPU via `WM_CLIPBOARDUPDATE`).
|
|
31
|
+
- **macOS & Linux:** Native GPU-accelerated **egui (`eframe`)** + dedicated background worker (`0%` idle CPU via `NSPasteboard.changeCount()` on macOS, menu bar / system tray integration, and global hotkeys).
|
|
32
|
+
- **Shared Core:** Embedded **SQLite (WAL mode) + FTS5** full-text index with automatic substring fallback, deduplication, and retention protection.
|
|
33
|
+
|
|
34
|
+
<div align="center">
|
|
35
|
+
<img src="https://raw.githubusercontent.com/onursercanyilmaz/memo/main/assets/preview.png" alt="Memo Clipboard Manager UI Preview" width="820" />
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Highlights
|
|
41
|
+
|
|
42
|
+
- **Zero-Stutter Background Architecture:**
|
|
43
|
+
- **Windows:** Event-driven `AddClipboardFormatListener` (`WM_CLIPBOARDUPDATE`) — zero polling.
|
|
44
|
+
- **macOS:** Dedicated background worker checking `NSPasteboard.changeCount()` in instant `O(1)` time with off-thread PNG encoding and zero idle UI repaints.
|
|
45
|
+
- **Multi-Format Capture & Restore:**
|
|
46
|
+
- Plain text, source code, URLs, rich text (`HTML` & `RTF`), images (`PNG` stored on disk outside SQLite with bounded GPU texture caching), and file copies (`CF_HDROP` on Windows, `NSFilenamesPboardType` in macOS Finder).
|
|
47
|
+
- **Instant Auto-Paste:**
|
|
48
|
+
- Remembers your previously active application, hides on selection, restores focus, and pastes automatically (`SendInput` on Windows, `CGEvent` `Cmd+V` on macOS, `xdotool` / `wtype` on Linux) — or strips formatting on the fly with `Shift + Enter`.
|
|
49
|
+
- **Live Shortcut Recorder:**
|
|
50
|
+
- Built-in **Shortcut Recorder** in Settings (`⚙`) lets you record any global toggle shortcut (`Ctrl` / `Shift` / `Alt·Option` / `Win·Cmd` + Key or `F1–F12`) or choose from presets.
|
|
51
|
+
- **Folders & Never-Delete Protection:**
|
|
52
|
+
- Organize clips into custom folders or pin (`📌`) important snippets. Pinned and folder-assigned clips are **never** removed by automatic retention limits or *Clear Unpinned History*.
|
|
53
|
+
- **Multi-Select Merge Paste & Inline Editor:**
|
|
54
|
+
- Select multiple clips with `Ctrl/Cmd + Click` or `Shift + Click` to merge-paste them in one shot, or press `Ctrl/Cmd + E` to edit any text/code clip inline (`Ctrl/Cmd + S` to save).
|
|
55
|
+
- **Smart Previews:**
|
|
56
|
+
- **Hex Colors (`#4F8CFF` / `#f0a`):** Live color swatches in both the clip list and preview pane with RGB values.
|
|
57
|
+
- **JSON:** Automatic pretty-printed formatting.
|
|
58
|
+
- **Images:** Scaled high-DPI preview with dimensions and usage stats.
|
|
59
|
+
- **Links:** One-click `🌐 Open` button to open URLs in your default browser.
|
|
60
|
+
- **Bilingual UI & Themes:**
|
|
61
|
+
- Instant **Dark / Light** theme switch (`☀` / `🌙`) and built-in **English / Turkish (`EN` / `TR`)** interface toggle.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Comparison
|
|
66
|
+
|
|
67
|
+
| Capability | Memo (`v0.2.2`) | Ditto | Electron Clipboard Apps |
|
|
68
|
+
| :--- | :---: | :---: | :---: |
|
|
69
|
+
| **Platforms** | **Windows, macOS, Linux** | Windows only | Cross-platform |
|
|
70
|
+
| **Binary Size** | `~1.5 MB` (Win) / `~4.6 MB` (macOS) | `~14 MB` | `150–300+ MB` |
|
|
71
|
+
| **Idle CPU Usage** | **`0%`** (event / `changeCount` driven) | `0%` | `1–5%` |
|
|
72
|
+
| **UI Stack** | Native Direct2D (Win) / `egui` (Unix) | Win32 MFC | Chromium / WebView |
|
|
73
|
+
| **Rich Text (`HTML` / `RTF`) & Plain Paste** | ✅ | ✅ | Partial |
|
|
74
|
+
| **Custom Global Shortcut Recorder** | ✅ | ✅ | ✅ |
|
|
75
|
+
| **Folders & Retention Protection** | ✅ | ✅ | Varies |
|
|
76
|
+
| **Multi-Select Merge Paste & Inline Edit** | ✅ | ✅ | Partial |
|
|
77
|
+
| **Smart Hex Color, JSON & Image Previews** | ✅ | Image only | Partial |
|
|
78
|
+
| **OS Concealed Password & App Blacklist** | ✅ | Partial | Partial |
|
|
79
|
+
| **Memory-Safe Core** | ✅ Pure Rust | C++ | JS / C++ |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
### Quick Install via npm / npx (Windows, macOS & Linux)
|
|
86
|
+
|
|
87
|
+
Requires [Node.js 18+](https://nodejs.org/). Ships prebuilt native binaries for `win32-x64`, `macos-arm64`, `macos-x64`, and `linux-x64` directly inside the package:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install -g memo-clipboard
|
|
91
|
+
memo
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Or launch directly without global installation:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npx memo-clipboard
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The npm package ships **prebuilt native binaries** for `macos-arm64`, `macos-x64`, `linux-x64` and `windows-x64`, so it starts right away with no Rust toolchain and no extra download.
|
|
101
|
+
|
|
102
|
+
| Command | Description |
|
|
103
|
+
| :--- | :--- |
|
|
104
|
+
| `memo` | Start Memo in the background (it won't start a second copy if one is already running) |
|
|
105
|
+
| `memo --status` | Show process status, binary source and database path |
|
|
106
|
+
| `memo --doctor` | Check platform, binary, database and auto-paste support |
|
|
107
|
+
| `memo --restart` / `memo --stop` | Restart or stop the background instance |
|
|
108
|
+
| `memo --foreground` | Run attached to the terminal and show live logs |
|
|
109
|
+
| `memo --version` / `memo --help` | Show version / help |
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### Windows
|
|
114
|
+
|
|
115
|
+
1. **Installer (Recommended):** Download **`Memo-Setup-<version>.exe`** from [GitHub Releases](https://github.com/onursercanyilmaz/memo/releases).
|
|
116
|
+
- Installs per-user to `%LOCALAPPDATA%\Memo` (no administrator rights required).
|
|
117
|
+
- Creates Desktop & Start Menu shortcuts, optional *Start with Windows* entry, and clean uninstaller.
|
|
118
|
+
2. **Portable:** Download **`memo-windows-x64.exe`** (or **`Memo-Portable-<version>.exe`**) and run directly.
|
|
119
|
+
3. **PowerShell (from source):**
|
|
120
|
+
```powershell
|
|
121
|
+
powershell -ExecutionPolicy Bypass -File scripts/install.ps1
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### macOS (Apple Silicon & Intel)
|
|
127
|
+
|
|
128
|
+
1. Download **`Memo-<version>-arm64.dmg`** (Apple Silicon) or **`Memo-<version>-x64.dmg`** (Intel) from [GitHub Releases](https://github.com/onursercanyilmaz/memo/releases) and drag **Memo.app** to `/Applications`.
|
|
129
|
+
2. **Unsigned Open-Source App Note:** If macOS Gatekeeper displays an unverified developer prompt on first launch, clear the quarantine attribute once:
|
|
130
|
+
```bash
|
|
131
|
+
xattr -cr /Applications/Memo.app
|
|
132
|
+
```
|
|
133
|
+
3. **Auto-Paste Permission (Optional):** Memo runs as a clean menu bar app (`LSUIElement`). To enable automatic `Cmd + V` pasting into the previous window on `Enter`, grant permission under **System Settings → Privacy & Security → Accessibility** (a direct shortcut button is available inside Memo `⚙ Settings`).
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### Linux (Debian / Ubuntu & AppImage)
|
|
138
|
+
|
|
139
|
+
- **Debian / Ubuntu (`.deb`):**
|
|
140
|
+
```bash
|
|
141
|
+
sudo dpkg -i memo_<version>_amd64.deb
|
|
142
|
+
```
|
|
143
|
+
- **Universal `.AppImage`:**
|
|
144
|
+
```bash
|
|
145
|
+
chmod +x memo_<version>_x86_64.AppImage
|
|
146
|
+
./memo_<version>_x86_64.AppImage
|
|
147
|
+
```
|
|
148
|
+
- *Optional for Linux Auto-Paste:* Install `xdotool` (X11) or `wtype` (Wayland) so Memo can automatically send `Ctrl + V` to the target window.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Keyboard Shortcuts
|
|
153
|
+
|
|
154
|
+
| Shortcut (Windows / Linux) | Shortcut (macOS) | Action |
|
|
155
|
+
| :--- | :--- | :--- |
|
|
156
|
+
| `Ctrl + Shift + V` | `Ctrl + Shift + V` *(customizable)* | Toggle Memo window from anywhere |
|
|
157
|
+
| `Up` / `Down` | `Up` / `Down` | Navigate clipboard history |
|
|
158
|
+
| `Enter` | `Enter` | Paste selected item (or merge-paste multi-selection) |
|
|
159
|
+
| `Shift + Enter` | `Shift + Enter` | Paste as **plain text** (strips HTML/RTF or pastes file paths) |
|
|
160
|
+
| `Ctrl + C` | `Cmd + C` | Copy selected item without hiding |
|
|
161
|
+
| `Ctrl + E` | `Cmd + E` | Edit selected text/code clip inline |
|
|
162
|
+
| `Ctrl + S` | `Cmd + S` | Save inline edit |
|
|
163
|
+
| `Ctrl + P` | `Cmd + P` | Pin / Unpin selected clip |
|
|
164
|
+
| `Alt + 1..9` | `Option + 1..9` | Quick-paste top 9 clips |
|
|
165
|
+
| `Ctrl + Click` / `Shift + Click` | `Cmd + Click` / `Shift + Click` | Multi-select clips for merge paste |
|
|
166
|
+
| `Delete` | `Delete` / `Cmd + Backspace` | Delete selected clip |
|
|
167
|
+
| `Esc` | `Esc` | Cancel edit → clear search → hide window |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Privacy & Security
|
|
172
|
+
|
|
173
|
+
- **100% Local & Offline:** Memo makes **zero** network requests and collects **zero** telemetry. History is stored exclusively on your device:
|
|
174
|
+
- **Windows:** `%APPDATA%\memo\memo.db` & `%APPDATA%\memo\images\`
|
|
175
|
+
- **macOS:** `~/Library/Application Support/memo/memo.db` & `images/`
|
|
176
|
+
- **Linux:** `${XDG_DATA_HOME:-~/.local/share}/memo/memo.db` & `images/`
|
|
177
|
+
- **OS Concealed Clipboard Compliance:**
|
|
178
|
+
- **Windows:** Ignores `ExcludeClipboardContentFromMonitorProcessing`, `Clipboard Viewer Ignore`, and `CanIncludeInClipboardHistory = 0`.
|
|
179
|
+
- **macOS:** Ignores `org.nspasteboard.ConcealedType`, `org.nspasteboard.TransientType`, `org.nspasteboard.AutoGeneratedType`, and `com.agilebits.onepassword`.
|
|
180
|
+
- **Password Manager Blacklist:** Automatically skips captures from `1Password`, `Bitwarden`, `KeePass`, `KeePassXC`, Apple `Passwords`, and `Keychain Access` (fully customizable in `⚙ Settings` or `settings.json`).
|
|
181
|
+
- **Policies:** [Privacy Policy](https://onursercanyilmaz.github.io/memo/privacy.html) · [Terms of Use & Disclaimer](https://onursercanyilmaz.github.io/memo/terms.html)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Building from Source
|
|
186
|
+
|
|
187
|
+
### Prerequisites
|
|
188
|
+
|
|
189
|
+
- **Rust 1.80+** (`rustup`)
|
|
190
|
+
- **Linux (Ubuntu/Debian) system headers:**
|
|
191
|
+
```bash
|
|
192
|
+
sudo apt-get update
|
|
193
|
+
sudo apt-get install -y \
|
|
194
|
+
libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
|
|
195
|
+
libxkbcommon-dev libgtk-3-dev libxdo-dev libayatana-appindicator3-dev
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Test, Lint & Build
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
cargo test
|
|
202
|
+
cargo clippy --all-targets -- -D warnings
|
|
203
|
+
cargo build --release
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The optimized binary is written to `target/release/memo` (`target\release\memo.exe` on Windows).
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Project Structure
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
memo/
|
|
214
|
+
├── src/
|
|
215
|
+
│ ├── main.rs # Entry point & Win32 message loop routing
|
|
216
|
+
│ ├── db.rs # SQLite (WAL) + FTS5/LIKE hybrid search, folders & retention
|
|
217
|
+
│ ├── config.rs # Settings, keybindings & cross-platform autostart (Registry / LaunchAgents / XDG)
|
|
218
|
+
│ ├── ui.rs # Windows native Direct2D + DirectWrite two-pane UI
|
|
219
|
+
│ ├── clipboard.rs # Windows clipboard listener, DIB/HTML/RTF/HDROP & privacy filters
|
|
220
|
+
│ ├── paste.rs # Windows RegisterHotKey, focus restore & SendInput Ctrl+V
|
|
221
|
+
│ ├── tray.rs # Windows system tray icon & context menu
|
|
222
|
+
│ ├── unix_app.rs # macOS & Linux egui UI, shortcut recorder, bilingual EN/TR & caching
|
|
223
|
+
│ ├── unix_clipboard.rs # Off-thread clipboard worker, PNG encoder & IgnoreHash loop guard
|
|
224
|
+
│ └── unix_platform.rs # macOS NSPasteboard/NSWorkspace/CGEvent FFI & Linux xdotool/wtype integration
|
|
225
|
+
├── assets/ # Application icons (memo.png & memo.ico)
|
|
226
|
+
├── bin/memo.js # Zero-dependency Node.js cross-platform binary launcher
|
|
227
|
+
├── docs/ # GitHub Pages website, privacy policy & terms
|
|
228
|
+
├── installer/memo.iss # Inno Setup per-user Windows installer script
|
|
229
|
+
├── scripts/install.ps1 # Local PowerShell build & shortcut installer
|
|
230
|
+
├── build.rs # Windows executable icon resource compiler
|
|
231
|
+
└── .github/workflows/ # Multi-OS CI, GitHub Releases (.exe/.dmg/.deb/.AppImage + npm) & Pages
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Code Signing
|
|
237
|
+
|
|
238
|
+
> Windows code signing policy is prepared for **[SignPath.io](https://signpath.io/)** (certificate by **[SignPath Foundation](https://signpath.org/)**). Until organization signing credentials are active on a release tag, Windows SmartScreen or macOS Gatekeeper may show a standard prompt for unsigned open-source binaries.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
Released under the [MIT License](LICENSE).
|
package/assets/memo.ico
ADDED
|
Binary file
|
package/assets/memo.png
ADDED
|
Binary file
|
|
Binary file
|
package/bin/memo.js
ADDED
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawn, execSync } = require("child_process");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
const rootDir = path.resolve(__dirname, "..");
|
|
11
|
+
const pkg = JSON.parse(
|
|
12
|
+
fs.readFileSync(path.join(rootDir, "package.json"), "utf8")
|
|
13
|
+
);
|
|
14
|
+
const VERSION = pkg.version || "0.2.2";
|
|
15
|
+
const isWin = process.platform === "win32";
|
|
16
|
+
const isMac = process.platform === "darwin";
|
|
17
|
+
|
|
18
|
+
function getAssetName() {
|
|
19
|
+
if (isWin) return "memo-windows-x64.exe";
|
|
20
|
+
if (isMac) {
|
|
21
|
+
return process.arch === "arm64" ? "memo-macos-arm64" : "memo-macos-x64";
|
|
22
|
+
}
|
|
23
|
+
return "memo-linux-x64";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getDataDir() {
|
|
27
|
+
if (isWin) {
|
|
28
|
+
return path.join(process.env.APPDATA || os.homedir(), "memo");
|
|
29
|
+
}
|
|
30
|
+
if (isMac) {
|
|
31
|
+
return path.join(os.homedir(), "Library", "Application Support", "memo");
|
|
32
|
+
}
|
|
33
|
+
return path.join(
|
|
34
|
+
process.env.XDG_DATA_HOME || path.join(os.homedir(), ".local", "share"),
|
|
35
|
+
"memo"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getCacheExePath() {
|
|
40
|
+
const asset = getAssetName();
|
|
41
|
+
if (isWin) {
|
|
42
|
+
const base = process.env.LOCALAPPDATA || path.join(os.homedir(), ".memo");
|
|
43
|
+
return path.join(base, "Memo", "bin", `v${VERSION}`, asset);
|
|
44
|
+
}
|
|
45
|
+
return path.join(os.homedir(), ".memo", "bin", `v${VERSION}`, asset);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const prebuiltExe = path.join(rootDir, "prebuilds", getAssetName());
|
|
49
|
+
const cargoReleaseExe = path.join(
|
|
50
|
+
rootDir,
|
|
51
|
+
"target",
|
|
52
|
+
"release",
|
|
53
|
+
isWin ? "memo.exe" : "memo"
|
|
54
|
+
);
|
|
55
|
+
const cachedExe = getCacheExePath();
|
|
56
|
+
|
|
57
|
+
function ensureExecutableMode(filePath) {
|
|
58
|
+
if (!isWin) {
|
|
59
|
+
try {
|
|
60
|
+
fs.chmodSync(filePath, 0o755);
|
|
61
|
+
} catch {
|
|
62
|
+
// ignore on read-only mounts
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveBinary() {
|
|
68
|
+
if (fs.existsSync(prebuiltExe)) {
|
|
69
|
+
ensureExecutableMode(prebuiltExe);
|
|
70
|
+
return { path: prebuiltExe, source: "bundled npm prebuild" };
|
|
71
|
+
}
|
|
72
|
+
if (fs.existsSync(cargoReleaseExe)) {
|
|
73
|
+
ensureExecutableMode(cargoReleaseExe);
|
|
74
|
+
return { path: cargoReleaseExe, source: "local cargo release" };
|
|
75
|
+
}
|
|
76
|
+
if (fs.existsSync(cachedExe)) {
|
|
77
|
+
ensureExecutableMode(cachedExe);
|
|
78
|
+
return { path: cachedExe, source: "cached release binary" };
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Process names Memo can run under (cargo build, npm prebuild, or .app bundle)
|
|
84
|
+
const UNIX_NAMES = new Set(["memo", "memo-macos-arm64", "memo-macos-x64", "memo-linux-x64"]);
|
|
85
|
+
const WIN_NAMES = ["memo.exe", "memo-windows-x64.exe"];
|
|
86
|
+
|
|
87
|
+
function getRunningPids() {
|
|
88
|
+
try {
|
|
89
|
+
if (isWin) {
|
|
90
|
+
const out = execSync("tasklist /FO CSV /NH", {
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
93
|
+
});
|
|
94
|
+
const pids = [];
|
|
95
|
+
for (const line of out.split(/\r?\n/)) {
|
|
96
|
+
const cols = line.split('","').map((c) => c.replace(/"/g, ""));
|
|
97
|
+
if (cols.length > 1 && WIN_NAMES.includes(cols[0].toLowerCase())) {
|
|
98
|
+
pids.push(parseInt(cols[1], 10));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return pids;
|
|
102
|
+
}
|
|
103
|
+
const out = execSync("ps -axo pid=,comm=", {
|
|
104
|
+
encoding: "utf8",
|
|
105
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
106
|
+
});
|
|
107
|
+
const pids = [];
|
|
108
|
+
for (const line of out.split("\n")) {
|
|
109
|
+
const m = line.trim().match(/^(\d+)\s+(.+)$/);
|
|
110
|
+
if (m && UNIX_NAMES.has(path.basename(m[2])) && parseInt(m[1], 10) !== process.pid) {
|
|
111
|
+
pids.push(parseInt(m[1], 10));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return pids;
|
|
115
|
+
} catch {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function getRunningPid() {
|
|
121
|
+
const pids = getRunningPids();
|
|
122
|
+
return pids.length ? pids[0] : null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function stopRunningInstance() {
|
|
126
|
+
const pids = getRunningPids();
|
|
127
|
+
for (const pid of pids) {
|
|
128
|
+
try {
|
|
129
|
+
process.kill(pid);
|
|
130
|
+
} catch {
|
|
131
|
+
// already exited
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return pids.length > 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function downloadFile(url, dest, redirectsLeft = 5) {
|
|
138
|
+
return new Promise((resolve, reject) => {
|
|
139
|
+
https
|
|
140
|
+
.get(
|
|
141
|
+
url,
|
|
142
|
+
{ headers: { "User-Agent": `memo-clipboard/${VERSION}` } },
|
|
143
|
+
(res) => {
|
|
144
|
+
if (
|
|
145
|
+
res.statusCode >= 300 &&
|
|
146
|
+
res.statusCode < 400 &&
|
|
147
|
+
res.headers.location &&
|
|
148
|
+
redirectsLeft > 0
|
|
149
|
+
) {
|
|
150
|
+
res.resume();
|
|
151
|
+
return resolve(
|
|
152
|
+
downloadFile(res.headers.location, dest, redirectsLeft - 1)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (res.statusCode !== 200) {
|
|
156
|
+
res.resume();
|
|
157
|
+
return reject(new Error(`HTTP ${res.statusCode}`));
|
|
158
|
+
}
|
|
159
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
160
|
+
const tmpDest = `${dest}.tmp-${process.pid}`;
|
|
161
|
+
const file = fs.createWriteStream(tmpDest);
|
|
162
|
+
res.pipe(file);
|
|
163
|
+
file.on("finish", () => {
|
|
164
|
+
file.close(() => {
|
|
165
|
+
try {
|
|
166
|
+
if (!isWin) fs.chmodSync(tmpDest, 0o755);
|
|
167
|
+
fs.renameSync(tmpDest, dest);
|
|
168
|
+
resolve();
|
|
169
|
+
} catch (e) {
|
|
170
|
+
reject(e);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
file.on("error", (err) => {
|
|
175
|
+
fs.unlink(tmpDest, () => reject(err));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
.on("error", reject);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function checkNpmUpdate() {
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
try {
|
|
186
|
+
const req = https.get(
|
|
187
|
+
"https://registry.npmjs.org/memo-clipboard/latest",
|
|
188
|
+
{ timeout: 1800 },
|
|
189
|
+
(res) => {
|
|
190
|
+
if (res.statusCode !== 200) {
|
|
191
|
+
res.resume();
|
|
192
|
+
return resolve();
|
|
193
|
+
}
|
|
194
|
+
let raw = "";
|
|
195
|
+
res.on("data", (c) => (raw += c));
|
|
196
|
+
res.on("end", () => {
|
|
197
|
+
try {
|
|
198
|
+
const latest = JSON.parse(raw)?.version;
|
|
199
|
+
if (latest && latest !== "0.0.0-stage" && latest !== VERSION) {
|
|
200
|
+
const a = latest.split(".").map((n) => parseInt(n, 10) || 0);
|
|
201
|
+
const b = VERSION.split(".").map((n) => parseInt(n, 10) || 0);
|
|
202
|
+
const newer =
|
|
203
|
+
a[0] > b[0] ||
|
|
204
|
+
(a[0] === b[0] && a[1] > b[1]) ||
|
|
205
|
+
(a[0] === b[0] && a[1] === b[1] && a[2] > b[2]);
|
|
206
|
+
if (newer) {
|
|
207
|
+
console.log(
|
|
208
|
+
`> Update available: ${VERSION} -> ${latest} (run: npm i -g memo-clipboard@latest)`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
// ignore parse errors
|
|
214
|
+
}
|
|
215
|
+
resolve();
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
req.on("error", () => resolve());
|
|
220
|
+
req.on("timeout", () => {
|
|
221
|
+
req.destroy();
|
|
222
|
+
resolve();
|
|
223
|
+
});
|
|
224
|
+
} catch {
|
|
225
|
+
resolve();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function printHelp() {
|
|
231
|
+
console.log(`
|
|
232
|
+
Memo v${VERSION} — Ultra-lightweight native Rust clipboard manager
|
|
233
|
+
|
|
234
|
+
Usage:
|
|
235
|
+
memo [options]
|
|
236
|
+
npx memo-clipboard [options]
|
|
237
|
+
|
|
238
|
+
Options:
|
|
239
|
+
-f, --foreground Run attached to the current terminal (shows live logs)
|
|
240
|
+
--restart Restart Memo if an instance is already running
|
|
241
|
+
--stop Stop the running Memo background instance
|
|
242
|
+
--status Show process status, binary source, and database path
|
|
243
|
+
--doctor Run environment & platform capability diagnostics
|
|
244
|
+
--reinstall Download a fresh native binary from GitHub Releases
|
|
245
|
+
-v, --version Print version and target platform
|
|
246
|
+
-h, --help Show this help message
|
|
247
|
+
`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function runDoctor() {
|
|
251
|
+
const resolved = resolveBinary();
|
|
252
|
+
const dataDir = getDataDir();
|
|
253
|
+
const dbFile = path.join(dataDir, "memo.db");
|
|
254
|
+
const pid = getRunningPid();
|
|
255
|
+
|
|
256
|
+
console.log(`Memo Doctor (v${VERSION})`);
|
|
257
|
+
console.log(` Platform : ${process.platform}-${process.arch}`);
|
|
258
|
+
console.log(` Expected Bin : ${getAssetName()}`);
|
|
259
|
+
console.log(
|
|
260
|
+
` Binary Path : ${resolved ? `${resolved.path} (${resolved.source})` : "not installed yet"}`
|
|
261
|
+
);
|
|
262
|
+
console.log(` Process : ${pid ? `running (PID ${pid})` : "stopped"}`);
|
|
263
|
+
console.log(
|
|
264
|
+
` Database : ${dbFile} (${fs.existsSync(dbFile) ? `${(fs.statSync(dbFile).size / 1024).toFixed(1)} KB` : "will be created on first launch"})`
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
if (isMac) {
|
|
268
|
+
console.log(
|
|
269
|
+
" macOS Note : Grant Accessibility in System Settings -> Privacy & Security for automatic Cmd+V paste."
|
|
270
|
+
);
|
|
271
|
+
} else if (!isWin) {
|
|
272
|
+
let hasXdotool = false;
|
|
273
|
+
let hasWtype = false;
|
|
274
|
+
try {
|
|
275
|
+
execSync("command -v xdotool", { stdio: "ignore" });
|
|
276
|
+
hasXdotool = true;
|
|
277
|
+
} catch {}
|
|
278
|
+
try {
|
|
279
|
+
execSync("command -v wtype", { stdio: "ignore" });
|
|
280
|
+
hasWtype = true;
|
|
281
|
+
} catch {}
|
|
282
|
+
console.log(
|
|
283
|
+
` Auto-Paste : xdotool=${hasXdotool ? "yes" : "no"}, wtype=${hasWtype ? "yes" : "no"}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function ensureBinary(forceDownload = false) {
|
|
289
|
+
if (!forceDownload) {
|
|
290
|
+
const existing = resolveBinary();
|
|
291
|
+
if (existing) return existing;
|
|
292
|
+
|
|
293
|
+
if (fs.existsSync(path.join(rootDir, "Cargo.toml"))) {
|
|
294
|
+
console.log("> Building Memo release binary with cargo...");
|
|
295
|
+
try {
|
|
296
|
+
execSync("cargo build --release", { cwd: rootDir, stdio: "inherit" });
|
|
297
|
+
const built = resolveBinary();
|
|
298
|
+
if (built) return built;
|
|
299
|
+
} catch {
|
|
300
|
+
// fall through to GitHub Releases download
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const asset = getAssetName();
|
|
306
|
+
const versionedUrl = `https://github.com/onursercanyilmaz/memo/releases/download/v${VERSION}/${asset}`;
|
|
307
|
+
const latestUrl = `https://github.com/onursercanyilmaz/memo/releases/latest/download/${asset}`;
|
|
308
|
+
|
|
309
|
+
console.log(`> Downloading ${asset} (v${VERSION}) from GitHub Releases...`);
|
|
310
|
+
try {
|
|
311
|
+
await downloadFile(versionedUrl, cachedExe);
|
|
312
|
+
} catch {
|
|
313
|
+
await downloadFile(latestUrl, cachedExe);
|
|
314
|
+
}
|
|
315
|
+
console.log(`> Saved native binary to ${cachedExe}`);
|
|
316
|
+
return { path: cachedExe, source: "downloaded release binary" };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async function main() {
|
|
320
|
+
const args = process.argv.slice(2);
|
|
321
|
+
|
|
322
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
323
|
+
printHelp();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (args.includes("-v") || args.includes("--version")) {
|
|
328
|
+
console.log(`memo-clipboard v${VERSION} (${process.platform}-${process.arch})`);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (args.includes("--doctor")) {
|
|
333
|
+
runDoctor();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (args.includes("--status")) {
|
|
338
|
+
const pid = getRunningPid();
|
|
339
|
+
const resolved = resolveBinary();
|
|
340
|
+
const dbFile = path.join(getDataDir(), "memo.db");
|
|
341
|
+
console.log(
|
|
342
|
+
pid ? `> Memo is running (PID ${pid})` : "> Memo is not currently running"
|
|
343
|
+
);
|
|
344
|
+
if (resolved) {
|
|
345
|
+
console.log(`> Binary: ${resolved.path} (${resolved.source})`);
|
|
346
|
+
}
|
|
347
|
+
console.log(`> Data directory: ${getDataDir()}`);
|
|
348
|
+
if (fs.existsSync(dbFile)) {
|
|
349
|
+
console.log(
|
|
350
|
+
`> Database size: ${(fs.statSync(dbFile).size / 1024).toFixed(1)} KB`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (args.includes("--stop")) {
|
|
357
|
+
const stopped = stopRunningInstance();
|
|
358
|
+
console.log(
|
|
359
|
+
stopped ? "> Stopped running Memo instance." : "> Memo was not running."
|
|
360
|
+
);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const forceReinstall = args.includes("--reinstall");
|
|
365
|
+
const foreground = args.includes("-f") || args.includes("--foreground");
|
|
366
|
+
const restart = args.includes("--restart");
|
|
367
|
+
|
|
368
|
+
let binInfo;
|
|
369
|
+
try {
|
|
370
|
+
binInfo = await ensureBinary(forceReinstall);
|
|
371
|
+
} catch (err) {
|
|
372
|
+
console.error(`[memo] Failed to obtain native binary: ${err.message}`);
|
|
373
|
+
console.error(
|
|
374
|
+
"[memo] Download manually from: https://github.com/onursercanyilmaz/memo/releases"
|
|
375
|
+
);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const existingPid = getRunningPid();
|
|
380
|
+
if (existingPid && !restart && !foreground) {
|
|
381
|
+
console.log(`> Memo v${VERSION} is already running (PID ${existingPid})`);
|
|
382
|
+
console.log(`> Data directory: ${getDataDir()}`);
|
|
383
|
+
console.log(`> Tip: Press Ctrl + Shift + V to toggle Memo, or pass --restart`);
|
|
384
|
+
await checkNpmUpdate();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (existingPid && restart) {
|
|
389
|
+
stopRunningInstance();
|
|
390
|
+
await new Promise((r) => setTimeout(r, 400));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const passArgs = args.filter(
|
|
394
|
+
(a) =>
|
|
395
|
+
![
|
|
396
|
+
"-f",
|
|
397
|
+
"--foreground",
|
|
398
|
+
"--restart",
|
|
399
|
+
"--reinstall",
|
|
400
|
+
].includes(a)
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
if (foreground) {
|
|
404
|
+
console.log(`> Starting Memo v${VERSION} in foreground (${binInfo.source})...`);
|
|
405
|
+
const child = spawn(binInfo.path, passArgs, { stdio: "inherit" });
|
|
406
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const child = spawn(binInfo.path, passArgs, {
|
|
411
|
+
detached: true,
|
|
412
|
+
stdio: "ignore",
|
|
413
|
+
});
|
|
414
|
+
child.unref();
|
|
415
|
+
|
|
416
|
+
console.log(`> Memo v${VERSION} started (PID ${child.pid})`);
|
|
417
|
+
console.log(`> Binary: ${binInfo.path} (${binInfo.source})`);
|
|
418
|
+
console.log(`> Data directory: ${getDataDir()}`);
|
|
419
|
+
console.log(`> Toggle shortcut: Ctrl + Shift + V (customizable in Settings)`);
|
|
420
|
+
|
|
421
|
+
await checkNpmUpdate();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memo-clipboard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Ultra-lightweight, blazing-fast native clipboard manager for Windows, macOS & Linux written in pure Rust — SQLite + FTS5 search, rich text, images, folders, themes & instant auto-paste.",
|
|
5
|
+
"author": "Onur Sercan Yılmaz <onursercanyilmaz@users.noreply.github.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://onursercanyilmaz.github.io/memo/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/onursercanyilmaz/memo.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/onursercanyilmaz/memo/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "bin/memo.js",
|
|
16
|
+
"bin": {
|
|
17
|
+
"memo": "./bin/memo.js",
|
|
18
|
+
"memo-clipboard": "./bin/memo.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin/**/*",
|
|
22
|
+
"prebuilds/**/*",
|
|
23
|
+
"assets/**/*",
|
|
24
|
+
"scripts/install.ps1",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "node bin/memo.js",
|
|
30
|
+
"status": "node bin/memo.js --status",
|
|
31
|
+
"doctor": "node bin/memo.js --doctor",
|
|
32
|
+
"build": "cargo build --release",
|
|
33
|
+
"test": "cargo test && node -c bin/memo.js && node -c scripts/prepare-npm.js",
|
|
34
|
+
"prepare:npm": "node scripts/prepare-npm.js",
|
|
35
|
+
"prepublishOnly": "node scripts/prepare-npm.js",
|
|
36
|
+
"install:windows": "powershell -ExecutionPolicy Bypass -File scripts/install.ps1"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"clipboard",
|
|
40
|
+
"clipboard-manager",
|
|
41
|
+
"clipboard-history",
|
|
42
|
+
"macos",
|
|
43
|
+
"windows",
|
|
44
|
+
"linux",
|
|
45
|
+
"rust",
|
|
46
|
+
"menu-bar",
|
|
47
|
+
"system-tray",
|
|
48
|
+
"ditto-alternative",
|
|
49
|
+
"maccy-alternative",
|
|
50
|
+
"paste",
|
|
51
|
+
"productivity",
|
|
52
|
+
"cli"
|
|
53
|
+
],
|
|
54
|
+
"engines": {
|
|
55
|
+
"node": ">=18.0.0"
|
|
56
|
+
},
|
|
57
|
+
"os": [
|
|
58
|
+
"win32",
|
|
59
|
+
"darwin",
|
|
60
|
+
"linux"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[switch]$Autostart
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
$ErrorActionPreference = "Stop"
|
|
6
|
+
$RepoRoot = Split-Path -Parent $PSScriptRoot
|
|
7
|
+
$ExeSource = Join-Path $RepoRoot "target\release\memo.exe"
|
|
8
|
+
|
|
9
|
+
if (-not (Test-Path $ExeSource)) {
|
|
10
|
+
Write-Host "Building memo.exe (release)..." -ForegroundColor Cyan
|
|
11
|
+
Push-Location $RepoRoot
|
|
12
|
+
cargo build --release
|
|
13
|
+
Pop-Location
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$InstallDir = Join-Path $env:LOCALAPPDATA "Memo"
|
|
17
|
+
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
|
18
|
+
|
|
19
|
+
# Stop running instance if present
|
|
20
|
+
Stop-Process -Name memo -Force -ErrorAction SilentlyContinue
|
|
21
|
+
Start-Sleep -Milliseconds 300
|
|
22
|
+
|
|
23
|
+
$InstalledExe = Join-Path $InstallDir "memo.exe"
|
|
24
|
+
Copy-Item -Path $ExeSource -Destination $InstalledExe -Force
|
|
25
|
+
|
|
26
|
+
$WshShell = New-Object -ComObject WScript.Shell
|
|
27
|
+
|
|
28
|
+
# Create Desktop Shortcut
|
|
29
|
+
$DesktopPath = [Environment]::GetFolderPath("Desktop")
|
|
30
|
+
$DesktopShortcut = $WshShell.CreateShortcut((Join-Path $DesktopPath "Memo.lnk"))
|
|
31
|
+
$DesktopShortcut.TargetPath = $InstalledExe
|
|
32
|
+
$DesktopShortcut.WorkingDirectory = $InstallDir
|
|
33
|
+
$DesktopShortcut.IconLocation = "$InstalledExe,0"
|
|
34
|
+
$DesktopShortcut.Description = "Memo - Ultra-Lightweight Rust Clipboard Manager"
|
|
35
|
+
$DesktopShortcut.Save()
|
|
36
|
+
|
|
37
|
+
# Create Start Menu Shortcut
|
|
38
|
+
$StartMenuDir = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs"
|
|
39
|
+
$StartShortcut = $WshShell.CreateShortcut((Join-Path $StartMenuDir "Memo.lnk"))
|
|
40
|
+
$StartShortcut.TargetPath = $InstalledExe
|
|
41
|
+
$StartShortcut.WorkingDirectory = $InstallDir
|
|
42
|
+
$StartShortcut.IconLocation = "$InstalledExe,0"
|
|
43
|
+
$StartShortcut.Description = "Memo - Ultra-Lightweight Rust Clipboard Manager"
|
|
44
|
+
$StartShortcut.Save()
|
|
45
|
+
|
|
46
|
+
if ($Autostart) {
|
|
47
|
+
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "MemoClipboard" -Value "`"$InstalledExe`""
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Write-Host "Memo installed to $InstallDir" -ForegroundColor Green
|
|
51
|
+
Write-Host "Desktop shortcut created: $(Join-Path $DesktopPath 'Memo.lnk')" -ForegroundColor Green
|