diff --git a/Community.PowerToys.Run.Plugin.CurrencyConverter/Community.PowerToys.Run.Plugin.CurrencyConverter.csproj b/Community.PowerToys.Run.Plugin.CurrencyConverter/Community.PowerToys.Run.Plugin.CurrencyConverter.csproj
index fe9aad2..5b85371 100755
--- a/Community.PowerToys.Run.Plugin.CurrencyConverter/Community.PowerToys.Run.Plugin.CurrencyConverter.csproj
+++ b/Community.PowerToys.Run.Plugin.CurrencyConverter/Community.PowerToys.Run.Plugin.CurrencyConverter.csproj
@@ -10,7 +10,7 @@
Community.PowerToys.Run.Plugin.CurrencyConverter
false
false
- 1.2.1
+ 1.3.0
x64;ARM64
$(Platform)
diff --git a/Community.PowerToys.Run.Plugin.CurrencyConverter/Main.cs b/Community.PowerToys.Run.Plugin.CurrencyConverter/Main.cs
index 3b181b9..f45f2c1 100755
--- a/Community.PowerToys.Run.Plugin.CurrencyConverter/Main.cs
+++ b/Community.PowerToys.Run.Plugin.CurrencyConverter/Main.cs
@@ -38,6 +38,7 @@ public class Main : IPlugin, IContextMenu, ISettingProvider, IDisposable, IDelay
private const int CacheExpirationHours = 3;
private const string AliasFileName = "alias.json";
private const string DefaultAliasResourceName = "Community.PowerToys.Run.Plugin.CurrencyConverter.alias.default.json";
+ private const string GithubReadmeURL = "https://github.com/Advaith3600/PowerToys-Run-Currency-Converter?tab=readme-ov-file#aliasing";
public IEnumerable AdditionalOptions => new List
{
@@ -138,9 +139,22 @@ private double GetConversionRateSync(string fromCurrency, string toCurrency)
if (!response.IsSuccessStatusCode)
{
- throw response.StatusCode == System.Net.HttpStatusCode.NotFound
- ? new Exception($"{fromCurrency.ToUpper()} is not a valid currency")
- : new Exception("Something went wrong while fetching the conversion rate");
+ if (response.StatusCode == System.Net.HttpStatusCode.NotFound)
+ {
+ throw new Exception($"{fromCurrency.ToUpper()} is not a valid currency");
+ }
+ else
+ {
+ var fallbackUrl = $"https://latest.currency-api.pages.dev/v1/currencies/{fromCurrency}.min.json";
+ response = _httpClient.GetAsync(fallbackUrl).Result;
+
+ if (!response.IsSuccessStatusCode)
+ {
+ throw response.StatusCode == System.Net.HttpStatusCode.NotFound
+ ? new Exception($"{fromCurrency.ToUpper()} is not a valid currency")
+ : new Exception("Something went wrong while fetching the conversion rate");
+ }
+ }
}
var content = response.Content.ReadAsStringAsync().Result;
@@ -411,7 +425,18 @@ public List Query(Query query)
{
return string.IsNullOrEmpty(query.ActionKeyword) || string.IsNullOrEmpty(query.Search.Trim())
? new List()
- : new List { new Result { Title = "Loading...", SubTitle = "Please open an issue if needed.", IcoPath = _iconPath } };
+ : new List
+ {
+ new Result
+ {
+ Title = "Loading...",
+ SubTitle = "Please open an issue if needed.",
+ IcoPath = _iconPath,
+ ContextData = new Dictionary { { "externalLink", GithubReadmeURL } },
+ Action = _ => PerformAction("externalLink", GithubReadmeURL)
+ }
+ };
+
}
public List Query(Query query, bool isDelayedExecution)
@@ -432,19 +457,21 @@ public List Query(Query query, bool isDelayedExecution)
}
catch (Exception ex) when (ex is FileNotFoundException || ex is JsonException)
{
- const string link = "https://github.com/Advaith3600/PowerToys-Run-Currency-Converter?tab=readme-ov-file#aliasing";
results.Add(new Result
{
Title = ex.Message,
SubTitle = "Press enter or click to see how to fix this issue",
IcoPath = _warningIconPath,
- ContextData = new Dictionary { { "externalLink", link } },
- Action = _ => PerformAction("externalLink", link)
+ ContextData = new Dictionary { { "externalLink", GithubReadmeURL } },
+ Action = _ => PerformAction("externalLink", GithubReadmeURL)
});
}
}
- return results;
+ return results
+ .GroupBy(r => new { r.Title, r.SubTitle })
+ .Select(g => g.First())
+ .ToList();
}
private void ValidateJsonFormat(string jsonContent)
diff --git a/Community.PowerToys.Run.Plugin.CurrencyConverter/plugin.json b/Community.PowerToys.Run.Plugin.CurrencyConverter/plugin.json
index 0e83fcd..485306c 100755
--- a/Community.PowerToys.Run.Plugin.CurrencyConverter/plugin.json
+++ b/Community.PowerToys.Run.Plugin.CurrencyConverter/plugin.json
@@ -4,7 +4,7 @@
"ActionKeyword": "$$",
"Name": "Currency Converter",
"Author": "advaith3600",
- "Version": "1.2.1",
+ "Version": "1.3.0",
"Language": "csharp",
"Website": "https://github.com/advaith3600/PowerToys-Run-Currency-Converter",
"ExecuteFileName": "Community.PowerToys.Run.Plugin.CurrencyConverter.dll",
diff --git a/exe/CurrencyConverter.nsi b/exe/CurrencyConverter.nsi
index 8c3165a..24f1773 100755
--- a/exe/CurrencyConverter.nsi
+++ b/exe/CurrencyConverter.nsi
@@ -1,50 +1,70 @@
-!define CC "CurrencyConverter"
+!include "MUI2.nsh"
-LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
-
-;--------------------------------
-;Version Information
-VIProductVersion "${ver}.0"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${CC} Setup"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "advaith3600"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "advaith3600"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Currency Converter plugin for PowerToys Run"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${ver}"
-VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${ver}"
;--------------------------------
-
-BrandingText "${CC} v${ver}"
-CRCCheck force
-FileErrorText "Can't write: $\r$\n$\r$\n$0$\r$\n$\r$\nPowerToys is probably still running, please close it and retry."
-Icon icon.ico
+; General Settings
+Name "CurrencyConverter ${ver} ${platform}"
+OutFile ".\..\bin\CurrencyConverter-${ver}-${platform}.exe"
InstallDir "$LOCALAPPDATA\Microsoft\PowerToys\PowerToys Run\Plugins\CurrencyConverter"
-Name "${CC}"
-OutFile ".\..\bin\${CC}-${ver}-${platform}.exe"
RequestExecutionLevel user
-SetCompressor /SOLID /FINAL lzma
+Icon "icon.ico"
+UninstallIcon "icon.ico"
LicenseData "..\LICENSE"
+BrandingText "CurrencyConverter ${ver} ${platform}"
;--------------------------------
+; Interface Settings
+!define MUI_ICON "icon.ico"
+!define MUI_UNICON "icon.ico"
+
+;--------------------------------
+; Pages
+!insertmacro MUI_PAGE_WELCOME
+!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
+!insertmacro MUI_PAGE_DIRECTORY
+!insertmacro MUI_PAGE_INSTFILES
+!insertmacro MUI_PAGE_FINISH
+
+!insertmacro MUI_UNPAGE_WELCOME
+!insertmacro MUI_UNPAGE_CONFIRM
+!insertmacro MUI_UNPAGE_INSTFILES
+!insertmacro MUI_UNPAGE_FINISH
-Page license
-Page instfiles
+!insertmacro MUI_LANGUAGE "English"
;--------------------------------
+; Version Information
+VIProductVersion "${ver}.0"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "CurrencyConverter Setup"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "advaith3600"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "advaith3600"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Currency Converter plugin for PowerToys Run"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${ver}"
+VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${ver}"
+;--------------------------------
+; Installer Sections
Section ""
ClearErrors
+ ; Check if already installed
+ ReadRegStr $0 HKCU "Software\advaith3600\CurrencyConverter" "InstallPath"
+ IfFileExists "$0\uninstall.exe" 0 +7
+ MessageBox MB_YESNO "CurrencyConverter is already installed. Do you want to uninstall it first?" IDYES uninst IDNO abort
+ abort:
+ Abort
+ uninst:
+ ; Execute the uninstaller and wait for it to complete
+ ExecWait '"$0\uninstall.exe"'
+ ; Check if the uninstaller process has finished
+ Sleep 100
+ IfFileExists "$0\uninstall.exe" loop
+ loop:
+ Sleep 100
+ IfFileExists "$0\uninstall.exe" loop
+
SetOutPath $INSTDIR
- GetFullPathName $0 "$EXEDIR\"
- GetFullPathName $0 $0
File /r "${direct}\*"
WriteUninstaller "$INSTDIR\uninstall.exe"
-
- IfErrors 0 +5
- SetErrorlevel 1
- IfSilent +2
- MessageBox MB_ICONEXCLAMATION "Unable to install, PowerToys is probably still running, please close it manually before install."
- Abort
SectionEnd
;--------------------------------
@@ -54,11 +74,11 @@ Section "Add Registry Entries"
WriteRegStr HKCU "Software\advaith3600\CurrencyConverter" "InstallPath" "$INSTDIR"
; Register for uninstallation
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}" "DisplayName" "${CC}"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}" "UninstallString" "$INSTDIR\uninstall.exe"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}" "InstallLocation" "$INSTDIR"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}" "DisplayVersion" "${ver}"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}" "Publisher" "advaith3600"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter" "DisplayName" "CurrencyConverter"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter" "UninstallString" "$INSTDIR\uninstall.exe"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter" "InstallLocation" "$INSTDIR"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter" "DisplayVersion" "${ver}"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter" "Publisher" "advaith3600"
SectionEnd
;--------------------------------
@@ -66,7 +86,7 @@ SectionEnd
Section "Uninstall"
Delete "$INSTDIR\*.*"
RMDir "$INSTDIR"
- DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${CC}"
+ DeleteRegKey HKCU "Software\advaith3600\CurrencyConverter"
+ DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\CurrencyConverter"
SectionEnd
-UninstallIcon icon.ico