add profile-image

This commit is contained in:
Daniel Langbein 2025-01-19 13:00:38 +01:00
parent 4403c58b0d
commit d068ee91db
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
9 changed files with 60 additions and 9 deletions

View File

@ -0,0 +1,9 @@
Pixabay License: https://pixabay.com/service/license/
Credits:
* https://pixabay.com/users/ribastank-805206/
Source:
* https://pixabay.com/photos/yoda-starwars-actionfigure-667955/
* https://free-images.com/display/yoda_starwars_actionfigure_667955.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 KiB

View File

@ -26,10 +26,7 @@
#../../modules/programs-kde.nix
#
../../modules/gnome-base.nix
../../modules/gnome-config.nix
../../modules/gnome-extensions.nix
../../modules/fwupd-gnome.nix
../../modules/gnome-wallpaper.nix
../../modules/programs-gnome.nix
../../modules/programs-base.nix

View File

@ -28,12 +28,9 @@
#../../modules/programs-kde.nix
#
../../modules/gnome-base.nix
../../modules/gnome-config.nix
../../modules/gnome-extensions.nix
# Not required as display scale is set 2.0 (multiple of 1).
#../../modules/gnome-fractional-scaling.nix
../../modules/fwupd-gnome.nix
../../modules/gnome-wallpaper.nix
../../modules/programs-gnome.nix
../../modules/programs-base.nix

View File

@ -34,11 +34,8 @@
#../../modules/programs-kde.nix
#
../../modules/gnome-base.nix
../../modules/gnome-config.nix
../../modules/gnome-extensions.nix
../../modules/gnome-fractional-scaling.nix
#../../modules/fwupd-gnome.nix # TODO: Constantly keeps installing the same fw update again
../../modules/gnome-wallpaper.nix
../../modules/programs-gnome.nix
../../modules/programs-base.nix

View File

@ -7,6 +7,10 @@
imports = [
./audio.nix
./gnome-config.nix
./gnome-extensions.nix
./gnome-wallpaper.nix
./gnome-profile-image.nix
];
# Enable the X11 windowing system.

View File

@ -0,0 +1,29 @@
{ config, pkgs, ... }:
let
dir = "/var/lib/AccountsService/icons";
user = "yoda";
in
{
# https://discourse.nixos.org/t/setting-the-user-profile-image-under-gnome/36233/4
# Important: File permissions and file format
# https://discourse.nixos.org/t/setting-the-user-profile-image-under-gnome/36233/7
# https://github.com/tolgaerok/nixos-kde/blob/3c4b55f2b0345facc5bc5157750dfaecef9d4d6c/machines/LAPTOPS/HP-i5-ProBook-6460b/user/user-profile-pic/default.nix
# https://github.com/tolgaerok/nixos-kde/blob/3c4b55f2b0345facc5bc5157750dfaecef9d4d6c/user/user-home-settings/create-user-profile-pics.nix
# After changing my profile image in KDE Plasma 6, this file was created:
# /var/lib/AccountsService/users
# With content:
# [User]
# Icon=/var/lib/AccountsService/icons/yoda
# SystemAccount=false
# Permissions: root:root 0600
# `system.activationScripts`:
# - Since these are executed every time you boot the system or run `nixos-rebuild`, its important that they are idempotent and fast.
system.activationScripts.setGnomeProfilePicture = ''
mkdir -p ${dir}
cp ${(pkgs.callPackage ./profile-image.nix { })}/img.png ${dir}/${user}
'';
}

18
modules/profile-image.nix Normal file
View File

@ -0,0 +1,18 @@
{ pkgs, lib }:
let
max-width = "256";
in
pkgs.stdenv.mkDerivation rec{
name = "yoda-profile-image";
src = "${../assets/img/profile-image/face.jpg}";
nativeBuildInputs = with pkgs; [ imagemagick ];
phases = "installPhase";
# magick limit width: https://stackoverflow.com/a/38415211/6334421
# magick jpg options: quality, progressive, strip metadata. https://stackoverflow.com/a/7262050/6334421
installPhase = ''
set -eu -o pipefail
mkdir -p $out
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' -quality 90% -interlace Plane -strip $out/img.jpg
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' $out/img.png
'';
}