diff options
Diffstat (limited to 'desktop/modules/user/userctl')
| -rwxr-xr-x | desktop/modules/user/userctl | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/desktop/modules/user/userctl b/desktop/modules/user/userctl index d9720d8..5ad31d1 100755 --- a/desktop/modules/user/userctl +++ b/desktop/modules/user/userctl @@ -18,7 +18,9 @@ # userctl set <key> <val> write one field to every store holding it # # Stores: AccountsService (and through SetRealName the passwd GECOS that -# LibreOffice reads), KDE's ~/.config/emaildefaults, the global git config. +# LibreOffice reads), KDE's ~/.config/emaildefaults, the global git config, +# and ~/.user-icon.jpg, the avatar hyprlock, the SDDM theme and the rofi +# power menu read (udt-accent points the greeter at it). # Polkit lets a user change their own AccountsService entry without a prompt. # # set prints nothing on success. On a failing write it prints the command and @@ -30,6 +32,7 @@ set -u # Character-wise ${x:0:1}, so an accented initial is not cut in half. export LC_ALL=C.UTF-8 +AVATAR="$HOME/.user-icon.jpg" ACC=org.freedesktop.Accounts OBJ="/org/freedesktop/Accounts/User$(id -u)" IFACE=org.freedesktop.Accounts.User @@ -77,6 +80,8 @@ case "$1" in # 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; } + # The desktop's avatar wins; AccountsService's is the fallback. + [[ "${p#*:}" == avatar && -e "$AVATAR" ]] && val="$AVATAR" out+="${p#*:}=$val"$'\n' done printf '%s' "$out" @@ -104,7 +109,13 @@ case "$1" in kde EmailAddress "$v" run git config --global user.email "$v" ;; - avatar) acc SetIconFile "$v" ;; + avatar) + # Converted, so the .jpg name is true whatever was picked; + # renamed into place, so no reader sees half a file. + run magick "$v" -auto-orient -strip "$AVATAR.tmp.jpg" + run mv -f "$AVATAR.tmp.jpg" "$AVATAR" + acc SetIconFile "$AVATAR" + ;; language) acc SetLanguage "$v" ;; location) acc SetLocation "$v" ;; signingkey) |
