Yakuake qdbus script

Hi I built the following yakuake.sh script for yakuake start-up, most of it works however I’m unable to resize the terminals - I’m pretty new to this so any help or guidance really appreciated.

#!/bin/bash
# DEPENDENCIES
#Yakuake, cmatrix, neofetch, bpytop 
#CONCEPT
#Have a drop down 'quake' like terminal which has a standard terminal on the left and bpytop on the right
# bpytop will appear to be overlaid on top of cmatrix giving a great visualization whilst also providing a great system monitor
# QDBusViewer was very useful in setting up this script

#This will create a split terminal as shown on diagram below.
#+--------------------------------+--------------------------------+
#|TerminalID=0 (runs neofetch)    |TerminalID=1 (runs cmatrix)     |
#|                                +--------------------------------+
#|                                |TerminalID=2 (runs bpytop)      |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#+                                +--------------------------------+
#|                                |TerminalID=3 (runs cmatrix)     |
#+--------------------------------+--------------------------------+

# This line is needed in case Yakuake does not accept fcitx inputs. 
#(don't know what this does - copied from example script)
/usr/bin/yakuake --im /usr/bin/fcitx --inputstyle onthespot &

# gives Yakuake a couple seconds before sending dbus commands
sleep 2      
#set-up some variables

#set tab title
qdbus org.kde.yakuake /yakuake/tabs setTabTitle 0 "user"

#set-up terminal split design (see diagram above)
#split terminal into two left/right
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalLeftRight "0"

#Now split the RHS into 3 terminals
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalTopBottom "1"

qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalTopBottom "2"

#now resize the right hand middle terminal to take up most the space (the next two lines don't work)
qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalTop "2" 250

qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalBottom "2" 200

#Now run applications
qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 0 "neofetch"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 1 "cmatrix"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 2 "bpytop"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 3 "cmatrix"

First I’d like to say that a colleague of mine made a similar script for automating konsole and I adapted to use it with yakuake, what a life saver!

On topic: try to use org.kde.yakuake.tryGrowTerminal(Bottom|Top) instead?

At least that’s what auto-complete gives me after taping Tab a couple of times:

$ qdbus org.kde.yakuake /yakuake/sessions
QDBusVariant                                             org.kde.yakuake.isTerminalKeyboardInputEnabled
QString                                                  org.kde.yakuake.isTerminalMonitorActivityEnabled
QVariantMap                                              org.kde.yakuake.isTerminalMonitorSilenceEnabled
bool                                                     org.kde.yakuake.raiseSession
int                                                      org.kde.yakuake.removeSession
method                                                   org.kde.yakuake.removeTerminal
org.freedesktop.DBus.Introspectable.Introspect           org.kde.yakuake.runCommand
org.freedesktop.DBus.Peer.GetMachineId                   org.kde.yakuake.runCommandInTerminal
org.freedesktop.DBus.Peer.Ping                           org.kde.yakuake.sessionIdForTerminalId
org.freedesktop.DBus.Properties.Get                      org.kde.yakuake.sessionIdList
org.freedesktop.DBus.Properties.GetAll                   org.kde.yakuake.setSessionClosable
org.freedesktop.DBus.Properties.PropertiesChanged        org.kde.yakuake.setSessionKeyboardInputEnabled
org.freedesktop.DBus.Properties.Set                      org.kde.yakuake.setSessionMonitorActivityEnabled
org.kde.yakuake.activeSessionId                          org.kde.yakuake.setSessionMonitorSilenceEnabled
org.kde.yakuake.activeTerminalId                         org.kde.yakuake.setTerminalKeyboardInputEnabled
org.kde.yakuake.addSession                               org.kde.yakuake.setTerminalMonitorActivityEnabled
org.kde.yakuake.addSessionQuad                           org.kde.yakuake.setTerminalMonitorSilenceEnabled
org.kde.yakuake.addSessionTwoHorizontal                  org.kde.yakuake.splitSessionLeftRight
org.kde.yakuake.addSessionTwoVertical                    org.kde.yakuake.splitSessionTopBottom
org.kde.yakuake.hasTerminalsWithKeyboardInputDisabled    org.kde.yakuake.splitTerminalLeftRight
org.kde.yakuake.hasTerminalsWithKeyboardInputEnabled     org.kde.yakuake.splitTerminalTopBottom
org.kde.yakuake.hasTerminalsWithMonitorActivityDisabled  org.kde.yakuake.terminalIdList
org.kde.yakuake.hasTerminalsWithMonitorActivityEnabled   org.kde.yakuake.terminalIdsForSessionId
org.kde.yakuake.hasTerminalsWithMonitorSilenceDisabled   org.kde.yakuake.tryGrowTerminalBottom
org.kde.yakuake.hasTerminalsWithMonitorSilenceEnabled    org.kde.yakuake.tryGrowTerminalLeft
org.kde.yakuake.hasUnclosableSessions                    org.kde.yakuake.tryGrowTerminalRight
org.kde.yakuake.isSessionClosable                        org.kde.yakuake.tryGrowTerminalTop
org.kde.yakuake.isSessionKeyboardInputEnabled            signal
org.kde.yakuake.isSessionMonitorActivityEnabled          void
org.kde.yakuake.isSessionMonitorSilenceEnabled

HTH

Edit: though runCommandInTerminal works for me whithout needing the preceding org.kde.yakuake.

One more thing: if yakuake is alredy running, your terminal/session IDs might be wrong, try to save them in variables, e.g.:

SESSION_ID=$(qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.addSession)
qdbus org.kde.yakuake /yakuake/tabs setTabTitle ${SESSION_ID} 'My Title'
TOP_TERMINAL_ID=$(qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.terminalIdsForSessionId ${SESSION_ID})
qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal ${TOP_TERMINAL_ID} 'my_top_command_goes_here'
BOTTOM_TERMINAL_ID=$(qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalTopBottom ${TOP_TERMINAL_ID})
qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal ${BOTTOM_TERMINAL_ID} 'my_bottom_command_goes_here'

Edit: added split terminal example

[quote=“richarson, post:2, topic:799”]
On topic: try to use org.kde.yakuake.tryGrowTerminal(Bottom|Top) instead?
[/quote

Hi thanks for the suggestion, that doesn’t appear to be recognised, I can use
org.kde.yakuake.tryGrowTerminalBottom 2 20
without any errors appearing and can send it successfully using QDbusviewer but on further investigation in the script it I can see that small numbers <~20 (which should be pixels) doesn’t move the terminal window at all and larger numbers seem to complexly expand TerminalID 2 Terminals 1 and 3 are there but minimized to be invisible - my mouse can resize them so they cam bee seen.

Thanks I was aware of this, but as I’m launching Yakuake within this script it shouldn’t be an issue.

so I think this problem is possibly with my syntax for how much to expand the terminal - that or it is broken - more likely to me though…

Yeah, I meant you use org.kde.yakuake.tryGrowTerminalBottom and org.kde.yakuake.tryGrowTerminalTop

Sorry for the convoluted syntax, regex habit :slight_smile:

no problem.

So using qdbusviewer I can see that tryGrowTerminalTop is overloaded.
You can use it with just the terminalID or with the TerminalID and the pixels you want to move it the behavior im getting in the script is the behaviour without the second parameter, but I can’t work out how to correct the script so that it takes both the terminalID and the pixels to move

1 Like

I made it work in my yakuake.

Supose the top terminal is 0 and the bottom is 1:

  • qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalTop 1 100 grows the bottom terminal 100 pixels up, shrinking the top terminal

  • qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalBottom 0 100 grows the top terminal 100 pixels down, shrinking the bottom terminal

Hi, Thanks for trying this.
I copy & pasted your example, changed the TerminalID and I still have the same behavior, I.e. it expands the terminal completely in the appropriate direction.
i.e.
qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalTop 2 100
fully expands terminal 2 to the top - i.e. it is ignoring the pixel parameter. If I run this command in QDBusViewer it expands as expected by 100px upwards

Odd, I se the duplicated tryGrowTerminalTop in qdbusviewer but from a terminal (either another yakuake tab or a konsole window) it works for me without issues.

But I never tried this method before, so it may be a bug? What version of yakuake are you using?

Mine is:

$ yakuake --version
yakuake 22.12.3

same one 22.12.3 - very weird

Ah so I might be getting somewhere, this also works for me in Yakuake terminal but not in the script
this is my script which I run at start-up

#!/bin/bash
# DEPENDENCIES
#Yakuake, cmatrix, neofetch, bpytop make sure all these work before installing this config file
#CONCEPT
#Have a drop down 'quake' terminal which has a standard terminal on the left and bpytop on the right
# BPYtop appears to be overlaid on top of cmatrix giving a great visualisation whilst also providing a great
# system monitor
# QDBusViewer was very useful in setting up this script

#This will create a split terminal as shown on diagram below.
#+--------------------------------+--------------------------------+
#|TerminalID=0 (runs neofetch)    |TerminalID=1 (runs cmatrix)     |
#|                                +--------------------------------+
#|                                |TerminalID=2 (runs bpytop)      |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#|                                |                                |
#+                                +--------------------------------+
#|                                |TerminalID=3 (runs cmatrix)     |
#+--------------------------------+--------------------------------+

# This line is needed in case Yakuake does not accept fcitx inputs.
#(don't know what this does - copied from example script)
/usr/bin/yakuake --im /usr/bin/fcitx --inputstyle onthespot &

# gives Yakuake a couple seconds before sending dbus commands
sleep 2      

#set tab title
qdbus org.kde.yakuake /yakuake/tabs setTabTitle 0 "user"

#set-up terminal split design (see diagram above)
#split terminal into two left/right
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalLeftRight 0

#Now split the RHS into 3 terminals
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalTopBottom 1

qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.splitTerminalTopBottom 2

#now resize the right hand middle terminal to take up most the space

qdbus org.kde.yakuake /yakuake/sessions tryGrowTerminalTop 2 100

qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.tryGrowTerminalBottom 2 200

#Now run applications
qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 0 "neofetch"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 1 "cmatrix -u 9"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 2 "bpytop"

qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal 3 "cmatrix -u 9"