lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.27k stars 162 forks source link

Execute command with dbus #409

Open vredesbyyrd opened 4 years ago

vredesbyyrd commented 4 years ago

Currently its possible to "run a custom command" when starting tilda. With the new dbus implementation is it possible to toggle a tilda instance, than execute a command via dbus?

My end goal is to pipe a command into tilda from a yad/zenity dialog. Sounds a little convoluted I know...haha.

Thanks for your time.

vredesbyyrd commented 4 years ago

Hi,

I tried a pretty hackish approach to accomplishing this; just toggling a tilda instance via dbus and then simulating input with xdotool. To my surprise it works pretty well, but ill have to play with it a little more.

#!/usr/bin/bash

yad=$(yad --entry --no-buttons --center --borders=0 --undecorated \
  --skip-taskbar --width=350 --height=40 --licon="search-textbox.svg" )
val=$?

function get_tilda() {
  dbus-send --session --type=method_call \
    --dest=com.github.lanoxx.tilda.Actions4 \
    /com/github/lanoxx/tilda/Actions4 \
    com.github.lanoxx.tilda.Actions.Toggle
    sleep 0.07; xdotool type --clearmodifiers -delay 0 "$(printf '%s %s' 'get' "${yad}")"
    xdotool key KP_Enter
}

if [[ $val -eq 0 ]]; then
  get_tilda
fi

Here is crappy gif that may communicate the objective better than myself.

Peek 2020-04-09 18-13

lanoxx commented 4 years ago

Currently that is not implemented but in general the D-Bus implementation would enable to add that in the future.

vredesbyyrd commented 4 years ago

Okay, thats what I was thinking after inspecting the interface with d-feet.

I discovered guake has a dbus interface for sending commands, so alongside my normal 4 instances of Tilda I will just run a single instance of guake for the time being. If I was confident I could implement this feature in Tilda myself I would, my c is just not up to par I'm afraid. If that changes in the near future I will give it a shot.

Thanks for sharing this amazing terminal!