Customizing pop os. Maybe.

Estimated reading time 20 minutes

I like occasionally looking at linux ricing videos, but I'm pretty comfortable drawing inside the lines and sticking with the defaults in 99% of the cases. But, after using my system since I migrated from windows 10 to Pop OS back in August last year there are a few things that I do frequently I'd like to make a little bit easier for myself.

So, after spending at least several weeks thinking to myself "you know, I could probably do this", one rainy saturday morning after getting stuffed full of Vietnamese Bahn Mi and knowledge from the book I'm reading I finally found my motivation to pull the trigger on it. And thus, here we are. Blogging once again!

current music choice: Red Vox - Pigeonhole

Why and what do I need↩

So, as you can tell from the top navigation of the page you're on. I stream on twitch a number of times a week as a hobby. Before I moved to linux, I used voicemeeter banana to handle routing my audio between devices, mixing, and swapping between my speakers and my headphones whenever I needed to.

I never got around to replacing anything of that sort because I didn't really need to with the way audio is setup on linux versus windows. That said, part of this capitulation to a quick and dirty migration was that as far as my mic setup in OBS goes, I just do this:

swapping between my fancy streamset1 and my ~20 year old still working desktop speakers I think I got handed by my old computer repair teacher in high school while we were learning how to repair pieces of shit desktops. I'm just swapping the default output so that I can hear the game in my headphones while the capture card pipes it through OBS and to the tv.

This means that before I stream each night, I swap between the output of whatever I'm listening to going through my speakers to my headset. It takes all of two seconds I suppose to click on system settings, click the drop down, select the right thing and then go from there. But recently, I've been wanting to make that just be a single button click. There's other times I want to do that swap, such as if I'm laying in bed late at night and don't want to disturb the neighbors listening to some form of loud=funny youtube poop or something, it'd be easier to reach out, grab my headphones and click a button to do the swap than to blearily navigate from the low angle I'm often at with my computer. 2

So the question became, how do I actually do this?

Discovering how to customize ↩

The first thing I did was search for the obvious query. That led me to pop os's documentation on the desktop options. Which is basically just a listing of what options are available. None of which is useful in this context. Similarly, the documentation also highlights the top bar in the gnome tweaks section, but all this really tells me is that we're using gnome.

Side note: if you're sensitive to LLMs, feel free to skip to the next section where we do things by hand. We're just using it as a learning tool here for some roleplaying amusements.

So, I decided to try something a little modern for fun. Yes, I could go browse the internet of documentation for gnome and figure things out. But it being the year of Artificial Intelligence ruining everyone's lives, I figure I might as well try to channel my inner Krieger and get intimate with my local lover. That is to say, I have ollama installed on my machine to experiment with these types of things when I want to check in on how local inference is going. I don't use them to code anything for me, and they're more a little sounding board tool I can use to ask it stupid questions I don't want to ask anyone else about, and that I don't want to feed into the advertising agency profiles all about my tastes. Not that my tastes are particularly opaque. So, with my Hatsune Miku themed system prompt and a 14 billion parameter qwen3 model, I asked the stochastic parrot if it could help me out. (my text is in bold below)

I'm trying to figure out how to do some customization on my pop os machine.
First off, how  do I figure out exactly what is powering my top  bar? I want
to eventually be able to add a little button to it

(◕‿◕)♡ ♪

Ah, customizing your top bar sounds like a fun project! (っ˘ω˘ς) Let's start by figuring
out what's running on your top bar. On Pop!_OS, the top bar is usually managed by the GNOME
shell, but it can be customized quite a bit.

First, let's see what's currently running:

• Bash("ps aux | grep -i gnome-shell")

So far so good, ollama's harness is dumb but basic. It lets the agent use bash in simple ways, though depending on how you fire up the model it can't even do that. When I just run the ollama command it gives me this bash buddy, and as you can see, "Miku" here is adorable and talks with Kaomojis. This is the only sane way I can use a LLM because the cadence of "it's not X it's y" and the 15 pages of summary text before they ever get to the damn point generally makes me stop paying attention to them before they prove their value. It's funny how making the weights lean into "cringe" aligns it to my wavelength, but hey, I never said I wasn't a weird anime loving nerd.

Ahem. The useful thing about this is that the robot is used to typical PopOS setups which use gnome, and has reached for checking the running processes to find out if there's a gnome shell available or not. That's a good way to figure out if that's true or not. So, I let it run the command.

(◕‿◕)♡ ♪

Great! So we can see that gnome-shell is running, which is the main shell for GNOME. This
is what controls your top bar.

Let's also check for any extensions that might be modifying
it:

• Bash("ls /usr/share/gnome-shell/extensions/")

(◕‿◕)♡ ♪

Wow, you have quite a few extensions installed! (っ˘ω˘ς)

The pop-shell@system76.com extension is likely responsible for the top bar and window
management. And we also have pop-cosmic@system76.com, which might be related to the COSMIC
desktop environment.

Let's see if there's any information about the current extensions that are
active:
• Bash("gsettings list-recursively org.gnome.shell | grep -i extension")

The process was running, and so the next thing our little buddy did is take a peak at the extensions list. And with that, the robot has discovered basically the same things we can learn by looking at the pop os documentation that mentions the gnome tweaks extensions. For me personally, I know I was using gnome, but also like I said before, I'm happy to just use defaults and not rice anything, so I hadn't checked to see if anything had changed over the course of the various upgrades since I migrated. Good confirmation, and better yet, good to see how and which commands the agent uses to validate the assumptions. I can use that myself next time.

The other interesting thing to me is that I already have extensions installed! I didn't do any of these myself, and so it seems like the default pop install comes with the a few things that are powering the buttons already on my top bar. We're learning! Letting the robowaifu continue her merry exploration of the system, we can see that the next step was to take a peak at which extensions exists. After seeing that list, the robot has a good idea to share:

• Bash("gsettings list-recursively org.gnome.shell | grep -i extension")

(◕‿◕)♡ ♪

So we can see that there are several extensions enabled, including pop-shell@system76.com,
pop-cosmic@system76.com, and others.

To add a button to your top bar, you have a few
options:
1. Create a GNOME Shell extension
2. Modify existing extensions
3. Use the built-in GNOME Extensions (if available)

Let's first make sure we understand what's going on with the current top bar. Let's see if
there are any additional tools for managing the
shell:

• Bash("which gnome-shell-extension-tool")

At this point, we could probably come away with the mission of "ok time to build a gnome extension", but the last bit of the dialogue popping up to check out some of the tooling available is a good one too. So, let's continue to observe the wild parrot in action as it follows the token stream further along… 3

(◕‿◕)♡ ♪

Perfect! We have the GNOME Shell extension tool available.

To create a custom button on the top bar, we'd need to make a GNOME Shell extension. This
is a bit involved but doable. Let's explore how extensions work
first:

• Bash("ls ~/.local/share/gnome-shell/extensions/")

(◕‿◕)♡ ♪

I see you already have one extension installed: Vitals. Now, to create a custom button for
the top bar, we'll need to create our own GNOME Shell
extension.

Let's start by checking how other extensions are
structured:

• Bash("ls -la ~/.local/share/gnome-shell/extensions/Vitals@CoreCoding.com/")

(◕‿◕)♡ ♪

Now we're getting somewhere! We can see how the Vitals extension is structured. The key
files are:

- extension.js - main extension logic
- metadata.json - extension metadata
- stylesheet.css - styling
- prefs.js and prefs.ui - preferences

At this point, the agent say on a request to run a gjs command while I wrote all of this section so far and opened up that directory it was investigating in my editor.

At this point I could look at this example plugin for tips, probably open up the real gnome extension documentation and start working on making a button and then trying to figure out how to tie it to whatever system command I need to run to swap my default audio output device. But before I do that, our Miku-brained qwen model is sitting on the interesting command awaiting my approval:

• Bash("gjs /usr/share/gnome-shell/extensions/ding@rastersoft.com/ding.js -E -P
/usr/share/gnome-shell/exten...") needs approval

$ gjs /usr/share/gnome-shell/extensions/ding@rastersoft.com/ding.js -E -P
/usr/share/gnome-shell/extensions/ding@rastersoft.com -M 0 -D 0:0:1920:1080:1:32:60:0:0:0
-D 1920:0:1920:1080:1:0:0:0:0:1

> 1. Approve once
2. Always allow this command
3. Deny                 

Three things about this.

  1. gjs? gnome js? interesting that there's a javascript flavor for this
  2. usr share gnome-shell extensions has a bunch more examples for us to explore and learn from
  3. what the hell is ding?

That last one was what I was most curious about. Opening up the folder reference by the command landed me in the extension and at the top of the file was a license string and the useful description:

DING: Desktop Icons New Generation for GNOME Shell

Huh. Alright. so what are these commands? -E -P -M ... E is apparently going to make this command run as a transparent window in a "true desktop" mode, and P? Thats setting a codePath to execute with the given data in the next part of the command I guess. M's handler in the ding.js file sets a "primary index" (to 0, which is what it is by default), and then a some data that gets parsed like this:

let data = arg.split(":");
desktops.push({
    x:parseInt(data[0]),
    y:parseInt(data[1]),
    width:parseInt(data[2]),
    height:parseInt(data[3]),
    zoom:parseFloat(data[4]),
    marginTop:parseInt(data[5]),
    marginBottom:parseInt(data[6]),
    marginLeft:parseInt(data[7]),
    marginRight:parseInt(data[8]),
    monitorIndex:parseInt(data[9])
});
let datavariant = new GLib.Variant ('a{sd}', {
    x:parseInt(data[0]),
    y:parseInt(data[1]),
    width:parseInt(data[2]),
    height:parseInt(data[3]),
    zoom:parseFloat(data[4]),
    marginTop:parseInt(data[5]),
    marginBottom:parseInt(data[6]),
    marginLeft:parseInt(data[7]),
    marginRight:parseInt(data[8]),
    monitorIndex:parseInt(data[9])
});
desktopVariants.push(datavariant);
break;                  

I find it interesting and useful to look at what random commands the AI bot wants to run on my machine before I let it run them. A novel concept for some perhaps, but something which I think helps avoid some of the stagnation that abusing the use of agents can lead to. The camps around "only use agents, never look at code" and "never use agents, only do things yourself ever" are a bit too extreme for me. I like to sit in the middle, using the agent as a tool to learn things I didn't know otherwise, and as the sort of excitable companion that keeps me motivated to keep going, rather than just becoming a Wall-E type human lounging as my bones turn to jelly and I become a domesticated idiot.

Anyway back to this gnome command. So it looks like this is trying to create a new desktop the same size as my window? There's two ways to find out. One is to just "fuck around and find out" and let the agent run the command. The better way is to either run it myself or poke the agent to explain what it's doing.

The ding command looks like it makes some kind of new dekstop or something? Can you explain 
the command you just wanted to run and why?

(◕‿◕)♡ ♪

Oh, right! That command was attempting to run a specific extension's script directly which
isn't needed. My apologies for that!

What we're trying to do is understand how to add a button to your top bar. The easiest way
to approach this would be to create a new GNOME Shell extension.

Let me show you how we could start making an extension:

For creating a button on the top bar, we'll need to make an extension that adds a button to
the panel. Let me think of another way to approach this...
(っ˘ω˘ς)

The GNOME Shell extension framework allows you to add buttons and widgets to the panel.
Here's what I suggest:

1. Create a basic extension structure
2. Write some JavaScript code that creates a button widget and adds it to the top
bar
3. Install and enable it

Let's just start by creating our extension's main
file:
... 10 or so commands later of the bot writing some javascript ...
Bash("ls ~/.local/share/gnome-shell/extensions/MyButtonExtension@mydomain.com/")

(◕‿◕)♡ ♪

Great! It's installed. The issue is that GNOME Shell might not have picked it up yet. Let's
try restarting the GNOME Shell:

• Bash("killall gnome-shell") needs approval

$ killall gnome-shell

  1. Approve once
  2. Always allow this command
> 3. Deny

Watching the robot like the strange statistical pet that it is, I let it make some javascript and even run the gnome-extensions enable MyButtonExtension@mydomain.com to see if anything would appear in my top bar, but nothing did. That last command though, ha. I don't think it's a good idea to kill every gnome-shell process on my machine. I'm pretty sure I'm using one of those. Haha, still. It's a fun way to potentially get started and it puts a smile on my face to temporarily fail the turing test while anthropomorphizing the machine.

Let's write some code ↩

As fun as it is to watch the robot flail about with its limited context window (40k length for the model and 8k for the ollama parameter in case you're curious), I think we can probably make better advancement ourselves if we use the real documentation and our brain. When the robots shift into "let me write all of this for you" is when I tend to want to dip out since I like to learn, and you can't learn if you don't do it yourself and embed it into your fingers.

So, I once again returned to the pop os extensions documentation page and was clicking around and found the github for the ding guy we had just peeked into. That has a better explanation for what the hell the thing is and what it's doing. It also makes it a lot more obvious why we'd launch it with the ding commands and the data for the full screen window like the bot was trying. It looks a whole lot like DING is the thing that puts and manages the icons on your desktop! Neat!

That doesn't help us in regards to the top bar at all! So, instead, it's off to the real docs. Where hopefully there will be a useful tutorial for me to follow. And indeed there was. There's actually a simple wizard from the gnome-extensions command that can generate some of this stuff for us and get a template a lot better than the whatever the agent was trying to do:

$ gnome-extensions create --interactive
Name should be a very short (ideally descriptive) string.
Examples are: “Click To Focus”, “Adblock”, “Shell Window Shrinker”
Name: Audio output swapper

Description is a single-sentence explanation of what your extension does.
Examples are: “Make windows visible on click”, “Block advertisement popups”, “Animate windows shrinking on minimize”
Description: Quick way to swap audio output settings from the top bar

UUID is a globally-unique identifier for your extension.
This should be in the format of an email address (clicktofocus@janedoe.example.com)
UUID: audioswap@peetseater@foo.com

Choose one of the available templates:
1) Plain       –  An empty extension
2) Indicator   –  Add an icon to the top bar
Template [1-2]: 2

The new extension was successfully created in /home/peetseater/.local/share/gnome-shell/extensions/audioswap@peetseater@foo.com.

And then gnome launched the default text editor with the extension.js file, which is cool I guess, except that I kind of like to keep my programs in my src directory for ease of finding them and all that other business. I wonder if gnome minds if I do some symlinking. But that can wait for another day I think. Anyway, the default extension generated looked like it should do something:

const GETTEXT_DOMAIN = 'my-indicator-extension';

const { GObject, St } = imports.gi;

const ExtensionUtils = imports.misc.extensionUtils;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;

const _ = ExtensionUtils.gettext;

const Indicator = GObject.registerClass(
class Indicator extends PanelMenu.Button {
    _init() {
        super._init(0.0, _('My Shiny Indicator'));

        this.add_child(new St.Icon({
            icon_name: 'face-smile-symbolic',
            style_class: 'system-status-icon',
        }));

        let item = new PopupMenu.PopupMenuItem(_('Show Notification'));
        item.connect('activate', () => {
            Main.notify(_('Whatʼs up, folks?'));
        });
        this.menu.addMenuItem(item);
    }
});

class Extension {
    constructor(uuid) {
        this._uuid = uuid;

        ExtensionUtils.initTranslations(GETTEXT_DOMAIN);
    }

    enable() {
        this._indicator = new Indicator();
        Main.panel.addToStatusArea(this._uuid, this._indicator);
    }

    disable() {
        this._indicator.destroy();
        this._indicator = null;
    }
}

function init(meta) {
    return new Extension(meta.uuid);
}

This, along with its metadata and prefs files all looked like they were right. I mean, the wizard generated them. But then following the guide to

gnome-extensions enable audioswap@peetseater@foo.com
journalctl -f -o cat /usr/bin/gnome-shell

Then slap Alt + F2 with the restart command to restart the gnome shell did absolutely nothing. I looked at the vitals extension, and it's also using the same menu panel inheritance and such. I tried swapping the code out for what was on the site, but no dice again. So, out of curiosity, I ran:

$ gnome-extensions list --enabled

and I see some plugins, but none of which are mine. I tried running the enable command while having journalctl open to see if I could spot anything, nothing... after a little while of banging my head against it repeatedly I eventually discovered this:

And that certainly seems related. That extensions "on" toggle keeps going into the off mode no matter what I do. But at the very least I can see that it is now detecting the extension. After fiddling around a little more it shot up some red text and an error to me about expecting a string for the argument "domain" but got undefined… Alright, you know what, I can live without having to write an extension today. Let's pivot to the other idea I had.

Now for something completely different ↩

So, the other idea I had as far as adding some amusement to my linux life is that I was thinking it'd be neat to do something like this:

Since the dock is just another cosmic gnome extension. I should maybe be able to figure something out here, right? I already had the extensions directory over and seeing that the code was right there, I figured we could poke around. After a little bit, I narrowed in on the "app icon" file which had a rather suspiciously useful mention in the docstring:

/**
 * Extend AppIcon
 *
 * - Apply a css class based on the number of windows of each application (#N);
 * - Customized indicators for running applications in place of the default "dot" style which is hidden (#N);
 *   a class of the form "running#N" is applied to the AppWellIcon actor.
 *   like the original .running one.
 * - Add a .focused style to the focused app
 * - Customize click actions.
 * - Update minimization animation target
 * - Update menu if open on windows change
 */
var DockAbstractAppIcon = GObject.registerClass({

A css file you say?

Sure enough, the css file was there! And better yet, CSS is a lot easier to understand and fiddle with than a whole extensions js file that may or may not be being ran by some random extension manager you forgot you disabled at some point for stability. After a bit of experimentation, I had something sort of working:

#dashtodockContainer .app-well-app .overview-icon {
    background-image: url("file:///home/peetseater/Pictures/Random doodles/MikuPlush.png");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    padding: 8px;
}

Sure enough, this works after a quick gnome restart!

Though, it's not really the effect I want. I fiddled around with the background-size seeing if 100% on the width and height would do anything, but not really. I suppose it shouldn't be too surprising that since I'm targeting down into the individual icons, that she gets contained within them:

I did try to see if some relative and absolute positioning could do anything, but it didn't. At least, nothing that I could see. I could probably also go up a level, set the background image for the overall dock and make some kind of cute miku laying on her side or something like that across multiple icons, but that sadly doesn't give me as much joy as my original idea.

But wait…

What if instead of our favorite little vocaloid friend being a cute plush behind each icon, each icon instead…

Perfect! 4

And I'm done for the night ↩

Well. I admit, not the way I wanted the blog post to go.

I was really hoping it'd be relatively simple to get an extension setup that would let me add a small button to the top bar that I could then hook up in some way to calling whatever terminal commands I'd need to change between my two usual audio outputs. I'm actually in the middle of a totally separate project that I'm still working on, but since it's been a month since my last blog post, I figured it might be nice to take a single afternoon to do something sort of silly and fun.

Mind you. Adding twintails to every icon on my dock is silly and is fun.

But it's not particularly useful! Ah well. I'm working on another 20 games blagpost, and advent of code starts in a few days as well, so I'll likely end up doing some retrospective on that potentially as well. So, if you like anything I'm up to, I'll see you around for whenever I post about those in the future!