From 01272e38af7b5c3ae4ef15ac66a7309706a442eb Mon Sep 17 00:00:00 2001 From: Recolic K <bensl@microsoft.com> Date: Mon, 21 Jun 2021 18:12:21 +0800 Subject: [PATCH] optimize scripts --- README.md | 2 +- unlock_keyrings.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 13ff0f1..8abcea4 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ gnome-keyring-yubikey-unlock/create_secret_file.sh /path/to/your_secret [Your Gn # input your keyring:password ``` -As an example, I need to input `默认钥匙环:My_Very_Long_Login_Password`. +As an example, I need to input `默认钥匙环:My_Very_Long_Login_Password`. (You may use `seahorse` to determine the name of your keyring) Then, add the following command to gnome-autostart. You should know how to auto-run a command after starting gnome. diff --git a/unlock_keyrings.sh b/unlock_keyrings.sh index 43e3071..5638eec 100755 --- a/unlock_keyrings.sh +++ b/unlock_keyrings.sh @@ -1,7 +1,7 @@ #!/bin/bash # This script should be run after gnome being started. -_my_path="$0" +_self_bin_name="$0" secret_file="$1" [[ "$secret_file" = '' ]] && echo "Usage: $0 <secret_file>" && exit 1 @@ -15,10 +15,11 @@ function where_is_him () { done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" echo -n "$DIR" - } +} function where_am_i () { - where_is_him "$_my_path" + _my_path=`type -p ${_self_bin_name}` + [[ "$_my_path" = "" ]] && where_is_him "$_self_bin_name" || where_is_him "$_my_path" } cd `where_am_i` && -- GitLab