Skip to content

Instantly share code, notes, and snippets.

@BreadFish64
Created April 5, 2026 05:35
Show Gist options
  • Select an option

  • Save BreadFish64/fb50f1161b6dc14df8414a1161860a08 to your computer and use it in GitHub Desktop.

Select an option

Save BreadFish64/fb50f1161b6dc14df8414a1161860a08 to your computer and use it in GitHub Desktop.
Extract icon from .exe to the user's icon directory. Useful for setting wine application shortcut icons with correct mip levels in Plasma.
function png_to_icon_root -a png_path exe_name
set icon_root ~/.local/share/icons/hicolor
set dimensions (magick identify -ping -format '%wx%h' $png_path)
set destination "$icon_root/$dimensions/apps/$exe_name.png"
mv --verbose $png_path $destination
end
function extract_exe_icon -a exe_path
set exe_name (path basename $exe_path)
set extract_dir (mktemp --directory)
wrestool --verbose --extract --type=14 --output="$extract_dir/icon.ico" $exe_path
magick -verbose "$extract_dir/icon.ico" -alpha on "$extract_dir/icon.png"
for png in $extract_dir/*.png
png_to_icon_root $png $exe_name &
end
wait
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment