Fixed some autostart issues #178

This commit is contained in:
Michael J. Seiferling
2019-03-09 09:20:37 -06:00
parent 7ca0a50411
commit 7fa0c66ca1
4 changed files with 54 additions and 23 deletions
+38 -18
View File
@@ -1186,8 +1186,9 @@ Public Class frmMain
'Verify the "Start with Windows" setting
If oSettings.StartWithWindows Then
If mgrCommon.IsUnix Then
If Not VerifyAutoStartLinux() Then
UpdateLog(frmMain_ErrorLinuxAutoStartMissing, False, ToolTipIcon.Info)
Dim sVerifyError As String = String.Empty
If Not VerifyAutoStartLinux(sVerifyError) Then
UpdateLog(sVerifyError, False, ToolTipIcon.Info)
End If
Else
If Not VerifyStartWithWindows() Then
@@ -1746,29 +1747,48 @@ Public Class frmMain
End If
End Sub
Private Function VerifyAutoStartLinux() As Boolean
Private Function VerifyAutoStartLinux(ByRef sErrorMessage As String) As Boolean
Dim oProcess As Process
Dim sAutoStartFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & Path.DirectorySeparatorChar & ".config/autostart/"
If File.Exists(sAutoStartFolder & Path.DirectorySeparatorChar & "gbm.desktop") Then
Return True
Else
'Create the autostart folder if it doesn't exist yet
If Not Directory.Exists(sAutoStartFolder) Then
Directory.CreateDirectory(sAutoStartFolder)
'Check if the app is still properly installed
If File.Exists("/usr/share/applications/gbm.desktop") Then
If File.Exists(sAutoStartFolder & Path.DirectorySeparatorChar & "gbm.desktop") Then
Return True
Else
'Create the autostart folder if it doesn't exist yet
If Not Directory.Exists(sAutoStartFolder) Then
Directory.CreateDirectory(sAutoStartFolder)
End If
'Create link
Try
oProcess = New Process
oProcess.StartInfo.FileName = "/bin/ln"
oProcess.StartInfo.Arguments = "-s /usr/share/applications/gbm.desktop " & sAutoStartFolder
oProcess.StartInfo.UseShellExecute = False
oProcess.StartInfo.RedirectStandardOutput = True
oProcess.StartInfo.CreateNoWindow = True
oProcess.Start()
Catch ex As Exception
mgrCommon.ShowMessage(frmSettings_ErrorLinuxAutoStart, ex.Message, MsgBoxStyle.Exclamation)
End Try
sErrorMessage = frmMain_ErrorLinuxAutoStartMissing
Return False
End If
'Create link
Else
'If the app is no longer properly installed, disable autostart and the setting.
Try
oProcess = New Process
oProcess.StartInfo.FileName = "/bin/ln"
oProcess.StartInfo.Arguments = "-s /usr/share/applications/gbm.desktop " & sAutoStartFolder
oProcess.StartInfo.UseShellExecute = False
oProcess.StartInfo.RedirectStandardOutput = True
oProcess.StartInfo.CreateNoWindow = True
oProcess.Start()
oSettings.StartWithWindows = False
oSettings.SaveSettings()
If File.Exists(sAutoStartFolder & Path.DirectorySeparatorChar & "gbm.desktop") Then
File.Delete(sAutoStartFolder & Path.DirectorySeparatorChar & "gbm.desktop")
End If
Catch ex As Exception
mgrCommon.ShowMessage(frmSettings_ErrorLinuxAutoStart, ex.Message, MsgBoxStyle.Exclamation)
End Try
sErrorMessage = frmMain_ErrorLinuxAutoStartLinkMissing
Return False
End If
End Function
@@ -2182,7 +2202,7 @@ Public Class frmMain
tmMinimizeTimer.Start()
End If
Else
Me.gMonTray.Visible = True
Me.gMonTray.Visible = True
End If
End If
Catch ex As Exception
+1 -2
View File
@@ -357,9 +357,8 @@ Public Class frmSettings
chkDisableDiskSpaceCheck.Text = frmSettings_chkDisableDiskSpaceCheck
If mgrCommon.IsUnix Then
'Only enable these options on Linux if GBM was installed with an official method
'Only enable this option on Linux if GBM was installed with an official method
If Not File.Exists("/usr/share/applications/gbm.desktop") Then
chkStartMinimized.Enabled = False
chkAutoStart.Enabled = False
End If
End If
+10 -1
View File
@@ -3309,6 +3309,15 @@ Namespace My.Resources
End Get
End Property
'''<summary>
''' Looks up a localized string similar to GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager..
'''</summary>
Friend ReadOnly Property frmMain_ErrorLinuxAutoStartLinkMissing() As String
Get
Return ResourceManager.GetString("frmMain_ErrorLinuxAutoStartLinkMissing", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to GBM is set to start automatically, but the autostart link is missing. The autostart link has been re-created..
'''</summary>
@@ -4867,7 +4876,7 @@ Namespace My.Resources
End Property
'''<summary>
''' Looks up a localized string similar to An error occured while creating the autostart link:[BR][BR][PARAM].
''' Looks up a localized string similar to An error occured while configuring autostart:[BR][BR][PARAM].
'''</summary>
Friend ReadOnly Property frmSettings_ErrorLinuxAutoStart() As String
Get
+4 -1
View File
@@ -2345,7 +2345,7 @@
<value>GBM is set to start automatically, but the autostart link is missing. The autostart link has been re-created.</value>
</data>
<data name="frmSettings_ErrorLinuxAutoStart" xml:space="preserve">
<value>An error occured while creating the autostart link:[BR][BR][PARAM]</value>
<value>An error occured while configuring autostart:[BR][BR][PARAM]</value>
</data>
<data name="mgrBackup_ErrorRegBackupElevation" xml:space="preserve">
<value>[PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to perform this backup.</value>
@@ -2368,4 +2368,7 @@
<data name="mgrRestore_ErrorRegBackupElevation" xml:space="preserve">
<value>[PARAM] stores saved games in the Windows registry, accessing the registry requires elevated permissions. Please restart GBM as Administrator to restore this backup.</value>
</data>
<data name="frmMain_ErrorLinuxAutoStartLinkMissing" xml:space="preserve">
<value>GBM is set to start automatically, but the desktop link is missing. Automatic start has been disabled, please re-install GBM using a package manager.</value>
</data>
</root>