FIXED #5 Fixed qutebrowser launch command
Truncate ".yml" from session file name for launch command
This commit is contained in:
parent
a529d22cab
commit
cc1a424f2b
1 changed files with 17 additions and 20 deletions
33
main.go
33
main.go
|
@ -61,7 +61,10 @@ func getBrowserSessions() []sessionOrCommand {
|
||||||
for _, entry := range fileList {
|
for _, entry := range fileList {
|
||||||
if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".yml") {
|
if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".yml") {
|
||||||
log.Printf("INFO %s", entry.Name())
|
log.Printf("INFO %s", entry.Name())
|
||||||
result = append(result, sessionOrCommand{displayString: strings.TrimSuffix(entry.Name(), ".yml"), command: nil})
|
result = append(result, sessionOrCommand{
|
||||||
|
displayString: strings.TrimSuffix(entry.Name(), ".yml"),
|
||||||
|
command: exec.Command("qutebrowser", "--restore", strings.TrimSuffix(entry.Name(), ".yml")),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// log.Printf("result: %v", result)
|
// log.Printf("result: %v", result)
|
||||||
|
@ -82,6 +85,9 @@ func initialModel() model {
|
||||||
}, {
|
}, {
|
||||||
displayString: "bottom",
|
displayString: "bottom",
|
||||||
command: exec.Command("xterm", "-maximized", "-e", "btm", "--group", "--battery", "--color", "gruvbox-light"),
|
command: exec.Command("xterm", "-maximized", "-e", "btm", "--group", "--battery", "--color", "gruvbox-light"),
|
||||||
|
}, {
|
||||||
|
displayString: "broot",
|
||||||
|
command: exec.Command("xterm", "-maximized", "-e", "broot"),
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
// An array of maps which indicates which choices are selected.
|
// An array of maps which indicates which choices are selected.
|
||||||
|
@ -94,29 +100,20 @@ func initialModel() model {
|
||||||
func launch(m model) tea.Cmd {
|
func launch(m model) tea.Cmd {
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
var result statusMsg
|
var result statusMsg
|
||||||
for j, item := range m.choices[BrowserSessions] {
|
for p := 0; p < 2; p++ {
|
||||||
if _, ok := m.selected[BrowserSessions][j]; ok {
|
for q, item := range m.choices[p] {
|
||||||
cmd := exec.Command("qutebrowser", "--restore", item.displayString)
|
if _, ok := m.selected[p][q]; ok {
|
||||||
err := cmd.Start()
|
log.Printf("INFO launching: %v\n", item.displayString)
|
||||||
result += statusMsg(fmt.Sprintf("Launching Qutebrowser session: %v\n", item.displayString))
|
result += statusMsg(fmt.Sprintf("Launching command: %v\n", item.displayString))
|
||||||
|
err := item.command.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result += statusMsg(fmt.Sprintf("%v\n", err))
|
result += statusMsg(fmt.Sprintf("%v\n", err))
|
||||||
log.Fatalf("Error starting browser session: %v\n", err)
|
log.Fatalf("Error launching: %v\n", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, item := range m.choices[Commands] {
|
|
||||||
if _, ok := m.selected[Commands][k]; ok {
|
|
||||||
cmd := item.command
|
|
||||||
err := cmd.Start()
|
|
||||||
result += statusMsg(fmt.Sprintf("Launching command: %v\n", item.displayString))
|
|
||||||
if err != nil {
|
|
||||||
result += statusMsg(fmt.Sprintf("%v\n", err))
|
|
||||||
log.Fatalf("Error starting command: %v\n", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue