Use Browsh-specific FF profile.

Also adds `-debug` flag.
pull/69/head v0.2.6
Thomas Buckley-Houston 2018-02-03 14:36:49 +08:00
rodzic 3b7ee79808
commit c0e51e6413
6 zmienionych plików z 30 dodań i 7 usunięć

8
interfacer/Gopkg.lock wygenerowano
Wyświetl plik

@ -20,14 +20,14 @@
revision = "aa4a75b1c20a2b03751b1a9f7e41d58bd6f71c43"
[[projects]]
name = "github.com/shuLhan/go-bindata"
branch = "master"
name = "github.com/shibukawa/configdir"
packages = ["."]
revision = "13e7f547b03edacc82d8b69dcf1f404b7f1d97f7"
version = "v3.2.0"
revision = "e180dbdc8da04c4fa04272e875ce64949f38bd3e"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "2c892d289743dedad27a5cab0c6716e1949efe9aa7cee7b683ce50ad5c15e5d6"
inputs-digest = "e1642a608af3337f43720099e44ef494d6d73b19c3c61f5422be19c8465df364"
solver-name = "gps-cdcl"
solver-version = 1

Wyświetl plik

@ -9,3 +9,7 @@
[[constraint]]
name = "github.com/shuLhan/go-bindata"
version = "3.2.0"
[[constraint]]
branch = "master"
name = "github.com/shibukawa/configdir"

Wyświetl plik

@ -21,6 +21,8 @@ import (
"github.com/nsf/termbox-go"
"github.com/gorilla/websocket"
"github.com/shibukawa/configdir"
)
var (
@ -30,6 +32,7 @@ var (
isFFGui = flag.Bool("with-gui", false, "Don't use headless Firefox")
isUseExistingFirefox = flag.Bool("use-existing-ff", false, "Whether Browsh should launch Firefox or not")
useFFProfile = flag.String("ff-profile", "default", "Firefox profile to use")
isDebug = flag.Bool("debug", false, "Log to ./debug.log")
upgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool { return true },
ReadBufferSize: 1024,
@ -85,6 +88,9 @@ func setupLogging() {
}
func log(msg string) {
if !*isDebug {
return
}
f, oErr := os.OpenFile(logfile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if oErr != nil {
shutdown(oErr.Error())
@ -272,6 +278,14 @@ func webSocketServer(w http.ResponseWriter, r *http.Request) {
sendTtySize()
}
// Gets a cross-platform path to store Browsh config
func getConfigFolder() string {
configDirs := configdir.New("browsh", "firefox_profile")
folders := configDirs.QueryFolders(configdir.Global)
folders[0].MkdirAll()
return folders[0].Path
}
func startHeadlessFirefox() {
println("Starting...")
log("Starting Firefox in headless mode")
@ -280,7 +294,12 @@ func startHeadlessFirefox() {
args = append(args, "--headless")
}
if *useFFProfile != "default" {
log("Using profile: " + *useFFProfile)
args = append(args, "-P", *useFFProfile)
} else {
profilePath := getConfigFolder()
log("Using default profile at: " + profilePath)
args = append(args, "--profile", profilePath)
}
firefoxProcess := exec.Command(*firefoxBinary, args...)
defer firefoxProcess.Process.Kill()

Wyświetl plik

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Browsh",
"version": "0.2.5",
"version": "0.2.6",
"description": "Renders the browser as realtime, interactive, TTY-compatible text",

Wyświetl plik

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Browsh",
"version": "0.2.5",
"version": "0.2.6",
"description": "Renders the browser as realtime, interactive, TTY-compatible text",

Wyświetl plik

@ -63,7 +63,7 @@ class Helper {
env: process.env
});
this.browshPTY.write(`cd ${dir} \r`);
this.browshPTY.write(`go run *.go -use-existing-ff \r`);
this.browshPTY.write(`go run *.go -use-existing-ff -debug \r`);
this.broadcastOutput();
}