ddterm / gnome-shell-extension-ddterm

Another drop down terminal extension for GNOME Shell. With tabs. Works on Wayland natively
https://extensions.gnome.org/extension/3780/ddterm/
GNU General Public License v3.0
313 stars 27 forks source link

extension: expose Hide action in D-Bus API #745

Closed SyntaxBlitz closed 10 months ago

SyntaxBlitz commented 10 months ago

I have some scripts that I mostly only run from the dropdown terminal, and I like them to be able to close the dropdown automatically when they finish. Toggle works, but on the rare occasions when I run these scripts from other terminals, I don't want it to open the dropdown. Using Activate then Toggle is a workaround, but it causes the terminal to flicker when the dropdown is not already active.

This PR exposes the idempotent Hide action over the D-Bus API. I think I hit all the spots where the code needed to be updated -- I just grepped toggle and activate and looked for all the spots where it looked like I needed to wire things up. Apologies if I missed anything; I haven't fully wrapped my head around the extension architecture, so this is mostly a copy-paste job.

I wrote this against the v46 tag because I'm running GNOME shell 42.9 (on jammy), but it merges fine against master as well. Tested manually on my machine with:

gdbus call --session --dest=org.gnome.Shell --object-path /org/gnome/Shell/Extensions/ddterm --method com.github.amezin.ddterm.Extension.Hide

which seems to work the same way as .Activate. I don't see anything breaking if I call it when the terminal is already hidden.

amezin commented 10 months ago

Does gapplication action com.github.amezin.ddterm hide not work for you?

Doing this through the extension API may have a few positive effects - like not starting the app if it's not running, and waiting for the window to actually hide. But is it necessary in your case?

By the way, v47 should also work fine on GNOME 42, if I'm not mistaken.

SyntaxBlitz commented 10 months ago

Ah, thanks for the pointer! I jumped to D-Bus because the last extension I used (before I upgraded to jammy yesterday) only had a D-Bus API; when I saw this extension also had D-Bus listeners, that's where I started looking for a hide action. Indeed, the extension API you mentioned does work for me.

v46 was a bit of an arbitrary choice I made from skimming the release notes, since I was more sure it would work. I figured this diff probably wouldn't touch the ESM updates either way.

Wonderful extension! Thanks again.

amezin commented 10 months ago

On the other hand, adding this method shouldn't cause any issues, and it'll make the interface logically complete.