Skip to content

Commit

Permalink
Use Browsh-specific FF profile.
Browse files Browse the repository at this point in the history
Also adds `-debug` flag.
  • Loading branch information
tombh committed Feb 3, 2018
1 parent 3b7ee79 commit c0e51e6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
8 changes: 4 additions & 4 deletions interfacer/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions interfacer/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
[[constraint]]
name = "github.com/shuLhan/go-bindata"
version = "3.2.0"

[[constraint]]
branch = "master"
name = "github.com/shibukawa/configdir"
19 changes: 19 additions & 0 deletions interfacer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/nsf/termbox-go"

"github.com/gorilla/websocket"
"github.com/shibukawa/configdir"

)

var (
Expand All @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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")
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion webext/dist/manifest.json
Original file line number Diff line number Diff line change
@@ -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",

Expand Down
2 changes: 1 addition & 1 deletion webext/manifest.json
Original file line number Diff line number Diff line change
@@ -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",

Expand Down
2 changes: 1 addition & 1 deletion webext/test/integration/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit c0e51e6

Please sign in to comment.