WSL: Firefox for Golang default browser

I used a tool called aws-okta. It’s implemented in Go language. ‘login’ command will open generated URL in browser.

Environments where aws-okta login and aws-okta exec are known to work include:

cmd.exe

aws-okta/windows.md at master · segmentio/aws-okta

The page above doesn’t say WSL as one of known to work env.

Indeed, it didn’t work. It complained about ‘xdg-open’ not found. I didn’t want to install this tool. This tool doesn’t have much value for WSL users. WSL has it’s own similar tool , for example wslstart, which will open specified file in appropriate Windows native app.

So, I searched alternative. Sadly, Go standard library doesn’t seem to read any environment variable for alternative browser(e.g. Firefox,Chrome)  as the thread below shows.

there’s OS-specific ways to open things in a browser

cmd/internal/browser: Open() shouldn’t rely on Commands() · Issue #33148 · golang/go

So, I installed xdg-open with ‘sudo apt install’ .  This is not the end of the story. I ended up using 2 environment variables like below.

$ sudo \
  PATH="$PATH:/mnt/c/Program Files/Mozilla Firefox" \
  BROWSER=firefox.exe \
  ~/go/bin/aws-okta login my_profile
[sudo] password for myWSLusername:
Enter passphrase to unlock /home/myWSLusername/.aws-okta/:
INFO[0006] Requesting MFA. Please complete two-factor authentication with your second device
INFO[0006] Select a MFA from the following list
INFO[0006] 0: OKTA (token:software:totp)
INFO[0006] 1: OKTA (push)
Select MFA method: 0

Enter MFA Code: abcdxxxxxxx

There’s related discussion below. But I don’t think the thread covers all solutions for various kinds of envs.

You can set the BROWSER variable.

bash – Open browser in host system from Windows Subsystem for Linux? – Super User

Hope this helps some Windows mate!

Another workaround is to have aws-okta to spit out the generated URL on stdout.

AutoHotkey:Slack通知grep

Windows10のSlackユーザーは以下の画面ショットの右下の通知エリアでdirect messageやchannelの重要なメッセージがポップアップするようにしてる方が多いと思います。

image

Slackでは下の画面ショットの青で注釈入れた部分で設定されてます。Windows Action Center、アクションセンターが正式名称のようです。

右側には実際に通知を表示させています。デフォルトでは最新3メッセージしか出ないようです。変更方法は分かりませんでした。

image

この Slack の最新3メッセージから正規表現で合致した文字列を抜き出してクリップボードに入れる AutoHotkeyスクリプトを書いてGithubに上げました。JIRAのIDのような固定フォーマット文字列を頻繁にSlackで連絡してる方などは使えるかもしれません。

Scan notification area for 3 messages from Slack and extract regex match and store them on copy&paste buffer,

my *.ahk scripts repository to make Windows10 life efficient one.

ところで通知を英語では toast notificationというようです。たしかにアイコンが真四角なので食パンに見えますね。