Skip to content

Commit 892bb07

Browse files
committed
features: change default folder with notes
1 parent 809f41b commit 892bb07

5 files changed

Lines changed: 93 additions & 42 deletions

File tree

QuickNotes/Community.PowerToys.Run.Plugin.QuickNotes/Community.PowerToys.Run.Plugin.QuickNotes.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- Other important properties -->
1919
<RootNamespace>Community.PowerToys.Run.Plugin.QuickNotes</RootNamespace>
2020
<AssemblyName>Community.PowerToys.Run.Plugin.QuickNotes</AssemblyName>
21-
<Version>1.0.10</Version>
21+
<Version>1.0.11</Version>
2222
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
2323
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
2424
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>

QuickNotes/Community.PowerToys.Run.Plugin.QuickNotes/Main.cs

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public class Main : IPlugin, IContextMenu, IPluginI18n, IDisposable, IDelayedExe
9898
private static readonly Regex UrlRegex = new Regex(@"\b(https?://|www\.)\S+\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
9999
private const string NotesFileName = "notes.txt"; // Центральний файл
100100
private const string CUSTOM_PATH_ENV_VAR = "QUICKNOTES_CUSTOM_PATH";
101+
private const string NotesFolderPathKey = "NotesFolderPath";
101102

102103
// --- Properties ---
103104
public string Name => "QuickNotes";
@@ -183,6 +184,15 @@ public Control CreateSettingPanel()
183184
// ISettingProvider
184185
public IEnumerable<PluginAdditionalOption> AdditionalOptions =>
185186
[
187+
new()
188+
{
189+
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Textbox,
190+
Key = NotesFolderPathKey,
191+
DisplayLabel = "Notes folder path",
192+
DisplayDescription = "Leave empty to use the default AppData location. The folder will be created if it does not exist.",
193+
TextBoxMaxLength = 500,
194+
PlaceholderText = @"Example: C:\Users\User\Documents\QuickNotes",
195+
},
186196
new()
187197
{
188198
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Checkbox,
@@ -231,14 +241,17 @@ public void UpdateSettings(PowerLauncherPluginSettings settings)
231241

232242
try
233243
{
244+
_settings.NotesFolderPath = settings.AdditionalOptions.FirstOrDefault(x => x.Key == NotesFolderPathKey)?.TextValue ?? string.Empty;
234245
_settings.EnableGitSync = settings.AdditionalOptions.FirstOrDefault(x => x.Key == EnableGitSyncKey)?.Value ?? false;
235246
_settings.GitRepositoryUrl = settings.AdditionalOptions.FirstOrDefault(x => x.Key == GitRepositoryUrlKey)?.TextValue ?? string.Empty;
236247
_settings.GitBranch = settings.AdditionalOptions.FirstOrDefault(x => x.Key == GitBranchKey)?.TextValue ?? "main";
237248
_settings.GitUsername = settings.AdditionalOptions.FirstOrDefault(x => x.Key == GitUsernameKey)?.TextValue ?? string.Empty;
238249
_settings.GitEmail = settings.AdditionalOptions.FirstOrDefault(x => x.Key == GitEmailKey)?.TextValue ?? string.Empty;
239250

251+
InitializeNotesStorage();
252+
240253
// Recreate git service if enabled
241-
if (_settings.EnableGitSync && !string.IsNullOrEmpty(_settings.GitRepositoryUrl))
254+
if (_settings.EnableGitSync && !string.IsNullOrEmpty(_settings.GitRepositoryUrl) && _isInitialized)
242255
{
243256
var notesDirectory = Path.GetDirectoryName(_notesPath) ?? string.Empty;
244257
if (!string.IsNullOrEmpty(notesDirectory))
@@ -266,34 +279,9 @@ public void Init(PluginInitContext context)
266279
UpdateIconPath(Context.API.GetCurrentTheme());
267280
Context.API.ThemeChanged += OnThemeChanged;
268281

269-
var customPath = Environment.GetEnvironmentVariable(CUSTOM_PATH_ENV_VAR);
270-
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
271-
var powerToysPath = string.IsNullOrEmpty(customPath)
272-
? Path.Combine(appDataPath, "Microsoft", "PowerToys", "QuickNotes")
273-
: customPath;
274-
275-
if (!Directory.Exists(powerToysPath))
276-
Directory.CreateDirectory(powerToysPath);
282+
InitializeNotesStorage();
277283

278-
_notesPath = Path.Combine(powerToysPath, NotesFileName);
279-
if (!File.Exists(_notesPath))
280-
File.WriteAllText(_notesPath, string.Empty);
281-
282-
try
283-
{
284-
File.AppendAllText(_notesPath, string.Empty); // Перевірка доступу на запис
285-
_isInitialized = true;
286-
}
287-
catch (Exception ex)
288-
{
289-
_isInitialized = false;
290-
Log.Exception("QuickNotes: Failed to access notes file", ex,
291-
typeof(Main),
292-
"Community.PowerToys.Run.Plugin.QuickNotes.Main",
293-
nameof(Init),
294-
66);
295-
}
296-
if (_settings.EnableGitSync)
284+
if (_settings.EnableGitSync && _isInitialized)
297285
{
298286
var notesDirectory = Path.GetDirectoryName(_notesPath) ?? throw new InvalidOperationException("Notes directory not found");
299287
_gitSyncService = new GitSyncService(notesDirectory, _settings);
@@ -318,6 +306,60 @@ public void SaveSettings()
318306
// PowerToys will handle settings persistence through the ISettingProvider interface
319307
}
320308

309+
private void InitializeNotesStorage()
310+
{
311+
try
312+
{
313+
var notesDirectory = ResolveNotesDirectory();
314+
if (string.IsNullOrWhiteSpace(notesDirectory))
315+
{
316+
throw new InvalidOperationException("Notes directory path is empty");
317+
}
318+
319+
notesDirectory = Environment.ExpandEnvironmentVariables(notesDirectory.Trim());
320+
notesDirectory = Path.GetFullPath(notesDirectory);
321+
322+
if (!Directory.Exists(notesDirectory))
323+
{
324+
Directory.CreateDirectory(notesDirectory);
325+
}
326+
327+
_notesPath = Path.Combine(notesDirectory, NotesFileName);
328+
329+
if (!File.Exists(_notesPath))
330+
{
331+
File.WriteAllText(_notesPath, string.Empty);
332+
}
333+
334+
File.AppendAllText(_notesPath, string.Empty);
335+
_isInitialized = true;
336+
}
337+
catch (Exception ex)
338+
{
339+
_isInitialized = false;
340+
_notesPath = string.Empty;
341+
Log.Exception("QuickNotes: Failed to initialize notes storage", ex, typeof(Main));
342+
}
343+
}
344+
345+
private string ResolveNotesDirectory()
346+
{
347+
var customPathSetting = _settings?.NotesFolderPath?.Trim();
348+
if (!string.IsNullOrEmpty(customPathSetting))
349+
{
350+
return customPathSetting;
351+
}
352+
353+
var customPathEnv = Environment.GetEnvironmentVariable(CUSTOM_PATH_ENV_VAR);
354+
if (!string.IsNullOrEmpty(customPathEnv))
355+
{
356+
return customPathEnv;
357+
}
358+
359+
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
360+
return Path.Combine(appDataPath, "Microsoft", "PowerToys", "QuickNotes");
361+
}
362+
321363

322364
// Допоміжний метод: відкинути timestamp
323365
private string StripTimestamp(string noteText)

QuickNotes/Community.PowerToys.Run.Plugin.QuickNotes/QuickNotesSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace Community.PowerToys.Run.Plugin.QuickNotes
33
public class QuickNotesSettings
44
{
55
public bool EnableGitSync { get; set; } = false;
6+
public string NotesFolderPath { get; set; } = string.Empty;
67
public string GitRepositoryUrl { get; set; } = string.Empty;
78
public string GitBranch { get; set; } = "main";
89
public string GitUsername { get; set; } = string.Empty;

QuickNotes/Community.PowerToys.Run.Plugin.QuickNotes/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"IsGlobal": false,
55
"Name": "QuickNotes",
66
"Author": "ruslanlap",
7-
"Version": "1.0.10",
7+
"Version": "1.0.11",
88
"Language": "csharp",
99
"Website": "https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes",
1010
"ExecuteFileName": "Community.PowerToys.Run.Plugin.QuickNotes.dll",
1111
"IcoPathDark": "Images\\quicknotes.dark.png",
1212
"IcoPathLight": "Images\\quicknotes.light.png",
1313
"DynamicLoading": false
14-
}
14+
}

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<h2>Create, manage, and search notes directly from PowerToys Run</h2>
88

99
<div>
10-
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-x64.zip">
10+
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-x64.zip">
1111
<img src="https://img.shields.io/badge/⬇_Download_x64-0078D7?style=for-the-badge&logo=windows&logoColor=white" alt="Download x64">
1212
</a>
13-
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-arm64.zip">
13+
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-arm64.zip">
1414
<img src="https://img.shields.io/badge/⬇_Download_ARM64-0078D7?style=for-the-badge&logo=windows&logoColor=white" alt="Download ARM64">
1515
</a>
1616
</div>
@@ -26,7 +26,7 @@
2626
<img src="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/actions/workflows/build-and-release.yml/badge.svg" alt="Build Status">
2727
</a>
2828
<img src="https://img.shields.io/badge/C%23-.NET-512BD4" alt="C#">
29-
<img src="https://img.shields.io/badge/version-1.0.10-brightgreen" alt="Version">
29+
<img src="https://img.shields.io/badge/version-1.0.11-brightgreen" alt="Version">
3030
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs Welcome">
3131
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/stargazers">
3232
<img src="https://img.shields.io/github/stars/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes" alt="GitHub stars">
@@ -52,8 +52,8 @@
5252
<summary>SHA256 Checksums</summary>
5353

5454
```text
55-
# QuickNotes-1.0.10-x64.zip
56-
# QuickNotes-1.0.10-arm64.zip
55+
# QuickNotes-1.0.11-x64.zip
56+
# QuickNotes-1.0.11-arm64.zip
5757
# Checksums will be generated during release build
5858
```
5959

@@ -63,6 +63,8 @@
6363
<img src="assets/image.png" alt="v1.0.10 MEGA RELEASE - Git Sync Feature" style="width:100%;max-width:600px;">
6464
</div>
6565

66+
> 🆕 **v1.0.11**: Added customizable notes folder so you decide where `notes.txt` lives. Huge thanks to [@ShiSui97x](https://github.com/ShiSui97x) for the idea! [Full changelog](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/blob/master/Release.md/CHANGELOG.md)
67+
6668
> 🚀 **v1.0.10 - MEGA RELEASE**: 🎉 **Git Sync Feature** - The game-changer you've been waiting for! Sync your notes across all devices with GitHub integration. Never lose a note again! [Full changelog](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/blob/master/Release.md/CHANGELOG.md)
6769
6870
> 🚀 **v1.0.9**: Improved multi-line notes with better code snippet support. [Full changelog](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/blob/master/Release.md/CHANGELOG.md)
@@ -85,7 +87,7 @@ For detailed documentation, visit the [QuickNotes Wiki](https://github.com/rusla
8587

8688
### Quick Install
8789

88-
1. Download the [x64](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-x64.zip) or [ARM64](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-arm64.zip) version
90+
1. Download the [x64](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-x64.zip) or [ARM64](https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-arm64.zip) version
8991
2. Extract to `%LOCALAPPDATA%\Microsoft\PowerToys\PowerToys Run\Plugins\`
9092
3. Restart PowerToys
9193
4. Start using with `Alt+Space` then type `qq`
@@ -94,7 +96,7 @@ For detailed documentation, visit the [QuickNotes Wiki](https://github.com/rusla
9496

9597
```powershell
9698
# Download and install the latest version (x64)
97-
$url = "https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-x64.zip"
99+
$url = "https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-x64.zip"
98100
$pluginPath = "$env:LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Plugins\QuickNotes"
99101
New-Item -ItemType Directory -Force -Path $pluginPath | Out-Null
100102
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\QuickNotes.zip"
@@ -115,6 +117,7 @@ Write-Host "QuickNotes plugin has been installed. Please restart PowerToys." -Fo
115117
- 📋 **Clipboard Integration** - Copy notes with a single click
116118
- 🔄 **Undo Delete** - Restore recently deleted notes
117119
- 💾 **Simple Backup** - Create backups of your notes collection
120+
- 📂 **Custom Storage Folder** - Choose the directory where your notes live right from PowerToys settings (thanks @ShiSui97x!)
118121

119122
## 🔧 Usage
120123

@@ -191,12 +194,15 @@ Open PowerToys Run (default: <kbd>Alt</kbd> + <kbd>Space</kbd>) and use these co
191194

192195
## 📁 Data Storage
193196

194-
QuickNotes stores all your notes in a simple text file at:
197+
QuickNotes stores all your notes in a simple text file. By default it lives at:
195198

196199
```
197200
%LOCALAPPDATA%\Microsoft\PowerToys\QuickNotes\notes.txt
198201
```
199202

203+
Prefer a different location? Open PowerToys settings → QuickNotes → “Notes folder path” to point the plugin to any folder you like. The plugin will create the folder if it does not exist (idea credit: @ShiSui97x!).
204+
```
205+
200206
## 🛠️ Building from Source
201207
202208
### Prerequisites
@@ -235,7 +241,7 @@ Contributions are welcome! Please check the [Contributing Guidelines](wiki/Contr
235241
236242
<details>
237243
<summary><b>Can I change the storage location?</b></summary>
238-
<p>Currently, the storage location is fixed. A future update may add customizable storage locations.</p>
244+
<p>Yes! Set the “Notes folder path” option in PowerToys → QuickNotes settings. Leave it empty to keep the default AppData folder.</p>
239245
</details>
240246
241247
## 📄 License
@@ -246,18 +252,19 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
246252
247253
- [Microsoft PowerToys](https://github.com/microsoft/PowerToys) team for creating the extensible PowerToys Run platform
248254
- All contributors who have helped improve this plugin
255+
- Special thanks to [@ShiSui97x](https://github.com/ShiSui97x) for inspiring the configurable notes folder feature
249256
- Icons and visual elements from various open-source projects
250257
251258
---
252259
253260
<div align="center">
254261
<h2>📥 Download Latest Version</h2>
255262
256-
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-x64.zip">
263+
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-x64.zip">
257264
<img src="https://img.shields.io/badge/Download-x64_64-0078D7?style=for-the-badge&logo=windows&logoColor=white" alt="Download x64">
258265
</a>
259266
260-
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.10/QuickNotes-1.0.10-arm64.zip">
267+
<a href="https://github.com/ruslanlap/CommunityPowerToysRunPlugin-QuickNotes/releases/download/v1.0.11/QuickNotes-1.0.11-arm64.zip">
261268
<img src="https://img.shields.io/badge/Download-ARM64-0078D7?style=for-the-badge&logo=windows&logoColor=white" alt="Download ARM64">
262269
</a>
263270
@@ -278,6 +285,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
278285
279286
- [Microsoft PowerToys](https://github.com/microsoft/PowerToys) team for creating the extensible PowerToys Run platform
280287
- All contributors who have helped improve this plugin
288+
- Special thanks to [@ShiSui97x](https://github.com/ShiSui97x) for inspiring the configurable notes folder feature
281289
- Icons and visual elements from various open-source projects
282290
283291
### 🧩 Notable Features

0 commit comments

Comments
 (0)