Add icon extraction and desktop entry support
- Extract icons from AppImage and install to standard locations - Create proper desktop entry with icon reference - Fix version handling in wrapper script - Update update script to verify icon extraction - Now provides complete desktop integration with proper icon display Resolves icon display issues in desktop environments.
This commit is contained in:
@@ -12,10 +12,17 @@
|
|||||||
|
|
||||||
buildCursor = { version, url, sha256 }:
|
buildCursor = { version, url, sha256 }:
|
||||||
let
|
let
|
||||||
|
src = pkgs.fetchurl { inherit url sha256; };
|
||||||
|
|
||||||
|
# Extract the AppImage to get access to the icon and desktop file
|
||||||
|
appimageContents = pkgs.appimageTools.extract {
|
||||||
|
inherit version src;
|
||||||
|
pname = "cursor";
|
||||||
|
};
|
||||||
|
|
||||||
unwrapped = pkgs.appimageTools.wrapType2 {
|
unwrapped = pkgs.appimageTools.wrapType2 {
|
||||||
pname = "cursor";
|
pname = "cursor";
|
||||||
inherit version;
|
inherit version src;
|
||||||
src = pkgs.fetchurl { inherit url sha256; };
|
|
||||||
|
|
||||||
extraPkgs = p: with p; [
|
extraPkgs = p: with p; [
|
||||||
glib gtk3 cairo pango atk gdk-pixbuf
|
glib gtk3 cairo pango atk gdk-pixbuf
|
||||||
@@ -27,18 +34,73 @@
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.writeShellScriptBin "cursor" ''
|
pkgs.stdenv.mkDerivation {
|
||||||
#!${pkgs.bash}/bin/bash
|
pname = "cursor";
|
||||||
if [[ "$1" == "--version" || "$1" == "-v" ]]; then
|
inherit version;
|
||||||
echo "${version}"
|
|
||||||
exit 0
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
fi
|
|
||||||
export CURSOR_DISABLE_UPDATE="1"
|
unpackPhase = "true";
|
||||||
export CURSOR_SKIP_UPDATE_CHECK="1"
|
|
||||||
export XDG_CACHE_HOME="$(mktemp -d -t cursor-xdg-cache-XXXXXX)"
|
installPhase = ''
|
||||||
export CURSOR_CACHE_DIR="$(mktemp -d -t cursor-cache-XXXXXX)"
|
mkdir -p $out/bin $out/share/applications $out/share/icons/hicolor/scalable/apps $out/share/icons/hicolor/256x256/apps $out/share/pixmaps
|
||||||
exec "${unwrapped}/bin/cursor" "$@"
|
|
||||||
'';
|
# Create version-aware wrapper script
|
||||||
|
cat > $out/bin/cursor << EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
if [[ "\$1" == "--version" || "\$1" == "-v" ]]; then
|
||||||
|
echo "${version}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
export CURSOR_DISABLE_UPDATE="1"
|
||||||
|
export CURSOR_SKIP_UPDATE_CHECK="1"
|
||||||
|
export XDG_CACHE_HOME="\$(mktemp -d -t cursor-xdg-cache-XXXXXX)"
|
||||||
|
export CURSOR_CACHE_DIR="\$(mktemp -d -t cursor-cache-XXXXXX)"
|
||||||
|
exec "${unwrapped}/bin/cursor" "\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x $out/bin/cursor
|
||||||
|
|
||||||
|
# Extract and install icon (try multiple possible locations and formats)
|
||||||
|
if [ -f "${appimageContents}/cursor.png" ]; then
|
||||||
|
cp "${appimageContents}/cursor.png" $out/share/pixmaps/cursor.png
|
||||||
|
cp "${appimageContents}/cursor.png" $out/share/icons/hicolor/256x256/apps/cursor.png
|
||||||
|
elif [ -f "${appimageContents}/Cursor.png" ]; then
|
||||||
|
cp "${appimageContents}/Cursor.png" $out/share/pixmaps/cursor.png
|
||||||
|
cp "${appimageContents}/Cursor.png" $out/share/icons/hicolor/256x256/apps/cursor.png
|
||||||
|
elif [ -f "${appimageContents}/usr/share/pixmaps/cursor.png" ]; then
|
||||||
|
cp "${appimageContents}/usr/share/pixmaps/cursor.png" $out/share/pixmaps/cursor.png
|
||||||
|
cp "${appimageContents}/usr/share/pixmaps/cursor.png" $out/share/icons/hicolor/256x256/apps/cursor.png
|
||||||
|
elif [ -f "${appimageContents}/usr/share/icons/hicolor/256x256/apps/cursor.png" ]; then
|
||||||
|
cp "${appimageContents}/usr/share/icons/hicolor/256x256/apps/cursor.png" $out/share/pixmaps/cursor.png
|
||||||
|
cp "${appimageContents}/usr/share/icons/hicolor/256x256/apps/cursor.png" $out/share/icons/hicolor/256x256/apps/cursor.png
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try SVG icon as well
|
||||||
|
if [ -f "${appimageContents}/cursor.svg" ]; then
|
||||||
|
cp "${appimageContents}/cursor.svg" $out/share/icons/hicolor/scalable/apps/cursor.svg
|
||||||
|
elif [ -f "${appimageContents}/Cursor.svg" ]; then
|
||||||
|
cp "${appimageContents}/Cursor.svg" $out/share/icons/hicolor/scalable/apps/cursor.svg
|
||||||
|
elif [ -f "${appimageContents}/usr/share/icons/hicolor/scalable/apps/cursor.svg" ]; then
|
||||||
|
cp "${appimageContents}/usr/share/icons/hicolor/scalable/apps/cursor.svg" $out/share/icons/hicolor/scalable/apps/cursor.svg
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create desktop entry
|
||||||
|
cat > $out/share/applications/cursor.desktop << EOF
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Cursor
|
||||||
|
Comment=AI-powered code editor
|
||||||
|
GenericName=Text Editor
|
||||||
|
Exec=$out/bin/cursor %F
|
||||||
|
Icon=cursor
|
||||||
|
Type=Application
|
||||||
|
StartupNotify=true
|
||||||
|
MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/javascript;application/json;text/x-markdown;text/x-web-markdown;text/html;text/css;text/x-sql;text/x-diff;
|
||||||
|
Categories=Development;IDE;
|
||||||
|
Keywords=editor;development;programming;ide;
|
||||||
|
StartupWMClass=Cursor
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${system} = {
|
packages.${system} = {
|
||||||
|
|||||||
@@ -104,6 +104,19 @@ if nix build .#cursor; then
|
|||||||
else
|
else
|
||||||
print_warning "Version mismatch: expected $NEW_VERSION, got $BUILT_VERSION"
|
print_warning "Version mismatch: expected $NEW_VERSION, got $BUILT_VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check that icon and desktop entry were installed
|
||||||
|
if [[ -f "./result/share/pixmaps/cursor.png" ]]; then
|
||||||
|
print_success "Icon successfully extracted and installed!"
|
||||||
|
else
|
||||||
|
print_warning "Icon not found - might not display properly in desktop"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "./result/share/applications/cursor.desktop" ]]; then
|
||||||
|
print_success "Desktop entry created!"
|
||||||
|
else
|
||||||
|
print_warning "Desktop entry not found"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
print_error "Build failed!"
|
print_error "Build failed!"
|
||||||
|
|||||||
Reference in New Issue
Block a user