electron icon indicating copy to clipboard operation
electron copied to clipboard

App Icon command

Open simonhamp opened this issue 2 years ago • 10 comments

Allows you to copy your app icon into the appropriate location for Electron to pick it up and use it

Make sure your icon is a square PNG and at least 1024px x 1024px

Usage

php artisan native:icon

This will look for resources/icon.png in your application.

Alternatively, you can specify a path:

php artisan native:icon public/app-icon.png

simonhamp avatar Aug 07 '23 16:08 simonhamp

I am concerned that with this approach that the change is not persistent, say in Git?

csfh avatar Aug 07 '23 17:08 csfh

I would prefer if the icon would just automatically be copied to the correct location during build time. The default location within the codebase can be configured. This way there's no manual step involved to copy the icon - this can be done in the electron builder instead.

mpociot avatar Aug 07 '23 17:08 mpociot

That would put this in line with the menu bar icons approach as well I believe.

csfh avatar Aug 07 '23 17:08 csfh

I guess this begs the question which API to put this method in.

None of the existing facades are suitable that I can think of. Maybe "Dock" but that is not available or semantically sound for all OS.

Maybe

use Native\Laravel\Facades\App;

...

public function boot()
{
  App::icon(storage_path('app/public/...'));
}

As long as that does not get confused with the Laravel app.

csfh avatar Aug 07 '23 17:08 csfh

My idea would be to just put it into the config file and then copy it automatically. Changing the app icon should just be a matter of replacing a file in your resources directory - rather a convention than actual configuration.

I don't think configuring it via an actual Facade/class makes much sense as you can not change the icon at runtime (cross platform) anyway.

mpociot avatar Aug 07 '23 17:08 mpociot

I agree. I saw the command as a stepping-stone towards that - like, this command could be called from whatever build step command, but opens the door to something more complex than just copying a file, whilst keeping the interface straightforward everywhere

Reasoning: In Tauri, there's a command to actually generate a bunch of icon variations from a single command line call, which puts all those files in the right location - having a command that wraps that and works in a similar fashion across both drivers feels neat

simonhamp avatar Aug 07 '23 18:08 simonhamp

My idea would be to just put it into the config file and then copy it automatically. Changing the app icon should just be a matter of replacing a file in your resources directory - rather a convention than actual configuration.

I don't think configuring it via an actual Facade/class makes much sense as you can not change the icon at runtime (cross platform) anyway.

Do you think we should do the same for the menu icon then?

<?php

return [

...

  'app_icon' => storage_path(env('NATIVEPHP_APP_ICON', 'app/public/appIcon.png')),

  'menu_bar_icon' => storage_path(env('NATIVEPHP_MENU_BAR_ICON', 'app/public/menuBarIcon.png')),

];

csfh avatar Aug 07 '23 18:08 csfh

Do you think we should do the same for the menu icon then?

No, as not every app has a Menubar - but every app has an icon. So it feels better to configure it along with the menu bar to me, instead of having it in a separate config file.

mpociot avatar Aug 07 '23 18:08 mpociot

Do you think we should do the same for the menu icon then?

No, as not every app has a Menubar - but every app has an icon. So it feels better to configure it along with the menu bar to me, instead of having it in a separate config file.

It could be confusing dealing with application assets in such different ways, even if they are different.

Maybe for menu bar, have an API to enable using the icon, and have the icon asset still be configured in the same way as the app icon?

csfh avatar Aug 07 '23 18:08 csfh

somes news ?

vassilidev avatar Apr 13 '24 15:04 vassilidev

I'm closing this PR in favour of #103.

simonhamp avatar Aug 30 '24 11:08 simonhamp