Fl4m3Ph03n1x

Fl4m3Ph03n1x

How to have an application Icon with Elixir desktop?

Background

I am trying to have an Elixir desktop application, and I am using elixir-desktop-app as a starting point.

Problem

The only thing I want is to have an icon represent my app. However, this is not happening (left side bar has what appears to be an empty icon instead of a real icon):

I ran this application with the following commands:

  • mix deps.get
  • cd assets/
  • npm install
  • cd ..
  • mix assets.deploy
  • ./run

And when I run the script, I see no errors:

$ ./run 
Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

warning: use Mix.Config is deprecated. Use the Config module instead
  config/dev.exs:1


12:05:52.202 [info]  Application eex started at :nonode@nohost
 
12:05:52.208 [info]  Application mime started at :nonode@nohost
 
12:05:52.208 [info]  Child Agent of Supervisor Plug.Crypto.Application started
Pid: #PID<0.283.0>
Start Call: Agent.start_link(#Function<0.16488927/0 in Plug.Crypto.Application."-fun.start_crypto_keys/0-">)
Restart: :permanent
Shutdown: 5000
Type: :worker
 
12:05:52.211 [info]  Application plug_crypto started at :nonode@nohost
 
12:05:52.213 [info]  Child :telemetry_handler_table of Supervisor :telemetry_sup started
Pid: #PID<0.288.0>
Start Call: :telemetry_handler_table.start_link()
Restart: :permanent
Shutdown: 5000
Type: :worker
 
12:05:52.213 [info]  Application telemetry started at :nonode@nohost
 
12:05:52.214 [info]  Child Plug.Upload of Supervisor Plug.Application started
Pid: #PID<0.293.0>
Start Call: Plug.Upload.start_link([])
Restart: :permanent
Shutdown: 5000
Type: :worker
 
12:05:52.215 [info]  Application plug started at :nonode@nohost
 
12:05:52.216 [info]  Child :pg of Supervisor #PID<0.297.0> (Supervisor.Default) started
Pid: #PID<0.298.0>
Start Call: :pg.start_link(Phoenix.PubSub)
Restart: :permanent
Shutdown: 5000
Type: :worker
 
12:05:52.216 [info]  Application phoenix_pubsub started at :nonode@nohost
 
12:05:52.216 [info]  Application phoenix_view started at :nonode@nohost
 
12:05:52.222 [info]  Child Phoenix.CodeReloader.Server of Supervisor Phoenix.Supervisor started
Pid: #PID<0.304.0>
Start Call: Phoenix.CodeReloader.Server.start_link([])
Restart: :permanent
Shutdown: 5000
Type: :worker
 
12:05:52.222 [info]  Child Phoenix.Transports.LongPoll.Supervisor of Supervisor Phoenix.Supervisor started
Pid: #PID<0.305.0>
Start Call: DynamicSupervisor.start_link([name: Phoenix.Transports.LongPoll.Supervisor, strategy: :one_for_one])
Restart: :permanent
Shutdown: :infinity
Type: :supervisor
 
12:05:52.222 [info]  Application phoenix started at :nonode@nohost
 
12:05:52.235 [info]  Child Gettext.ExtractorAgent of Supervisor #PID<0.309.0> (Supervisor.Default) started
Pid: #PID<0.310.0>
Start Call: Gettext.ExtractorAgent.start_link([])
Restart: :permanent
Shutdown: 5000 
Type: :worker
 
12:05:52.235 [info]  Application gettext started at :nonode@nohost
 
12:05:52.250 [info]  Child :disk_log_sup of Supervisor :kernel_safe_sup started
Pid: #PID<0.311.0>
Start Call: :disk_log_sup.start_link()
Restart: :permanent
Shutdown: 1000
Type: :supervisor
 
12:05:52.250 [info]  Child :disk_log_server of Supervisor :kernel_safe_sup started
Pid: #PID<0.312.0>
Start Call: :disk_log_server.start_link()
Restart: :permanent
Shutdown: 2000
Type: :worker
Sass is watching for changes. Press Ctrl-C to stop.

[watch] build finished, watching for changes...
[notice] Connecting to UNIX socket: "/run/user/1000/bus"

[notice] DBUS auth: sending initial data

[notice] Got GUID '027f216ba8c2148b5e89683862860b5f' from the server

[notice] Succesfully negotiated UNIX FD passing

[notice] Calling "/"::"org.freedesktop.DBus".:Hello([])

I understand this can be an issue from my OS version (although I found nothing indicating that):

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

I also tried replacing the image inside static/icon.png with something else, but it didn’t work either.

Questions

  • Am I doing something wrong?
  • Will this same icon show up in both Windows and Linux?

Marked As Solved

dominicletz

dominicletz

Creator of Elixir Desktop

Yes unfortunately the env variable is currently the only way Erlangs wx app overriding the icon. That said in MacOS things are a bit different, there to get your own icon in the Dock you have to create a MacOS app structure that contains your icon:

todo.app/Contents
todo.app/Contents/MacOS
todo.app/Contents/MacOS/run
todo.app/Contents/Resources
todo.app/Contents/Resources/icon.icns
todo.app/Contents/Info.plist
todo.app/Contents/PkgInfo

with Info.plist that names the icon file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>run</string>
    <key>CFBundleGetInfoString</key>
    <string>TodoApp version 3.3.0</string>
    <key>CFBundleIconFile</key>
    <string>icon.icns</string>
    <key>CFBundleIdentifier</key>
    <string>org.yourdomain.todoapp</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleLongVersionString</key>
    <string>3.3.0, (c) 2023 You</string>
    <key>CFBundleName</key>
    <string>TodoApp</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>3.3</string>
    <key>CFBundleVersion</key>
    <string>3.3.0</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright 2023 You</string>
    <key>ATSApplicationFontsPath</key>
    <string>Fonts</string>
    <key>NSPrincipalClass</key>
    <string>wxNSApplication</string>
</dict>
</plist>

For testing the icon around Erlang you can use the existing :wx.demo() and just create (or take an existing) app structure and copy erl into the app.

cp `which erl` todo.app/Contents/MacOS/run
vi todo.app/Contents/MacOS/run

Update exec "$BINDIR/erlexec" ${1+"$@"} to exec "$BINDIR/erlexec" ${1+"$@"} -eval 'wx:demo().' -noshell in todo.app/Contents/MacOS/run

Then running that app using open todo.app will show the icon.icns icon in the dock.

Also Liked

LostKobrakai

LostKobrakai

Should this be documented? Why is Desktop.Window documenting a config for the icon i if it would never be applied?

dominicletz

dominicletz

Creator of Elixir Desktop

More documentation is absolutely the right thing. Especially around these icons it took myself quite a while to grasp whats’ going on. But essentially there are three different icons (or two dependent on the platform).

From the top of the head this is it:

I’ll update the documentation.

Where Next?

Popular in Questions Top

myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

We're in Beta

About us Mission Statement