Skip to content

Commit 9895090

Browse files
committed
Fix #32
1 parent f8734e1 commit 9895090

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

YMouseButtonControl.Linux/Services/StartupInstallerService.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Reflection;
2-
using YMouseButtonControl.Core.Services;
31
using YMouseButtonControl.Core.Services.StartupInstaller;
42

53
namespace YMouseButtonControl.Linux.Services;
@@ -10,6 +8,7 @@ public class StartupInstallerService : IStartupInstallerService
108
[Desktop Entry]
119
Type=Application
1210
Exec={0}
11+
Path={1}
1312
Hidden=false
1413
NoDisplay=false
1514
X-GNOME-Autostart-enabled=true
@@ -46,15 +45,17 @@ public bool InstallStatus()
4645
return File.ReadAllText(_desktopFilePath).Contains(expectedExecLine);
4746
}
4847

49-
public void Install()
50-
{
51-
File.WriteAllText(_desktopFilePath, string.Format(DesktopFile, GetCurExePath()));
52-
}
48+
public void Install() =>
49+
File.WriteAllText(
50+
_desktopFilePath,
51+
string.Format(DesktopFile, GetCurExePath(), GetCurExeParentPath())
52+
);
5353

54-
public void Uninstall()
55-
{
56-
File.Delete(_desktopFilePath);
57-
}
54+
public void Uninstall() => File.Delete(_desktopFilePath);
55+
56+
private static string GetCurExeParentPath() =>
57+
Path.GetDirectoryName(GetCurExePath())
58+
?? throw new Exception("Error retrieving parent of process path");
5859

5960
private static string GetCurExePath() =>
6061
Environment.ProcessPath ?? throw new Exception("Error retrieving process path");

0 commit comments

Comments
 (0)