--- 
canonical: 'https://mwop.net/blog/2024-09-17-wezterm-dropdown.html'
title: 'Wezterm Dropdown in Gnome'
author: "[Matthew Weier O'Phinney](https://mwop.net)"
created: '2024-09-17T15:37:01-05:00'
updated: '2024-09-17T15:37:01-05:00'
tags:
  - gnome
  - gnome-shell
  - linux
  - wayland
  - wezterm

---
In [a previous article](/blog/2024-07-04-how-i-use-wezterm.html), I detailed how I use Wezterm.
One goal I had when switching to Wezterm to was to ensure I was able to continue using a dropdown terminal, and in that article, I detailed using the `tdrop` utility to implement this... but with the caveat that it didn't work well under the Wayland environment.

Well, I've now found a better solution.





Recently, when looking for a completely unrelated gnome-shell extension, I stumbled across the [Quake terminal extension](https://github.com/diegodario88/quake-terminal).
I decided to give it a try to see if it was using a built-in terminal library, or calling out to existing terminals, and was surprised to discover it was the latter... and that it found my Wezterm install!

Not only that, but it worked exactly as I would expect - it dropped in the terminal from the top, at a partial height, and hitting the hot key scrolled it back out.

### Customizing the terminal

That said, I wanted to do a couple things different, and needed to experiment:

- I wanted the terminal to be partially transparent, so that I can see what's under it on the screen.
- I don't want window decorations for my dropdown terminal.
- I want to use Wezterm's multiplexer, and open in a dedicated workspace.

I'd achieved this in `tdrop` by writing a separate command that `tdrop` would invoke, and I wondered if I could do that here.

At first, I had no luck.
The terminal would open, but as a regular window, and not as a dropdown.

And then I did a bit more reading, and realized what I needed to do.

I discovered that Quake Terminal looks for `.desktop` files where the `Categories` field includes `TerminalEmulator`.
From there, the next important bit is that the `WM_CLASS` of the running application has to match the application ID.

In practice, this means the following:

- The `.desktop` file needs the name to be a valid application ID.
  The recommendation in the XDG spec is that this follows the `TLD.HOST.APP` format, and needs to be unique.
  I chose `net.mwop.wezterm-dropdown` for mine, and thus the file is named `net.mwop.wezterm-dropdown.desktop`.
- When invoking Wezterm, I need to specify the `WM_CLASS`.
  I can do this with the `--class` option to the `start` subcommand: `wezterm start --class=net.mwop.wezterm-dropdown`.

In the end, the full command I would run became:

```bash
wezterm \
  --config "window_background_opacity=0.85" \
  --config "window_decorations='NONE'" \
  start \
    --cwd . \
    --class=net.mwop.dropdown-terminal \
    --domain unix \
    --attach \
    --workspace dropdown
```

I specified this originally in the `Exec=` line of my `net.mwop.wezterm-dropdown.desktop` file, but I found that it would open a bare window on first execution, and only on the second and subsequent executions would it become a dropdown.

So I moved that invocation to the file `$HOME/.local/bin/wezterm-dropdown`, and added an `exec` at the front of it, and modified the desktop file to read `Exec=/home/matthew/.local/bin/wezterm-dropdown`.
This works slightly better - the first invocation opens it as a bare window, but when you hit the hot key again, it hides it, and after that, it opens as a dropdown.
I can live with this.

### The final files

The `wezterm-dropdown` script:

```bash
#!/usr/bin/zsh
# File: $HOME/.local/bin/wezterm-dropdown
exec wezterm \
  --config "window_background_opacity=0.85" \
  --config "window_decorations='NONE'" \
  start \
    --cwd . \
    --class=net.mwop.dropdown-terminal \
    --domain unix \
    --attach \
    --workspace dropdown
```

The `net.mwop.wezterm-dropdown.desktop` file (this goes in `$HOME/.local/share/applications/`):

```ini
[Desktop Entry]
Name=Dropdown Terminal
Comment=Wezterm as a dropdown terminal
Keywords=shell;prompt;command;commandline;cmd;
Icon=org.wezfurlong.wezterm
StartupWMClass=org.wezfurlong.wezterm
Exec=/home/matthew/.local/bin/wezterm-dropdown
Type=Application
Categories=System;TerminalEmulator;Utility;
Terminal=false
```