in kde how can I get the current activity name by command line in konsole?
the one shown by the “cashwe” or what else its name placed in the upper right corner of screen
many thanks, ciao, pier
Why do you want that?
You can get the ID of the current activity e.g. via:
qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity
You can get the name of a certain activity like this:
qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName *$ID*
($ID specifies the ID of the activity from which you want to get the name)
Combine this to get the name of the current activity:
qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`
Maaanythanks, at the end wasn’t so easy :-), I want to have the activity name showed in a more readable way and I cannot easy modify the object in the upper right of the screen, so I will do a plasmoid that shows the activity name… or is there a better way??
Well, if you are going to write a plasmoid, you could probably use DBUS directly instead of by calling the program “qdbus”.
Depending on which language you use, you could probably also use Plasma’s functions directly.
But as this question is completely KDE specific (rather low-level even) and has nothing to do with openSUSE, you should probably better ask in the KDE forums/mailinglists…
uh, I’m not so skilly to kwon what to do to write a plasmoid…:), I only modify a python plasmoid
# Written by Grissiom chaos.proton@gmail.com
# This script is inspired by ruby-cpufreq plasmoid and released under GPL
# license. It noly goal is to display CPU frequency. If you want to do CPU
# scaling, try PowerDevil.
# Thanks to:
# wd <wd@wdicc.com> for sharing his/her script that teach me to use file object.
# Wang Hoi <zealot.hoi@gmail.com> for teaching me getting font from Plasma.font()
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QFontMetrics
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
import os
class CpuFreqDisplay(plasmascript.Applet):
def __init__(self, parent, args = None):
plasmascript.Applet.__init__(self, parent)
def init(self):
self.setHasConfigurationInterface(False)
self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
self.ft = self.font()
# set to a reasonable pixelSize
self.ft.setPixelSize(30)
# from plasmaengineexplorer, solidservice seems not working on
# my box. So I cannot use DataEngin here...
# signal cored machine will have /sys/devices/system/cpu/cpu0/ too.
# FIXME: What if the box have cores with different frequency?
# f = os.system("whoami")
# afreq = os.system("whoami")
# f.close()
# self.afreq = os.system("whoami")
self.afreq = os.popen("qdbus org.kde.ActivityManager /ActivityManager/Activities ActivityName `qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity`")
self.cfreq = self.afreq.readline().rstrip("
")
# now = f.read()
# self.afreq.sort()
# self.cfreq = 0
# self.update_freq()
#self.startTimer(1000)
def paintInterface(self, p, option, rect):
p.save()
text = "KDE Activity=" + (self.cfreq)
self.color = Qt.blue
p.setFont(self.ft)
p.translate(rect.x(), rect.y())
p.scale(float(rect.width()) / p.boundingRect(rect, Qt.AlignTop | Qt.AlignLeft, text).width(),
float(rect.height()) / p.boundingRect(rect, Qt.AlignTop | Qt.AlignLeft, text).height())
p.setPen(self.color)
# from the doc: The y-position is used as the baseline of the font.
y = QFontMetrics(self.ft).ascent()
p.drawText(0, y, text)
p.restore()
def CreateApplet(p):
return CpuFreqDisplay(p)
I found in the net or use stdin-plasmoid, but it could be a good idea to ask to kde people …