<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mediawiki.comfac.net/index.php?action=history&amp;feed=atom&amp;title=Ollama_GNOME_System_Tray_Panel_260401</id>
	<title>Ollama GNOME System Tray Panel 260401 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mediawiki.comfac.net/index.php?action=history&amp;feed=atom&amp;title=Ollama_GNOME_System_Tray_Panel_260401"/>
	<link rel="alternate" type="text/html" href="https://mediawiki.comfac.net/index.php?title=Ollama_GNOME_System_Tray_Panel_260401&amp;action=history"/>
	<updated>2026-06-05T09:49:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mediawiki.comfac.net/index.php?title=Ollama_GNOME_System_Tray_Panel_260401&amp;diff=211&amp;oldid=prev</id>
		<title>Justinaquino: &quot;Add Ollama GNOME System Tray Panel guide&quot;</title>
		<link rel="alternate" type="text/html" href="https://mediawiki.comfac.net/index.php?title=Ollama_GNOME_System_Tray_Panel_260401&amp;diff=211&amp;oldid=prev"/>
		<updated>2026-03-31T16:38:11Z</updated>

		<summary type="html">&lt;p&gt;&amp;quot;Add Ollama GNOME System Tray Panel guide&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Adding an Ollama System Tray Control to GNOME (Ubuntu) =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
When using Ollama locally, large language models (LLMs) are loaded directly into your GPU&amp;#039;s VRAM for fast processing. However, Ollama keeps these models &amp;quot;hot&amp;quot; in memory for a period of time after you finish chatting. If you are running heavy models (like a 7B or 8B parameter model), this can easily consume 5GB+ of VRAM, leaving little room for gaming, video editing, or other GPU-intensive tasks.&lt;br /&gt;
&lt;br /&gt;
Instead of repeatedly opening a terminal to run &amp;lt;code&amp;gt;systemctl&amp;lt;/code&amp;gt; commands to kill the service, you can create a lightweight GNOME panel application (system tray icon). This utility provides a simple, two-click visual interface to start and stop the Ollama background service, immediately freeing up your VRAM when needed.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;One-Click Controls:&amp;#039;&amp;#039;&amp;#039; Start or stop the Ollama systemd service directly from the top panel.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Visual Status:&amp;#039;&amp;#039;&amp;#039; The icon dynamically changes to show whether Ollama is currently running (&amp;lt;code&amp;gt;▶&amp;lt;/code&amp;gt;) or stopped (&amp;lt;code&amp;gt;⏸&amp;lt;/code&amp;gt;).&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Asynchronous Execution:&amp;#039;&amp;#039;&amp;#039; Uses background threading so password prompts (&amp;lt;code&amp;gt;pkexec&amp;lt;/code&amp;gt;) do not freeze your desktop environment.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Auto-Polling:&amp;#039;&amp;#039;&amp;#039; Detects if Ollama was started or stopped from a terminal and updates the panel icon automatically.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Step 1: Install Prerequisites ===&lt;br /&gt;
&lt;br /&gt;
You will need the Python bindings for GTK3 and AppIndicator to allow the script to integrate with the GNOME top panel.&lt;br /&gt;
&lt;br /&gt;
Open your terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt update&lt;br /&gt;
sudo apt install python3-gi python3-gi-cairo gir1.2-appindicator3-0.1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Step 2: Create the Python Script ===&lt;br /&gt;
&lt;br /&gt;
Create a new Python file in a permanent location, such as your home directory or a dedicated scripts folder.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
nano ~/ollama-panel.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the following code into the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import gi&lt;br /&gt;
import subprocess&lt;br /&gt;
import threading&lt;br /&gt;
&lt;br /&gt;
# Require the necessary GTK and AppIndicator versions&lt;br /&gt;
gi.require_version(&amp;#039;Gtk&amp;#039;, &amp;#039;3.0&amp;#039;)&lt;br /&gt;
gi.require_version(&amp;#039;AppIndicator3&amp;#039;, &amp;#039;0.1&amp;#039;)&lt;br /&gt;
from gi.repository import Gtk, AppIndicator3, GLib&lt;br /&gt;
&lt;br /&gt;
class OllamaIndicator:&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        # Initialize with a placeholder icon; it will update immediately&lt;br /&gt;
        self.indicator = AppIndicator3.Indicator.new(&lt;br /&gt;
            &amp;quot;ollama_indicator&amp;quot;,&lt;br /&gt;
            &amp;quot;system-run&amp;quot;,&lt;br /&gt;
            AppIndicator3.IndicatorCategory.APPLICATION_STATUS&lt;br /&gt;
        )&lt;br /&gt;
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)&lt;br /&gt;
&lt;br /&gt;
        self.menu = Gtk.Menu()&lt;br /&gt;
&lt;br /&gt;
        # Start Button&lt;br /&gt;
        self.start_item = Gtk.MenuItem(label=&amp;#039;▶ Start Ollama&amp;#039;)&lt;br /&gt;
        self.start_item.connect(&amp;#039;activate&amp;#039;, lambda _: self.run_systemctl(&amp;#039;start&amp;#039;))&lt;br /&gt;
        self.menu.append(self.start_item)&lt;br /&gt;
&lt;br /&gt;
        # Stop Button&lt;br /&gt;
        self.stop_item = Gtk.MenuItem(label=&amp;#039;⏹ Stop Ollama&amp;#039;)&lt;br /&gt;
        self.stop_item.connect(&amp;#039;activate&amp;#039;, lambda _: self.run_systemctl(&amp;#039;stop&amp;#039;))&lt;br /&gt;
        self.menu.append(self.stop_item)&lt;br /&gt;
&lt;br /&gt;
        self.menu.append(Gtk.SeparatorMenuItem())&lt;br /&gt;
&lt;br /&gt;
        # Quit Button&lt;br /&gt;
        quit_item = Gtk.MenuItem(label=&amp;#039;Quit Panel App&amp;#039;)&lt;br /&gt;
        quit_item.connect(&amp;#039;activate&amp;#039;, Gtk.main_quit)&lt;br /&gt;
        self.menu.append(quit_item)&lt;br /&gt;
&lt;br /&gt;
        self.menu.show_all()&lt;br /&gt;
        self.indicator.set_menu(self.menu)&lt;br /&gt;
&lt;br /&gt;
        # Run an initial status check&lt;br /&gt;
        self.update_status()&lt;br /&gt;
&lt;br /&gt;
        # Poll systemctl every 3 seconds to catch external changes&lt;br /&gt;
        GLib.timeout_add_seconds(3, self.update_status)&lt;br /&gt;
&lt;br /&gt;
    def get_ollama_status(self):&lt;br /&gt;
        # Suppress errors/output so it fails gracefully if cancelled&lt;br /&gt;
        result = subprocess.run(&lt;br /&gt;
            [&amp;quot;systemctl&amp;quot;, &amp;quot;is-active&amp;quot;, &amp;quot;ollama&amp;quot;],&lt;br /&gt;
            capture_output=True, text=True&lt;br /&gt;
        )&lt;br /&gt;
        return result.stdout.strip() == &amp;quot;active&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    def update_status(self):&lt;br /&gt;
        active = self.get_ollama_status()&lt;br /&gt;
&lt;br /&gt;
        if active:&lt;br /&gt;
            self.indicator.set_icon_full(&amp;quot;media-playback-start&amp;quot;, &amp;quot;Ollama is running&amp;quot;)&lt;br /&gt;
            self.start_item.set_sensitive(False)&lt;br /&gt;
            self.stop_item.set_sensitive(True)&lt;br /&gt;
        else:&lt;br /&gt;
            self.indicator.set_icon_full(&amp;quot;media-playback-pause&amp;quot;, &amp;quot;Ollama is stopped&amp;quot;)&lt;br /&gt;
            self.start_item.set_sensitive(True)&lt;br /&gt;
            self.stop_item.set_sensitive(False)&lt;br /&gt;
&lt;br /&gt;
        return True # Returning True keeps the GLib timer running&lt;br /&gt;
&lt;br /&gt;
    def run_systemctl(self, command):&lt;br /&gt;
        def execute():&lt;br /&gt;
            # Run the command and wait for it to finish (or be cancelled)&lt;br /&gt;
            subprocess.run([&amp;quot;pkexec&amp;quot;, &amp;quot;systemctl&amp;quot;, command, &amp;quot;ollama&amp;quot;])&lt;br /&gt;
            # Schedule a UI update on the main GTK thread once done&lt;br /&gt;
            GLib.idle_add(self.update_status)&lt;br /&gt;
&lt;br /&gt;
        # Fire in a background thread so the polkit prompt doesn&amp;#039;t freeze the panel&lt;br /&gt;
        threading.Thread(target=execute, daemon=True).start()&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    app = OllamaIndicator()&lt;br /&gt;
    Gtk.main()&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit your text editor.&lt;br /&gt;
&lt;br /&gt;
=== Step 3: Make the Script Executable ===&lt;br /&gt;
&lt;br /&gt;
Grant the script permission to run as an executable program:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
chmod +x ~/ollama-panel.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can test it immediately by running &amp;lt;code&amp;gt;python3 ~/ollama-panel.py&amp;lt;/code&amp;gt;. An icon should appear in your top-right system tray.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Optional: Configure Passwordless Toggling ==&lt;br /&gt;
&lt;br /&gt;
By default, clicking &amp;quot;Start&amp;quot; or &amp;quot;Stop&amp;quot; will bring up a graphical prompt asking for your sudo password. If you want to bypass this for convenience:&lt;br /&gt;
&lt;br /&gt;
# Open the sudoers editor safely:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo visudo&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
# Add this line to the very bottom of the file (replace &amp;lt;code&amp;gt;your_username&amp;lt;/code&amp;gt; with your actual Ubuntu username):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
your_username ALL=(ALL) NOPASSWD: /bin/systemctl start ollama, /bin/systemctl stop ollama&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Save and exit.&lt;br /&gt;
# Open &amp;lt;code&amp;gt;~/ollama-panel.py&amp;lt;/code&amp;gt; and change the &amp;lt;code&amp;gt;subprocess.run&amp;lt;/code&amp;gt; line inside the &amp;lt;code&amp;gt;execute()&amp;lt;/code&amp;gt; function from &amp;lt;code&amp;gt;&amp;quot;pkexec&amp;quot;&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;&amp;quot;sudo&amp;quot;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
subprocess.run([&amp;quot;sudo&amp;quot;, &amp;quot;systemctl&amp;quot;, command, &amp;quot;ollama&amp;quot;])&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Setting Up Autostart (Run on Boot) ==&lt;br /&gt;
&lt;br /&gt;
To ensure the control panel is always available when you log in:&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;#039;&amp;#039;&amp;#039;Startup Applications&amp;#039;&amp;#039;&amp;#039; tool from your Ubuntu application menu.&lt;br /&gt;
# Click &amp;#039;&amp;#039;&amp;#039;Add&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
# Fill in the fields:&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;Name:&amp;#039;&amp;#039;&amp;#039; Ollama Control Panel&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;Command:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;/usr/bin/python3 /home/YOUR_USERNAME/ollama-panel.py&amp;lt;/code&amp;gt; — ensure you use the absolute path to your script&lt;br /&gt;
#* &amp;#039;&amp;#039;&amp;#039;Comment:&amp;#039;&amp;#039;&amp;#039; System tray toggle for the Ollama service.&lt;br /&gt;
# Click &amp;#039;&amp;#039;&amp;#039;Save&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:System Administration]]&lt;br /&gt;
[[Category:AI]]&lt;br /&gt;
[[Category:Ollama]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:GNOME]]&lt;/div&gt;</summary>
		<author><name>Justinaquino</name></author>
	</entry>
</feed>