diff --git a/lib/freedive/api/service/icons.ex b/lib/freedive/api/service/icons.ex new file mode 100644 index 0000000..af35493 --- /dev/null +++ b/lib/freedive/api/service/icons.ex @@ -0,0 +1,25 @@ +defmodule Freedive.Api.Service.Icons do + def icon_for_service(name) do + case name do + "automountd" -> "hard-drive" + "autounmountd" -> "hard-drive" + "caddy" -> "globe" + "cron" -> "clock" + "dbus" -> "bus" + "devd" -> "usb" + "ip6addrctl" -> "network" + "lockd" -> "lock" + "moused" -> "mouse" + "ntpd" -> "clock" + "pf" -> "shield" + "pflog" -> "newspaper" + "powerd" -> "utility-pole" + "sddm" -> "user" + "sshd" -> "lock" + "statd" -> "braces" + "syslogd" -> "newspaper" + "tailscaled" -> "shield" + _ -> "puzzle" + end + end +end diff --git a/lib/freedive/api/service/server.ex b/lib/freedive/api/service/server.ex index e6c860a..ecc6666 100644 --- a/lib/freedive/api/service/server.ex +++ b/lib/freedive/api/service/server.ex @@ -5,6 +5,7 @@ defmodule Freedive.Api.Service do use GenServer require Logger import Freedive.Api.Service.Cli + import Freedive.Api.Service.Icons def start_link(opts) do GenServer.start_link(__MODULE__, opts, name: __MODULE__) @@ -24,6 +25,11 @@ defmodule Freedive.Api.Service do @impl true def handle_continue(_opts, state) do {:ok, services} = list_services() + services = services + |> Enum.map(fn {name, service} -> + {name, Map.put(service, :icon, icon_for_service(name))} + end) + |> Enum.into(%{}, &{&1[:name], &1}) state = %{state | services: services} {:noreply, state} end