solemnwarning / rehex

Reverse Engineers' Hex Editor
https://rehex.solemnwarning.net/
GNU General Public License v2.0
2.31k stars 116 forks source link

Add png2icns as a fallback to iconutil #107

Closed SuperSandro2000 closed 3 years ago

SuperSandro2000 commented 3 years ago

I am currently helping packaging rehex for Nix which does not contain iconutil because there is no source for it and can't fallback to the system one because this would be impure. Would it be possible to fallback (https://github.com/solemnwarning/rehex/blob/master/Makefile.osx#L55) to something else when iconutil is not available on macos?

Edit: I will try to compose a patch based on https://github.com/NixOS/nixpkgs/blob/66172a2ea4fa28e9a8692a6ad2adad7b65d0fe16/pkgs/applications/misc/kitty/png2icns.patch.

This command worked for me:

png2icns res/REHex.icns res/REHex.iconset/icon_16x16.png res/REHex.iconset/icon_32x32.png res/REHex.iconset/icon_128x128.png res/REHex.iconset/icon_256x256.png res/REHex.iconset/icon_512x512.png

I am not sure how to integrate this into the Makefile as an fallback. Help would be appreciated.

solemnwarning commented 3 years ago

So, this is Mac-specific, right?

Do you want it to fallback to png2icns only when iconutil isn't available, or would it be helpful to have a build option in the context of Nix?

SuperSandro2000 commented 3 years ago

So, this is Mac-specific, right?

Yeah, more like nix for darwin specific than mac.

Do you want it to fallback to png2icns only when iconutil isn't available, or would it be helpful to have a build option in the context of Nix?

It would be helpful in the context of Nix because we do not have iconutil available.

solemnwarning commented 3 years ago

Does the Makefile change on the png2icns-fallback branch work for you?

SuperSandro2000 commented 3 years ago

@solemnwarning Can you remove the which part and just call the executable directly?

Also it errors because the sizes are double.

mkdir res/REHex.iconset
cp res/icon16.png   res/REHex.iconset/icon_16x16.png
cp res/icon32.png   res/REHex.iconset/icon_16x16@2x.png
cp res/icon32.png   res/REHex.iconset/icon_32x32.png
cp res/icon64.png   res/REHex.iconset/icon_32x32@2x.png
cp res/icon128.png  res/REHex.iconset/icon_128x128.png
cp res/icon256.png  res/REHex.iconset/icon_128x128@2x.png
cp res/icon256.png  res/REHex.iconset/icon_256x256.png
cp res/icon512.png  res/REHex.iconset/icon_256x256@2x.png
cp res/icon512.png  res/REHex.iconset/icon_512x512.png
cp res/icon1024.png res/REHex.iconset/icon_512x512@2x.png
png2icns res/REHex.icns res/REHex.iconset/*
Using icns type 'it32', mask 't8mk' for 'res/REHex.iconset/icon_128x128.png'
Using icns type 'ic08' (ARGB) for 'res/REHex.iconset/icon_128x128@2x.png'
Using icns type 'is32', mask 's8mk' for 'res/REHex.iconset/icon_16x16.png'
Using icns type 'il32', mask 'l8mk' for 'res/REHex.iconset/icon_16x16@2x.png'
Duplicate icon element of type 'ic08' detected (res/REHex.iconset/icon_256x256.png)
make: *** [Makefile.osx:59: res/REHex.icns] Error 1`
solemnwarning commented 3 years ago

The which command is for checking if png2icns is actually installed, does Nix not have which?

So the @2x icons aren't used on Nix?

SuperSandro2000 commented 3 years ago

The which command is for checking if png2icns is actually installed, does Nix not have which?

All bash commands are available by default but I can specify which to make it available. A little nitpick which is not that important.

So the @2x icons aren't used on Nix?

I think the png2icns used in Nix does not use it. The tool is part of libicns https://icns.sourceforge.io/.

solemnwarning commented 3 years ago

Okay, pushed another commit to stop the @2x icons being used.

SuperSandro2000 commented 3 years ago

Thanks! I think this is fine now and can be merged.

solemnwarning commented 3 years ago

Merged to master in f19287fad329b54566b18a47a3ea8379adaa8d1a.