Jump to content

Recommended Posts

Posted (edited)

About This File

image.png.1770b0a554b9de4c88960b18fddb4f27.png


open-webui is a nice toy but leaves the command prompt where it runs visible and I wanted to hide it, or move it to the tray. Solution ?, code it.
So here is the open-webui-ToTray I wanted.

Not much to it, just WinSetState() to hide/show the window.
Is more of an app than an example script but it'd need a place to chat about it ( if needed ) hence posting here instead of the examples area.

Command parameters are:
  /runUpdate = to run the update command (new in v0.0.0.3)
  /hide = to hide overiding the ini declaration
  /show = to show overiding the ini declaration
  /exit = do one of the above and exit the tray icon, if that is what you'd like. It'll wait 2 secs before exiting.

The way I use it, is with a shortcut in "shell:startup" and that runs the script that in turn, runs open-webui and then hides it to tray.

If the "OI" icon in the tray area is blue it's all good, now if it's red, then the title was not found. If so, check the ini file and change what needs changing.
On updates the icon is green.
While the window loaded but not ready ( the page is not ready yet ) the icon is violet.
Double click the tray icon to either, hide/show the terminal window or run the ExtraCmd ( set to load the web UI ).
Right click for the context menu.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

What's New in Version 0.0.0.2

Changed the way it waits for the terminal to be ready.
If the "title" in the ini file is empty, the command is used as part of the title.
That opens the possibility to use this script, as is, for other commands that open windows that the user may wanna send to tray.
Since icon files are preferred over those in the executable, just changing the icons and running from another folder makes this a flexible toy to have.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

What's New in Version 0.0.0.3

Added "cmdForUdate". The default is the command to update open-webui, but you can put anything there.
If "cmdForUdate" is empty, the context menu will not show the option. So that's how you hide the menu entry.

Added environment variables. By default sets or adds "WEBUI_AUTH=True". If you don't want it set to "WEBUI_AUTH=".
To have these be applied set DoEnvSet=1

Added, given that you may not ever double click to see the window, to do something else.
Added something else. There is a ExtraCmd area where you can have an extra menu entry that executes whaever you declare.
For more help look in https://www.autoitscript.com/autoit3/docs/functions/ShellExecute.htm because that is what it does/runs.
The default example is to open your current session of open-webui ( http://localhost:8080/?temporary-chat=true )
I did that because that's what I'll use it for.


In regards to WEBUI_AUTH=False, it will bypass asking for an email/password if it never had a user in it's users DB.


In python one can have a virtual environment and that keeps things neat. In the verbatim words of an AI:

Why a Virtual Environment is Preferable (and why users don't know):

Users, especially those new to development or specific tools, often aren't aware of the benefits of virtual environments. The "default install" often means installing directly into the system's Python environment, which can lead to:

  • Dependency Conflicts: Different projects might require different versions of the same library. Installing globally can cause these versions to clash, breaking one or both projects.
  • System Pollution: The global environment can become cluttered with many packages, some of which are no longer needed, making it harder to manage.
  • Reproducibility Issues: It's harder to guarantee that a project will run the same way on another machine if its dependencies are tangled with system-wide installations.
  • Permissions Problems: Installing globally often requires administrative privileges, which can be a security risk or an annoyance.

Virtual environments (like venv in Python) solve these problems by creating isolated spaces for each project, allowing them to have their own dependencies without interfering with others.

So, how do I get that venv done ?

SET WEBUI_AUTH=False
python -m venv C:\open-webui-venv
CD /d C:\open-webui-venv\Scripts
python.exe -m pip install --upgrade pip open-webui

1st line is to bypass the login. Since you're gonna use it at home might as well not have users.
2nd line is to set the venv ( virtual environment )
3rd line is to change the working directory to the one where our new venv has the executables
4th line is to finally install the open-webui.
Then you're ready to run it ( open-webui.exe serve --host 0.0.0.0 --port 8080 ) to test that it all runs.

That's what these 4 lines do. What is as default in my setup is without this venv but I had no idea of it's existence until @ioa747 called my attention.
We also have an update menu entry thanks to @ioa747 telling me to do it, that admittedly does come in handy as updates come in quite often as I later found out.

And that, I think wraps it up.

Edited by argumentum
English

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

What's New in Version 0.0.0.4

Fixed default phython's expected folder
Fixed default run and update commands
Better INI file comment handling
Some function refactoring.

Spoiler
... ...
If $g_1stRun Then
    If Not FileCreateShortcut(@AutoItExe, StringTrimRight(@ScriptFullPath, 4) & _
            " (script) - Shortcut.lnk", @ScriptDir, '/AutoIt3ExecuteScript "' & _
            @ScriptFullPath & '"', "Hide open-webui's WindowsTerminal.exe to tray", _
            StringTrimRight(@ScriptFullPath, 4) & ".ico") Then
        ConsoleWrite('@@(' & @ScriptLineNumber & ') : FileCreateShortcut FAILED' & @CRLF)
    EndIf ; added on v0.0.0.5
... ...

  ... didn't occur to add this. In the next release will be there :)

 

 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

  • Solution
Posted (edited)

What's New in Version 0.0.0.5

Added an icon ( looks violet to me ) to show while not online on startup ( optional default ).
Changed script reload to run via .lnk as otherwise I can not see the it's own icon on the Task Manager running as script.
Added key combination ( Ctrl + Shift ) that when pressed, on exit will not close the window if that was default.

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...