diff options
Diffstat (limited to 'desktop/modules/user/userctl')
| -rwxr-xr-x | desktop/modules/user/userctl | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/desktop/modules/user/userctl b/desktop/modules/user/userctl index 07d3a63..d9720d8 100755 --- a/desktop/modules/user/userctl +++ b/desktop/modules/user/userctl @@ -49,12 +49,16 @@ run() { } # --json, because plain get-property prints non-ASCII as octal escapes. +# Fails with the first line of stderr as its output, so get can report it. prop() { - busctl --system --json=short get-property "$ACC" "$OBJ" "$IFACE" "$1" | jq -r .data + local out + out="$(busctl --system --json=short get-property "$ACC" "$OBJ" "$IFACE" "$1" 2>&1)" \ + || { head -n1 <<< "${out:-failed}"; return 1; } + jq -r .data <<< "$out" } -acc() { run busctl --system call "$ACC" "$OBJ" "$IFACE" "$1" s "$2"; } -kde() { run kwriteconfig6 --file emaildefaults --group PROFILE_Default --key "$1" "$2"; } +acc() { run busctl --system call -- "$ACC" "$OBJ" "$IFACE" "$1" s "$2"; } +kde() { run kwriteconfig6 --file emaildefaults --group PROFILE_Default --key "$1" -- "$2"; } # The surname as an initial, for commits: "Jane Doèr" -> "Jane D.". gitname() { @@ -69,20 +73,22 @@ gitname() { case "$1" in get) - printf 'name=%s\n' "$(prop RealName)" - printf 'email=%s\n' "$(prop Email)" - printf 'avatar=%s\n' "$(prop IconFile)" - printf 'language=%s\n' "$(prop Language)" - printf 'location=%s\n' "$(prop Location)" + out= + # Read everything first: one error line and exit 1, never blank fields. + for p in RealName:name Email:email IconFile:avatar Language:language Location:location; do + val="$(prop "${p%%:*}")" || { printf 'error=%s\n' "$val"; exit 1; } + out+="${p#*:}=$val"$'\n' + done + printf '%s' "$out" printf 'signingkey=%s\n' "$(git config --global --get user.signingkey)" ;; keys) # The first fpr after a sec is the primary key's; the first uid # after that names it. ssb fingerprints come later and are skipped. gpg --list-secret-keys --with-colons 2>/dev/null | awk -F: ' - $1 == "sec" { want = 1; next } + $1 == "sec" { want = ($2 !~ /^[rei]$/ && $12 ~ /S/) ? 1 : 0; next } $1 == "fpr" && want == 1 { fpr = $10; want = 2; next } - $1 == "uid" && want == 2 { print fpr "\t" $10; want = 0 }' + $1 == "uid" && want == 2 && $2 !~ /^[re]$/ { print fpr "\t" $10; want = 0 }' ;; set) [[ $# -eq 3 ]] || usage @@ -105,7 +111,7 @@ case "$1" in if [[ -n "$v" ]]; then run git config --global user.signingkey "$v" elif git config --global --get user.signingkey >/dev/null; then - run git config --global --unset user.signingkey + run git config --global --unset-all user.signingkey fi ;; *) usage ;; |
