This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Command for showing the desktop (minimizing all windows)

Tags: dbus dbus dbus
(comma "," separated)
User avatar
JaKi
Registered Member
Posts
109
Karma
0
OS
In KDE3 it was possible to access the desktop (i.e. minimize all windows) with a dcop call. What's the equivalent in KDE4 to access the desktop (from a script or servicemenu or so)? I took a look at qdbusviewer but I couldn't figure it out.
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS
Type
Code: Select all
qdbus org.kde.plasma-desktop
(replace plasma-desktop with plasma, if you use a KDE-version before 4.3.0) (You can see other applications by executing qdbus)
You'll get a list of strings like:
Code: Select all
/
/App
/FileUndoManager
/JobViewServer
/KIO
/KIO/Scheduler
/MainApplication
/VisualNotifications

Take one of these and add it to the command:
Code: Select all
qdbus org.kde.plasma-desktop /App

Execute it and you'll get a list of other strings:
Code: Select all
method void local.PlasmaApp.toggleDashboard()
method int org.kde.KUniqueApplication.newInstance()
method int org.kde.KUniqueApplication.newInstance(QByteArray asn_id)
method int org.kde.KUniqueApplication.newInstance(QByteArray asn_id, QByteArray args)
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()

Add (for example) local.PlasmaApp.toggleDashboard
Code: Select all
qdbus org.kde.plasma-desktop /App local.PlasmaApp.toggleDashboard

Execute it and the dashboard will the toggled.
I hope it is useful.

Jan


Image
User avatar
JaKi
Registered Member
Posts
109
Karma
0
OS
Thanks for your detailed answer, now I know at least a little how to deal with the structure of qdbus. Is it always the /App part? I tried searching for something that has to do with showing the desktop or minimizing windows but either there is nothing which I cannot imagine or the problem sits between chair and keyboard... :( Any idea?

BTW: Do you know how to deal with such things in brackets?

Code: Select all
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)


Edit: I found a command to switch to the next desktop:
Code: Select all
qdbus org.kde.kwin /KWin org.kde.KWin.nextDesktop

That could do the job if I knew that the next desktop is empty...
But the real show/toogle desktop would be better. Do I look in the wrong direction? I'd expect it to be something with "toggle".
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS
The things in brackets are arguments and you use them like this (I'll take another method)
Code: Select all
qdbus org.kde.kwin /KWin org.kde.KWin.setCurrentDesktop 2

The description looks like this
Code: Select all
method bool org.kde.KWin.setCurrentDesktop(int desktop)

int means integer and is a number like 1 40 5. desktop is the name of the variable (in this case it means the desktop to go to). If there's something like you wrote
Code: Select all
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)

The arguments are separated with whitspaces (" "):
Code: Select all
qdbus org.kde.kwin /KWin org.freedesktop.DBus.Properties.Set "first string" "the next string" "a variant: a number, a string or something else"


Image
User avatar
JaKi
Registered Member
Posts
109
Karma
0
OS
I see, thanks. Is there a way to search for specific elements in qdbus?
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS
I wrote a script (I didn't know any other way).
Use:
pathToScript searchterm
pathToScript --kde searchterm

If you add --kde it only searches in paths which start with org.kde (all of the KDE applications, I think).
Here's the code:
Code: Select all
#!/bin/sh
#Searchs for a search term
#If the option --kde is set, it only searchs paths that start with org.kde
#It uses qdbus
usage="Usage: dbussearch [--kde] <search term>"
filter=""

if [ "x$1" = "x" ];then
  echo $usage
  exit 1
fi

if [ "$1" = "--kde" ];then
  filter="org.kde"
  shift
fi

#qdbus command
qdbus="qdbus 2> /dev/null"
#Get the programm list
programms=""
if [ "$filter" ]; then
  programms=`bash -c "$qdbus" | grep $filter | sed -e 's/\n/ /g'`
else
  programms=`bash -c "$qdbus" | sed -e 's/\n/ /g'`
fi

for program in $programms; do
  paths=`bash -c "$qdbus $program" | sed -e 's/\n/ /g'`
  for path in $paths; do
    methods=`bash -c "$qdbus $program $path" | grep -i $1`
    if [ "x$methods" != "x" ];then
      echo $methods
    fi
  done
done

Save it and set the x-bit (execute-bit) by
chmod +x pathToScript


Image
User avatar
JaKi
Registered Member
Posts
109
Karma
0
OS
That's great - thanks! :)
User avatar
JanGerrit
Moderator
Posts
647
Karma
3
OS
No problem :)
It is fun to do tasks like this and I like helping ;)


Image


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]