-
-
Save seanthegeek/10bd3bab4fe3cb0df2fcdf18d43fc48a to your computer and use it in GitHub Desktop.
Fish shell + WSL2 + gnome-keyring / secret-tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This fish config sets up a working `gnome-keyring` on WSL2. | |
# I imagine it will work with WSL1 as well, perhaps after adjusting the `DISPLAY` value. | |
# | |
# Based off this bash script: https://askubuntu.com/questions/815327/running-gnome-keyring-on-wsl-windows-subsystem-for-linux | |
# Tested and working with `aws-vault` and `jetbrains-toolbox`. | |
# | |
# Be sure your x server is running!!! | |
set -x DISPLAY (cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0 | |
pgrep dbus-daemon > /dev/null | |
if test $status -eq 1 | |
dbus-launch --sh-syntax | read --line bus_address ignored bus_pid bus_windowid | |
set -Ux DBUS_SESSION_BUS_ADDRESS (string match -r "'(.*)'" $bus_address)[2] | |
set -Ux DBUS_SESSION_BUS_ID (string match -r "=(.*);" $bus_pid)[2] | |
set -Ux DBUS_SESSION_BUS_WINDOWID (string match -r "=(.*);" $bus_windowid)[2] | |
end | |
# This command fixes "No such secret collection at path: /" | |
# https://github.com/NixOS/nixpkgs/issues/174099#issuecomment-1137916279 | |
dbus-update-activation-environment --systemd DISPLAY | |
# pgrep limited to 15 chars, so truncate `daemon` | |
pgrep gnome-keyring-d > /dev/null | |
if test $status -eq 1 | |
gnome-keyring-daemon | read --line gnome_keyring_control ssh_auth_sock | |
set -Ux GNOME_KEYRING_CONTROL (string split -m 1 = $gnome_keyring_control)[2] | |
set -Ux SSH_AUTH_SOCK (string split -m 1 = $ssh_auth_sock)[2] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment