Skip to content

Commit

Permalink
fix linux profile path
Browse files Browse the repository at this point in the history
  • Loading branch information
arguablykomodo committed Jun 20, 2018
1 parent b56f242 commit 632a798
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion fallbackui.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func createFallbackUI() {
return
}

fmt.Print("ShadowFox updater 1.5.1\n\n")
fmt.Print("ShadowFox updater 1.5.2\n\n")

fmt.Println("Available profiles:")
for i, name := range names {
Expand Down
33 changes: 23 additions & 10 deletions profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,48 @@ func getProfilePaths() ([]string, []string) {
if err != nil {
panic(err)
}
if !exists {
if exists {
iniPath = filepath.Join(filepath.Dir(cwd), "profiles.ini")
} else {
homedir, err := homedir.Dir()
if err != nil {
panic(err)
}

var possible []string

switch runtime.GOOS {
case "windows":
iniPath = homedir + "\\AppData\\Roaming\\Mozilla\\Firefox\\profiles.ini"
possible = []string{homedir + "\\AppData\\Roaming\\Mozilla\\Firefox\\profiles.ini"}

case "darwin":
iniPath = homedir + "/Library/Application Support/Firefox/profiles.ini"
possible = []string{homedir + "/Library/Application Support/Firefox/profiles.ini"}

case "linux":
iniPath = homedir + "/.mozilla/firefox/profiles.ini"
possible = []string{
homedir + "/.mozilla/firefox/profiles.ini",
homedir + "/.mozilla/firefox-trunk/profiles.ini",
}

default:
panic("Sorry, but this program only works on Windows, Mac OS, or Linux")
}

exists, _, err := pathExists(iniPath)
if err != nil {
panic(err)
found := false
for _, p := range possible {
exists, _, err := pathExists(p)
if err != nil {
panic(err)
}
if exists {
iniPath = p
found = true
break
}
}
if !exists {
if !found {
return nil, nil
}
} else {
iniPath = filepath.Join(filepath.Dir(cwd), "profiles.ini")
}

file, err := ini.Load(iniPath)
Expand Down
4 changes: 2 additions & 2 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func createUI() error {
AddItem(nil, 1, 0, false).
AddItem(exitButton, 0, 1, true), 3, 0, true,
)
flex.SetBorder(true).SetTitle("ShadowFox updater 1.5.1").SetBorderPadding(1, 1, 1, 1)
flex.SetBorder(true).SetTitle("ShadowFox updater 1.5.2").SetBorderPadding(1, 1, 1, 1)

if paths == nil {
text := tview.NewTextView().SetText(
Expand All @@ -144,7 +144,7 @@ func createUI() error {
"3. Run the program ",
).SetTextAlign(tview.AlignCenter)

text.SetBorder(true).SetTitle("ShadowFox updater 1.5.1").SetBorderPadding(1, 1, 1, 1)
text.SetBorder(true).SetTitle("ShadowFox updater 1.5.2").SetBorderPadding(1, 1, 1, 1)

app.SetRoot(text, true)
} else {
Expand Down

0 comments on commit 632a798

Please sign in to comment.