create localWebApps option

This commit is contained in:
atagen 2024-05-02 10:52:19 +10:00
parent a9e78be414
commit 9bc61077d5
5 changed files with 178 additions and 32 deletions

View file

@ -34,34 +34,34 @@
type = "Application";
icon = ../icons/openwebui.png;
exec = "${let
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"}";
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"} -a \"Ollama OpenWebUI\"";
systemctl = "${lib.getExe' pkgs.systemd "systemctl"}";
dex = "${lib.getExe pkgs.dex}";
curl = "${lib.getExe pkgs.curl}";
in
pkgs.writeShellScript "ollama"
''
${notify-send} "Ollama OpenWebUI" "Launching backend.."
${notify-send} "Launching backend.." "Please be patient."
${systemctl} --user start open-webui
attempts=0
success=false
while [[ $attempts -lt $((20*9)) ]]; do
if [[ $(${curl} http://127.0.0.1:3021) ]]; then
${notify-send} "Ollama OpenWebUI" "Launching client.."
${notify-send} "Backend up." "Launching client.."
success=true
break
else
attempts=$((attempts+1))
if [[ $(($attempts % 20)) -eq 0 ]]; then
${notify-send} "Ollama OpenWebUI" "Still launching backend.. ($((attempts/2))s)"
${notify-send} "Launching backend.." "Still launching.. ($((attempts/2))s)"
fi
fi
sleep 0.5
done
if [[ ! $success ]]; then
${notify-send} "Ollama OpenWebUI" "Failed to launch backend!"
${notify-send} "Failure" "Failed to launch backend!"
${systemctl} --user kill open-webui
exit 1
fi
@ -69,7 +69,7 @@
sleep 0.5 # give it a little time
${dex} -w ~/.nix-profile/share/applications/OpenWebUI.desktop
${notify-send} "Ollama OpenWebUI" "Shutting down."
${notify-send} "Goodbye" "Shutting down."
${systemctl} --user stop open-webui
exit 0
''}";

View file

@ -34,34 +34,34 @@
type = "Application";
icon = ../icons/comfyui.png;
exec = "${let
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"}";
notify-send = "${lib.getExe' pkgs.libnotify "notify-send"} -a Stable Diffusion";
systemctl = "${lib.getExe' pkgs.systemd "systemctl"}";
dex = "${lib.getExe pkgs.dex}";
curl = "${lib.getExe pkgs.curl}";
in
pkgs.writeShellScript "stable-diffusion"
''
${notify-send} "Stable Diffusion" "Launching backend.."
${notify-send} "Launching backend.." "Please be patient."
${systemctl} --user start stable-diffusion
attempts=0
success=false
while [[ $attempts -lt $((20*9)) ]]; do
if [[ $(${curl} http://127.0.0.1:7860) ]]; then
${notify-send} "Stable Diffusion" "Launching client.."
${notify-send} "Backend up." "Launching client.."
success=true
break
else
attempts=$((attempts+1))
if [[ $(($attempts % 20)) -eq 0 ]]; then
${notify-send} "Stable Diffusion" "Still launching backend.. ($((attempts/2))s)"
${notify-send} "Launching backend.." "Still launching.. ($((attempts/2))s)"
fi
fi
sleep 0.5
done
if [[ ! $success ]]; then
${notify-send} "Stable Diffusion" "Failed to launch backend!"
${notify-send} "Failure" "Failed to launch backend!"
${systemctl} --user kill stable-diffusion
exit 1
fi
@ -69,7 +69,7 @@
sleep 0.5 # give it a little time
${dex} -w ~/.nix-profile/share/applications/StableDiffusion.desktop
${notify-send} "Stable Diffusion" "Shutting down."
${notify-send} "Goodbye" "Shutting down."
${systemctl} --user stop stable-diffusion
exit 0
''}";